From: Mike Frysinger Date: Sun, 16 Feb 2014 06:59:20 +0000 (-0500) Subject: Implement xlat generator X-Git-Tag: v4.9~71 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=761ed9ba42d00aa9cbd4daceefbbff016e7c9f12;p=strace Implement xlat generator * bootstrap: New file. * xlat/gen.sh: Likewise. * Makefile.am: Include xlat/Makemodule.am (EXTRA_DIST): Add $(XLAT_INPUT_FILES), $(XLAT_HEADER_FILES), and xlat/gen.sh. --- diff --git a/Makefile.am b/Makefile.am index a789b8ca..7052157f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,6 +14,8 @@ ACLOCAL_AMFLAGS = -I m4 AM_CFLAGS = $(WARN_CFLAGS) AM_CPPFLAGS = -I$(srcdir)/$(OS)/$(ARCH) -I$(srcdir)/$(OS) -I$(builddir)/$(OS) +include xlat/Makemodule.am + strace_SOURCES = \ aio.c \ bjm.c \ @@ -213,6 +215,9 @@ EXTRA_DIST = \ strace-log-merge \ strace.spec \ syscallent.sh \ + $(XLAT_INPUT_FILES) \ + $(XLAT_HEADER_FILES) \ + xlat/gen.sh \ xlate.el .PHONY: srpm diff --git a/bootstrap b/bootstrap new file mode 100755 index 00000000..196d8e46 --- /dev/null +++ b/bootstrap @@ -0,0 +1,3 @@ +#!/bin/sh +./xlat/gen.sh +exec autoreconf -f -i diff --git a/xlat/gen.sh b/xlat/gen.sh new file mode 100755 index 00000000..23d5b8d8 --- /dev/null +++ b/xlat/gen.sh @@ -0,0 +1,96 @@ +#!/bin/sh + +usage() { + cat < + +Generate xlat header files from (a file or dir of files) and write +the generated headers to . +EOF + exit 1 +} + +gen_header() { + local input="$1" output="$2" name="$3" + local line + echo "generating ${output}" + ( + echo "/* Generated by $0 from $1; do not edit. */" + echo "const struct xlat ${name}[] = {" + while read line ; do + case ${line} in + /*|\#*|'') + echo "${line}" + ;; + *) + echo "#ifdef ${line}" + echo " XLAT(${line})," + echo "#endif" + ;; + esac + done < "${input}" + echo " XLAT_END" + echo "};" + ) >"${output}" +} + +gen_make() { + local output="$1" + local name + shift + echo "generating ${output}" + ( + printf "XLAT_INPUT_FILES = " + printf 'xlat/%s.in ' "$@" + echo + printf "XLAT_HEADER_FILES = " + printf 'xlat/%s.h ' "$@" + echo + for name; do + printf '$(top_srcdir)/xlat/%s.h: $(top_srcdir)/xlat/%s.in $(top_srcdir)/xlat/gen.sh\n' \ + "${name}" "${name}" + echo ' $(AM_V_GEN)$(top_srcdir)/xlat/gen.sh $< $@' + done + ) >"${output}" +} + +gen_git() { + local output="$1" + shift + echo "generating ${output}" + ( + printf '/%s\n' .gitignore Makemodule.am + printf '/%s.h\n' "$@" + ) >"${output}" +} + +main() { + case $# in + 0) set -- "${0%/*}" "${0%/*}" ;; + 2) ;; + *) usage ;; + esac + + local input="$1" + local output="$2" + local name + + if [ -d "${input}" ]; then + local f name names + for f in "${input}"/*.in; do + name=${f##*/} + name=${name%.in} + gen_header "${f}" "${output}/${name}.h" "${name}" & + names="${names} ${name}" + done + gen_git "${output}/.gitignore" ${names} + gen_make "${output}/Makemodule.am" ${names} + wait + else + name=${input##*/} + name=${name%.in} + gen_header "${input}" "${output}" "${name}" + fi +} + +main "$@"