3 if test ! -f config.sh; then
5 ln ../../config.sh . || \
6 ln ../../../config.sh . || \
7 (echo "Can't find config.sh."; exit 1)
13 */*) cd `expr X$0 : 'X\(.*\)/'` ;;
15 echo "Extracting makedepend (with variable substitutions)"
17 $spitshell >makedepend <<!GROK!THIS!
19 # $RCSfile: makedepend.SH,v $$Revision: 4.1 $$Date: 92/08/07 18:24:20 $
21 # $Log: makedepend.SH,v $
22 # Revision 4.1 92/08/07 18:24:20 lwall
24 # Revision 4.0.1.4 92/06/08 13:51:24 lwall
25 # patch20: various and sundry fixes
27 # Revision 4.0.1.3 91/11/05 17:56:33 lwall
28 # patch11: various portability fixes
30 # Revision 4.0.1.2 91/06/07 15:40:06 lwall
31 # patch4: fixed cppstdin to run in the right directory
33 # Revision 4.0.1.1 91/06/07 11:20:06 lwall
34 # patch4: Makefile is no longer self-modifying code under makedepend
36 # Revision 4.0 91/03/20 01:27:04 lwall
41 export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh \$0; kill \$\$)
60 $spitshell >>makedepend <<'!NO!SUBS!'
65 $cat /dev/null >.deptmp
67 if test -f Makefile; then
72 defrule=`<$mf sed -n \
75 -e 's/^[^;]*;[ ]*//p' \
86 '') defrule='$(CC) -c $(CFLAGS)' ;;
89 make clist || ($echo "Searching for .c files..."; \
90 $echo *.c | $tr ' ' '\012' | $egrep -v '\*' >.clist)
91 for file in `$cat .clist`; do
92 # for file in `cat /dev/null`; do
94 *.c) filebase=`basename $file .c` ;;
95 *.y) filebase=`basename $file .y` ;;
98 */*) finc="-I`echo $file | sed 's#/[^/]*$##`" ;;
101 $echo "Finding dependencies for $filebase.o."
102 ( $echo "#line 1 \"$file\""; \
104 -e "/^${filebase}_init(/q" \
111 $cppstdin $finc -I/usr/local/include -I. $cppflags $cppminus <$file.c |
113 -e 's#\.[0-9][0-9]*\.c#'"$file.c#" \
114 -e 's/^[ ]*#[ ]*line/#/' \
115 -e '/^# *[0-9][0-9]* *[".\/]/!d' \
116 -e 's/^.*"\(.*\)".*$/'$filebase'.o: \1/' \
117 -e 's/^# *[0-9][0-9]* \(.*\)$/'$filebase'.o: \1/' \
119 -e 's|\.c\.c|.c|' | \
120 $uniq | $sort | $uniq >> .deptmp
123 $sed <$mf >$mf.new -e '1,/^# AUTOMATICALLY/!d'
125 make shlist || ($echo "Searching for .SH files..."; \
126 $echo *.SH | $tr ' ' '\012' | $egrep -v '\*' >.shlist)
127 if $test -s .deptmp; then
128 for file in `cat .shlist`; do
129 $echo `$expr X$file : 'X\(.*\).SH'`: $file config.sh \; \
130 /bin/sh $file >> .deptmp
132 $echo "Updating $mf..."
133 $echo "# If this runs make out of memory, delete /usr/include lines." \
135 $sed 's|^\(.*\.o:\) *\(.*/.*\.c\) *$|\1 \2; '"$defrule \2|" .deptmp \
138 make hlist || ($echo "Searching for .h files..."; \
139 $echo *.h | $tr ' ' '\012' | $egrep -v '\*' >.hlist)
140 $echo "You don't seem to have a proper C preprocessor. Using grep instead."
141 $egrep '^#include ' `cat .clist` `cat .hlist` >.deptmp
142 $echo "Updating $mf..."
145 -e 's|^\(.*\)/\(.*\)\.c|\2.o: \1/\2.c; '"$defrule \1/\2.c|p" \
148 -e 's|^\(.*\)\.c|\1.o: \1.c|p' >> $mf.new
149 <.hlist $sed -n 's|\(.*/\)\(.*\)|s= \2= \1\2=|p' >.hsed
150 <.deptmp $sed -n 's|c:#include "\(.*\)".*$|o: \1|p' | \
151 $sed 's|^[^;]*/||' | \
152 $sed -f .hsed >> $mf.new
153 <.deptmp $sed -n 's|c:#include <\(.*\)>.*$|o: /usr/include/\1|p' \
155 <.deptmp $sed -n 's|h:#include "\(.*\)".*$|h: \1|p' | \
156 $sed -f .hsed >> $mf.new
157 <.deptmp $sed -n 's|h:#include <\(.*\)>.*$|h: /usr/include/\1|p' \
159 for file in `$cat .shlist`; do
160 $echo `$expr X$file : 'X\(.*\).SH'`: $file config.sh \; \
161 /bin/sh $file >> $mf.new
168 $echo "# WARNING: Put nothing here or make depend will gobble it up!" >> $mf
169 $rm -f .deptmp `sed 's/\.c/.c.c/' .clist` .shlist .clist .hlist .hsed
172 $eunicefix makedepend
177 ln makedepend ../makedepend