Skip to content

Commit

Permalink
Rework r339635 to fix .depend.tables.h handling.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bdrewery committed Aug 16, 2019
1 parent fb50acc commit 5b684f3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
9 changes: 3 additions & 6 deletions lib/libsysdecode/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
21 changes: 15 additions & 6 deletions lib/libsysdecode/mktables
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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

0 comments on commit 5b684f3

Please sign in to comment.