6 Usage: $0 <input> <output>
8 Generate xlat header files from <input> (a file or dir of files) and write
9 the generated headers to <output>.
16 local line val m def xlat
19 val="$(printf %s "${line}" | sed -n 's/^\([^[:space:]]\+\).*$/\1/p')"
21 def="$(printf %s "${line}" |
22 sed -n 's/^[^[:space:]]\+[[:space:]]\+\([^[:space:]].*\)$/\1/p')"
24 if [ "${m}" = "${m#1<<}" ]; then
28 xlat=" { ${val}, \"${m}\" },"
31 if [ -z "${def}" ]; then
33 #if defined(${m}) || (defined(HAVE_DECL_${m}) && HAVE_DECL_${m})
39 #if !(defined(${m}) || (defined(HAVE_DECL_${m}) && HAVE_DECL_${m}))
49 local input="$1" output="$2" name="$3"
50 echo "generating ${output}"
52 local defs="${0%/*}/../defs.h"
54 if grep -x "extern const struct xlat ${name}\\[\\];" "${defs}" > /dev/null; then
61 /* Generated by $0 from $1; do not edit. */
63 ${prefix}const struct xlat ${name}[] = {
65 local unconditional= unterminated= line
75 [A-Z_]*) # symbolic constants
76 if [ -n "${unconditional}" ]; then
77 echo " XLAT(${line}),"
82 '1<<'[A-Z_]*) # symbolic constants with shift
84 if [ -n "${unconditional}" ]; then
85 echo " { ${line}, \"${line#1<<}\" },"
90 [0-9]*) # numeric constants
91 echo " XLAT(${line}),"
98 if [ -n "${unterminated}" ]; then
99 echo " /* this array should remain not NULL-terminated */"
112 echo "generating ${output}"
114 printf "XLAT_INPUT_FILES = "
115 printf 'xlat/%s.in ' "$@"
117 printf "XLAT_HEADER_FILES = "
118 printf 'xlat/%s.h ' "$@"
121 printf '$(top_srcdir)/xlat/%s.h: $(top_srcdir)/xlat/%s.in $(top_srcdir)/xlat/gen.sh\n' \
123 echo ' $(AM_V_GEN)$(top_srcdir)/xlat/gen.sh $< $@'
132 echo "generating ${output}"
134 printf '/%s\n' .gitignore Makemodule.am
135 printf '/%s.h\n' "$@"
142 0) set -- "${0%/*}" "${0%/*}" ;;
151 local ncpus="$(getconf _NPROCESSORS_ONLN)"
152 [ "${ncpus}" -ge 1 ] ||
155 if [ -d "${input}" ]; then
157 for f in "${input}"/*.in; do
158 [ -f "${f}" ] || continue
161 gen_header "${f}" "${output}/${name}.h" "${name}" &
162 names="${names} ${name}"
164 if [ ${jobs} -ge ${ncpus} ]; then
169 gen_git "${output}/.gitignore" ${names}
170 gen_make "${output}/Makemodule.am" ${names}
175 gen_header "${input}" "${output}" "${name}"