From dc89d06976b7ce93b0e934f3dcd567def521bab4 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Fri, 16 Aug 2019 22:34:10 +0000 Subject: [PATCH] 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 --- lib/libsysdecode/Makefile | 9 +++------ lib/libsysdecode/mktables | 21 +++++++++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/libsysdecode/Makefile b/lib/libsysdecode/Makefile index 2be244a6da46..c96a39e0ffac 100644 --- a/lib/libsysdecode/Makefile +++ b/lib/libsysdecode/Makefile @@ -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. diff --git a/lib/libsysdecode/mktables b/lib/libsysdecode/mktables index 39f3a4f30b4a..4765ca5d8beb 100644 --- a/lib/libsysdecode/mktables +++ b/lib/libsysdecode/mktables @@ -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