Rework r339635 to fix .depend.tables.h handling.

Avoid touching the tables.h file unless it has changed to avoid unneeded
rebuilds.

Also revert r350301's explicit dependencies.

Reviewed by:	emaste
MFC after:	2 weeks
X-MFC-With:	r339635 (kevans request)
PR:		238828
Sponsored by:	DellEMC
Differential Revision:	https://reviews.freebsd.org/D21295
This commit is contained in:
Bryan Drewery 2019-08-16 22:34:10 +00:00
parent 49366f6299
commit dc89d06976
2 changed files with 18 additions and 12 deletions

View File

@ -107,7 +107,7 @@ MLINKS+=sysdecode_mask.3 sysdecode_accessmode.3 \
sysdecode_mask.3 sysdecode_wait4_options.3 \
sysdecode_mask.3 sysdecode_wait6_options.3
CLEANFILES= ioctl.c ioctl.c.tmp tables.h tables.h.tmp
CLEANFILES= ioctl.c ioctl.c.tmp tables.h
.if defined(COMPAT_32BIT)
CPP+= -m32
@ -123,11 +123,8 @@ CFLAGS.gcc.ioctl.c+= -Wno-redundant-decls
CFLAGS.gcc+= ${CFLAGS.gcc.${.IMPSRC}}
DEPENDOBJS+= tables.h
incdir=${SYSROOT:U${DESTDIR}}${INCLUDEDIR}
tables.h: mktables ${incdir}/netinet/in.h ${incdir}/netinet/tcp.h \
${incdir}/netinet6/in6.h
sh ${.CURDIR}/mktables ${incdir} ${.TARGET}.tmp && \
mv -f ${.TARGET}.tmp ${.TARGET}
tables.h: mktables
sh ${.CURDIR}/mktables ${SYSROOT:U${DESTDIR}}${INCLUDEDIR} ${.TARGET}
# mkioctls runs find(1) for headers so needs to rebuild every time. This used
# to be a hack only done in buildworld.

View File

@ -43,7 +43,8 @@ fi
include_dir=$1
if [ -n "$2" ]; then
output_file="$2"
exec > "$output_file"
output_tmp=$(mktemp -u)
exec > "$output_tmp"
fi
all_headers=
@ -167,9 +168,17 @@ fi
# 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"
depend_tmp=$(mktemp -u)
{
echo "$output_file: \\"
echo "$all_headers" | tr ' ' '\n' | sort -u |
sed -e "s,^, $include_dir/," -e 's,$, \\,'
echo
} > "$depend_tmp"
if cmp -s "$output_tmp" "$output_file"; then
rm -f "$output_tmp" "$depend_tmp"
else
mv -f "$depend_tmp" ".depend.${output_file}"
mv -f "$output_tmp" "$output_file"
fi
fi