Generate and use a proper .depend file for tables.h.

Reported by:	jhb
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
This commit is contained in:
Bryan Drewery 2016-11-13 00:11:12 +00:00
parent df5b485a4f
commit 5e1eb60d94
2 changed files with 18 additions and 2 deletions

View File

@ -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}" \

View File

@ -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