depend: remove script

Using the libgray approach the script is not needed anymore.
Instead of collecting all indirect dependencies of an object
(essentially redoing the work of the linker), we just link libgray.

This causes slightly more recompilations, but it's a lot simpler.
This commit is contained in:
Michele Guerini Rocco 2024-04-22 14:07:35 +02:00
parent be2cfe5ac9
commit e4b9236dbe
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450

30
depend
View File

@ -1,30 +0,0 @@
#!/bin/sh
# Compute the dependencies (direct and transitive) of an object
# This is used to collect all objects needed to link a program.
# Bail out when .d files are missing
test -f "${1%.o}.d" || exit 1
# Check whether $1 contains substring $2
contains(){ test "${1#*$2}" != "$1"; }
# Walk the dependency graph (consisting of the set of all .d files)
# and output the visited nodes (objects).
walk_dag(){
while read -r line; do
# skip the first line (file own name)
contains "$line" ': ' && continue
# only look up object files
contains "$line" '.o ' || continue
line="${line% \\}"
contains "$visited" "$line" && continue
visited="$line:$visited"
printf '%s ' "$line"
# whether the node is a leaf
test "$(wc -l < "${line%.o}.d")" -gt 1 && walk_dag < "${line%.o}.d"
done
}
printf '%s ' "$1" # the object itself
walk_dag < "${1%.o}.d"