3 if test -f config.sh; then TOP=.;
4 elif test -f ../config.sh; then TOP=..;
5 elif test -f ../../config.sh; then TOP=../..;
6 elif test -f ../../../config.sh; then TOP=../../..;
7 elif test -f ../../../../config.sh; then TOP=../../../..;
9 echo "Can't find config.sh."; exit 1
14 : This forces SH files to create target in same directory as SH file.
15 : This is so that make depend always knows where to find SH derivatives.
17 */*) cd `expr X$0 : 'X\(.*\)/'` ;;
19 echo "Extracting makedepend (with variable substitutions)"
21 $spitshell >makedepend <<'!NO!SUBS!'
25 export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh \$0; kill \$\$)
29 if test -f config.sh; then TOP=.;
30 elif test -f ../config.sh; then TOP=..;
31 elif test -f ../../config.sh; then TOP=../..;
32 elif test -f ../../../config.sh; then TOP=../../..;
33 elif test -f ../../../../config.sh; then TOP=../../../..;
35 echo "Can't find config.sh."; exit 1
44 $cat /dev/null >.deptmp
46 if test -f Makefile; then
51 defrule=`<$mf sed -n \
54 -e 's/^[^;]*;[ ]*//p' \
65 '') defrule='$(CC) -c $(CFLAGS)' ;;
68 : Create files in UU directory to avoid problems with long filenames
69 : on systems with 14 character filename limits so file.c.c and file.c
71 $test -d UU || mkdir UU
73 make clist || ($echo "Searching for .c files..."; \
74 $echo *.c | $tr ' ' '\012' | $egrep -v '\*' >.clist)
75 for file in `$cat .clist`; do
76 # for file in `cat /dev/null`; do
78 *.c) filebase=`basename $file .c` ;;
79 *.y) filebase=`basename $file .y` ;;
82 */*) finc="-I`echo $file | sed 's#/[^/]*$##`" ;;
85 $echo "Finding dependencies for $filebase.o."
86 ( $echo "#line 1 \"$file\""; \
88 -e "/^${filebase}_init(/q" \
95 $cppstdin $finc -I/usr/local/include -I. $cppflags $cppminus <UU/$file.c |
97 -e 's#\.[0-9][0-9]*\.c#'"$file.c#" \
98 -e 's/^[ ]*#[ ]*line/#/' \
99 -e '/^# *[0-9][0-9]* *[".\/]/!d' \
100 -e 's/^.*"\(.*\)".*$/'$filebase'.o: \1/' \
101 -e 's/^# *[0-9][0-9]* \(.*\)$/'$filebase'.o: \1/' \
103 -e 's|\.c\.c|.c|' | \
104 $uniq | $sort | $uniq >> .deptmp
107 $sed <$mf >$mf.new -e '1,/^# AUTOMATICALLY/!d'
109 make shlist || ($echo "Searching for .SH files..."; \
110 $echo *.SH | $tr ' ' '\012' | $egrep -v '\*' >.shlist)
111 if $test -s .deptmp; then
112 for file in `cat .shlist`; do
113 $echo `$expr X$file : 'X\(.*\).SH'`: $file $TOP/config.sh \; \
114 /bin/sh $file >> .deptmp
116 $echo "Updating $mf..."
117 $echo "# If this runs make out of memory, delete /usr/include lines." \
119 $sed 's|^\(.*\.o:\) *\(.*/.*\.c\) *$|\1 \2; '"$defrule \2|" .deptmp \
122 make hlist || ($echo "Searching for .h files..."; \
123 $echo *.h | $tr ' ' '\012' | $egrep -v '\*' >.hlist)
124 $echo "You don't seem to have a proper C preprocessor. Using grep instead."
125 $egrep '^#include ' `cat .clist` `cat .hlist` >.deptmp
126 $echo "Updating $mf..."
129 -e 's|^\(.*\)/\(.*\)\.c|\2.o: \1/\2.c; '"$defrule \1/\2.c|p" \
132 -e 's|^\(.*\)\.c|\1.o: \1.c|p' >> $mf.new
133 <.hlist $sed -n 's|\(.*/\)\(.*\)|s= \2= \1\2=|p' >.hsed
134 <.deptmp $sed -n 's|c:#include "\(.*\)".*$|o: \1|p' | \
135 $sed 's|^[^;]*/||' | \
136 $sed -f .hsed >> $mf.new
137 <.deptmp $sed -n 's|h:#include "\(.*\)".*$|h: \1|p' | \
138 $sed -f .hsed >> $mf.new
139 for file in `$cat .shlist`; do
140 $echo `$expr X$file : 'X\(.*\).SH'`: $file $TOP/config.sh \; \
141 /bin/sh $file >> $mf.new
148 $echo "# WARNING: Put nothing here or make depend will gobble it up!" >> $mf
149 $rm -rf .deptmp UU .shlist .clist .hlist .hsed
152 $eunicefix makedepend
157 ln makedepend ../makedepend