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 20OBJTOP=$1 21if [ ! -d "$OBJTOP" ]; then 22 echo "usage: $(basename $0) objtop" >&2 23 exit 1 24fi 25 26# $1 directory 27# $2 source filename w/o extension 28# $3 source extension 29clean_dep() 30{ 31 if egrep -qw "$2\.$3" "$OBJTOP"/$1/.depend.$2.*o 2>/dev/null; then 32 echo "Removing stale dependencies and objects for $2.$3" 33 rm -f \ 34 "$OBJTOP"/$1/.depend.$2.* \ 35 "$OBJTOP"/$1/$2.*o \ 36 "$OBJTOP"/obj-lib32/$1/.depend.$2.* \ 37 "$OBJTOP"/obj-lib32/$1/$2.*o 38 fi 39} 40 41# Date Rev Description 42# 20200310 r358851 rename of openmp's ittnotify_static.c to .cpp 43clean_dep lib/libomp ittnotify_static c 44# 20200414 r359930 closefrom 45clean_dep lib/libc closefrom S 46 47# 20200826 r364746 OpenZFS merge, apply a big hammer (remove whole tree) 48if [ -e "$OBJTOP"/cddl/lib/libzfs/.depend.libzfs_changelist.o ] && \ 49 egrep -qw "cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c" \ 50 "$OBJTOP"/cddl/lib/libzfs/.depend.libzfs_changelist.o; then 51 echo "Removing old ZFS tree" 52 rm -rf "$OBJTOP"/cddl "$OBJTOP"/obj-lib32/cddl 53fi 54 55# 20200916 WARNS bumped, need bootstrapped crunchgen stubs 56if [ -e "$OBJTOP"/rescue/rescue/rescue.c ] && \ 57 ! grep -q 'crunched_stub_t' "$OBJTOP"/rescue/rescue/rescue.c; then 58 echo "Removing old rescue(8) tree" 59 rm -rf "$OBJTOP"/rescue/rescue 60fi 61 62# 20210105 fda7daf06301 pfctl gained its own version of pf_ruleset.c 63if [ -e "$OBJTOP"/sbin/pfctl/.depend.pf_ruleset.o ] && \ 64 egrep -qw "sys/netpfil/pf/pf_ruleset.c" \ 65 "$OBJTOP"/sbin/pfctl/.depend.pf_ruleset.o; then 66 echo "Removing old pf_ruleset dependecy file" 67 rm -rf "$OBJTOP"/sbin/pfctl/.depend.pf_ruleset.o 68fi 69 70# 20210108 821aa63a0940 non-widechar version of ncurses removed 71if [ -e "$OBJTOP"/lib/ncurses/ncursesw ]; then 72 echo "Removing stale ncurses objects" 73 rm -rf "$OBJTOP"/lib/ncurses "$OBJTOP"/obj-lib32/lib/ncurses 74fi 75 76# 20210608 f20893853e8e move from atomic.S to atomic.c 77clean_dep cddl/lib/libspl atomic S 78# 20211207 cbdec8db18b5 switch to libthr-friendly pdfork 79clean_dep lib/libc pdfork S 80 81# 20211230 5e6a2d6eb220 libc++.so.1 path changed in ldscript 82if [ -e "$OBJTOP"/lib/libc++/libc++.ld ] && \ 83 fgrep -q "/usr/lib/libc++.so" "$OBJTOP"/lib/libc++/libc++.ld; then 84 echo "Removing old libc++ linker script" 85 rm -f "$OBJTOP"/lib/libc++/libc++.ld 86fi 87 88# 20220326 fbc002cb72d2 move from bcmp.c to bcmp.S 89if [ "$MACHINE_ARCH" = "amd64" ]; then 90 clean_dep lib/libc bcmp c 91fi 92 93# 20220524 68fe988a40ca kqueue_test binary replaced shell script 94if stat "$OBJTOP"/tests/sys/kqueue/libkqueue/*kqtest* \ 95 "$OBJTOP"/tests/sys/kqueue/libkqueue/.depend.kqtest* >/dev/null 2>&1; then 96 echo "Removing old kqtest" 97 rm -f "$OBJTOP"/tests/sys/kqueue/libkqueue/.depend.* \ 98 "$OBJTOP"/tests/sys/kqueue/libkqueue/* 99fi 100 101# 20221115 42d10b1b56f2 move from rs.c to rs.cc 102clean_dep usr.bin/rs rs c 103 104# 20230110 bc42155199b5 usr.sbin/zic/zic -> usr.sbin/zic 105if [ -d "$OBJTOP"/usr.sbin/zic/zic ] ; then 106 echo "Removing old zic directory" 107 rm -rf "$OBJTOP"/usr.sbin/zic/zic 108fi 109 110# 20230208 29c5f8bf9a01 move from mkmakefile.c to mkmakefile.cc 111clean_dep usr.sbin/config mkmakefile c 112# 20230209 83d7ed8af3d9 convert to main.cc and mkoptions.cc 113clean_dep usr.sbin/config main c 114clean_dep usr.sbin/config mkoptions c 115 116# 20230401 54579376c05e kqueue1 from syscall to C wrapper 117clean_dep lib/libc kqueue1 S 118