From 5e1eb60d943d42d38113a8c3f2df04899d488948 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Sun, 13 Nov 2016 00:11:12 +0000 Subject: [PATCH] Generate and use a proper .depend file for tables.h. Reported by: jhb MFC after: 2 weeks Sponsored by: Dell EMC Isilon --- lib/libsysdecode/Makefile | 3 ++- lib/libsysdecode/mktables | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/libsysdecode/Makefile b/lib/libsysdecode/Makefile index 5e0590e912f8..692bfbf6f08d 100644 --- a/lib/libsysdecode/Makefile +++ b/lib/libsysdecode/Makefile @@ -110,8 +110,9 @@ CFLAGS.gcc.ioctl.c+= -Wno-unused CFLAGS.gcc+= ${CFLAGS.gcc.${.IMPSRC}} +DEPENDOBJS+= tables.h tables.h: mktables - sh ${.CURDIR}/mktables ${DESTDIR}${INCLUDEDIR} > ${.TARGET} + sh ${.CURDIR}/mktables ${DESTDIR}${INCLUDEDIR} ${.TARGET} ioctl.c: mkioctls env MACHINE=${MACHINE} CPP="${CPP}" \ diff --git a/lib/libsysdecode/mktables b/lib/libsysdecode/mktables index 0cc2ff3dc770..e51ffe366022 100644 --- a/lib/libsysdecode/mktables +++ b/lib/libsysdecode/mktables @@ -37,11 +37,16 @@ LC_ALL=C; export LC_ALL if [ -z "$1" ] then - echo "usage: sh $0 include-dir" + echo "usage: sh $0 include-dir [output-file]" exit 1 fi include_dir=$1 +if [ -n "$2" ]; then + output_file="$2" + exec > "$output_file" +fi +all_headers= # # Generate a table C #definitions. The including file can define the # TABLE_NAME(n), TABLE_ENTRY(x), and TABLE_END macros to define what @@ -60,6 +65,7 @@ gen_table() else filter="egrep -v" fi + all_headers="${all_headers:+${all_headers} }${file}" cat <<_EOF_ TABLE_START(${name}) _EOF_ @@ -142,3 +148,12 @@ gen_table "sigcode" "SI_[A-Z]+[[:space:]]+0(x[0-9abcdef]+)?" "sys/ gen_table "umtxcvwaitflags" "CVWAIT_[A-Z_]+[[:space:]]+0x[0-9]+" "sys/umtx.h" gen_table "umtxrwlockflags" "URWLOCK_PREFER_READER[[:space:]]+0x[0-9]+" "sys/umtx.h" gen_table "caprights" "CAP_[A-Z_]+[[:space:]]+CAPRIGHT\([0-9],[[:space:]]+0x[0-9]{16}ULL\)" "sys/capsicum.h" + +# Generate a .depend file for our output file +if [ -n "$output_file" ]; then + echo "$output_file: \\" > ".depend.$output_file" + echo "$all_headers" | tr ' ' '\n' | sort -u | + sed -e "s,^, $include_dir/," -e 's,$, \\,' >> \ + ".depend.$output_file" + echo >> ".depend.$output_file" +fi