xref: /freebsd/tools/build/depend-cleanup.sh (revision e17f5b1d)
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
15OBJTOP=$1
16if [ ! -d "$OBJTOP" ]; then
17	echo "usage: $(basename $0) objtop" >&2
18	exit 1
19fi
20
21# $1 directory
22# $2 source filename w/o extension
23# $3 source extension
24clean_dep()
25{
26	if [ -e "$OBJTOP"/$1/.depend.$2.pico ] && \
27	    egrep -qw "$2\.$3" "$OBJTOP"/$1/.depend.$2.pico; then \
28		echo "Removing stale dependencies for $2.$3"; \
29		rm -f "$OBJTOP"/$1/.depend.$2.* \
30		    "$OBJTOP"/obj-lib32/$1/.depend.$2.*
31	fi
32}
33
34# Date      Rev      Description
35# 20190916  r352703  shm_open syscall reimplemented in C
36clean_dep lib/libc   shm_open S
37# 20200310  r358851  rename of openmp's ittnotify_static.c to .cpp
38clean_dep lib/libomp ittnotify_static c
39# 20200414  r359930  closefrom
40clean_dep lib/libc   closefrom S
41