barrier/tools/depconv

47 lines
892 B
Plaintext
Raw Normal View History

#!/bin/sh
#
# add dependency info from files on command line to $depfile
depfile="Makedepends"
dependencies=""
targets="^$"
# tmp directory
if test -z "$TMP"; then TMP=/tmp; fi
while [ -n "$*" ]; do
case "$1" in
-f)
depfile=$2
shift
shift
;;
-*)
echo "usage: $0 [-f <makefile>] <dependency-file> ..."
exit 1
;;
*)
break
esac
done
# collect all dependencies
while [ -n "$*" ]; do
line=`cat $1 | sed -e 's/\\\\//g' | sed -e 's/ \/[^ ]*//g'`
target=`echo $line | sed -e 's/^\([^:]*\):.*/\1/'`
targets="$targets|^$target:"
dependencies="$dependencies$line\n"
shift
done
# add new dependencies to $depfile
if [ -n "$targets" ]; then
if [ -r $depfile ]; then
(egrep -v $targets $depfile; echo -e -n $dependencies) > $TMP/dep$$
if [ $? -eq 0 ]; then mv $TMP/dep$$ $depfile; fi
else
echo -e -n $dependencies > $depfile
fi
fi