svn commit: r308602 - head/lib/libsysdecode

Bryan Drewery bdrewery at FreeBSD.org
Sun Nov 13 00:11:14 UTC 2016


Author: bdrewery
Date: Sun Nov 13 00:11:12 2016
New Revision: 308602
URL: https://svnweb.freebsd.org/changeset/base/308602

Log:
  Generate and use a proper .depend file for tables.h.
  
  Reported by:	jhb
  MFC after:	2 weeks
  Sponsored by:	Dell EMC Isilon

Modified:
  head/lib/libsysdecode/Makefile
  head/lib/libsysdecode/mktables

Modified: head/lib/libsysdecode/Makefile
==============================================================================
--- head/lib/libsysdecode/Makefile	Sun Nov 13 00:11:09 2016	(r308601)
+++ head/lib/libsysdecode/Makefile	Sun Nov 13 00:11:12 2016	(r308602)
@@ -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}" \

Modified: head/lib/libsysdecode/mktables
==============================================================================
--- head/lib/libsysdecode/mktables	Sun Nov 13 00:11:09 2016	(r308601)
+++ head/lib/libsysdecode/mktables	Sun Nov 13 00:11:12 2016	(r308602)
@@ -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]+[[
 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


More information about the svn-src-all mailing list