]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tools/build/depend-cleanup.sh
retire an old NO_CLEAN dependency cleanup hack
[FreeBSD/FreeBSD.git] / tools / build / depend-cleanup.sh
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5 # Our current make(1)-based approach to dependency tracking cannot cope with
6 # certain source tree changes, including:
7 # - removing source files
8 # - replacing generated files with files committed to the tree
9 # - changing file extensions (e.g. a C source file rewritten in C++)
10 #
11 # We handle those cases here in an ad-hoc fashion by looking for the known-
12 # bad case in the main .depend file, and if found deleting all of the related
13 # .depend files (including for example the lib32 version).
14 #
15 # These tests increase the build time (albeit by a small amount), so they
16 # should be removed once enough time has passed and it is extremely unlikely
17 # anyone would try a NO_CLEAN build against an object tree from before the
18 # related change.  One year should be sufficient.
19
20 OBJTOP=$1
21 if [ ! -d "$OBJTOP" ]; then
22         echo "usage: $(basename $0) objtop" >&2
23         exit 1
24 fi
25
26 # $1 directory
27 # $2 source filename w/o extension
28 # $3 source extension
29 clean_dep()
30 {
31         if [ -e "$OBJTOP"/$1/.depend.$2.pico ] && \
32             egrep -qw "$2\.$3" "$OBJTOP"/$1/.depend.$2.pico; then \
33                 echo "Removing stale dependencies for $2.$3"; \
34                 rm -f "$OBJTOP"/$1/.depend.$2.* \
35                     "$OBJTOP"/obj-lib32/$1/.depend.$2.*
36         fi
37 }
38
39 # Date      Rev      Description
40 # 20200310  r358851  rename of openmp's ittnotify_static.c to .cpp
41 clean_dep lib/libomp ittnotify_static c
42 # 20200414  r359930  closefrom
43 clean_dep lib/libc   closefrom S
44
45 # 20200826  r364746  OpenZFS merge, apply a big hammer (remove whole tree)
46 if [ -e "$OBJTOP"/cddl/lib/libzfs/.depend.libzfs_changelist.o ] && \
47     egrep -qw "cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c" \
48     "$OBJTOP"/cddl/lib/libzfs/.depend.libzfs_changelist.o; then
49         echo "Removing old ZFS tree"
50         rm -rf "$OBJTOP"/cddl "$OBJTOP"/obj-lib32/cddl
51 fi