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)"
16 $spitshell >makedepend <<!GROK!THIS!
18 # $Header: makedepend.SH,v 3.0 89/10/18 15:20:19 lwall Locked $
20 # $Log: makedepend.SH,v $
21 # Revision 3.0 89/10/18 15:20:19 lwall
25 export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh \$0; kill \$\$)
28 ccflags='$ccflags $sockethdr'
43 $spitshell >>makedepend <<'!NO!SUBS!'
45 : the following weeds options from ccflags that are of no interest to cpp
52 -D*|-I*) ccflags="$ccflags $flag";;
58 $cat /dev/null >.deptmp
60 if test -f Makefile; then
66 defrule=`<$mf sed -n \
69 -e 's/^[^;]*;[ ]*//p' \
80 '') defrule='$(CC) -c $(CFLAGS)' ;;
83 make clist || ($echo "Searching for .c files..."; \
84 $echo *.c | $tr ' ' '\012' | $egrep -v '\*' >.clist)
85 for file in `$cat .clist`; do
86 # for file in `cat /dev/null`; do
88 *.c) filebase=`basename $file .c` ;;
89 *.y) filebase=`basename $file .c` ;;
91 $echo "Finding dependencies for $filebase.o."
92 $sed -n <$file >$file.c \
93 -e "/^${filebase}_init(/q" \
99 $cpp -I/usr/local/include -I. $ccflags $file.c | \
102 -e 's/^.*"\(.*\)".*$/'$filebase'.o: \1/' \
104 -e 's|\.c\.c|.c|' | \
105 $uniq | $sort | $uniq >> .deptmp
108 $sed <Makefile >Makefile.new -e '1,/^# AUTOMATICALLY/!d'
110 make shlist || ($echo "Searching for .SH files..."; \
111 $echo *.SH | $tr ' ' '\012' | $egrep -v '\*' >.shlist)
112 if $test -s .deptmp; then
113 for file in `cat .shlist`; do
114 $echo `$expr X$file : 'X\(.*\).SH`: $file config.sh \; \
115 /bin/sh $file >> .deptmp
117 $echo "Updating Makefile..."
118 $echo "# If this runs make out of memory, delete /usr/include lines." \
120 $sed 's|^\(.*\.o:\) *\(.*/.*\.c\) *$|\1 \2; '"$defrule \2|" .deptmp \
123 make hlist || ($echo "Searching for .h files..."; \
124 $echo *.h | $tr ' ' '\012' | $egrep -v '\*' >.hlist)
125 $echo "You don't seem to have a proper C preprocessor. Using grep instead."
126 $egrep '^#include ' `cat .clist` `cat .hlist` >.deptmp
127 $echo "Updating Makefile..."
130 -e 's|^\(.*\)/\(.*\)\.c|\2.o: \1/\2.c; '"$defrule \1/\2.c|p" \
133 -e 's|^\(.*\)\.c|\1.o: \1.c|p' >> Makefile.new
134 <.hlist $sed -n 's|\(.*/\)\(.*\)|s= \2= \1\2=|p' >.hsed
135 <.deptmp $sed -n 's|c:#include "\(.*\)".*$|o: \1|p' | \
136 $sed 's|^[^;]*/||' | \
137 $sed -f .hsed >> Makefile.new
138 <.deptmp $sed -n 's|c:#include <\(.*\)>.*$|o: /usr/include/\1|p' \
140 <.deptmp $sed -n 's|h:#include "\(.*\)".*$|h: \1|p' | \
141 $sed -f .hsed >> Makefile.new
142 <.deptmp $sed -n 's|h:#include <\(.*\)>.*$|h: /usr/include/\1|p' \
144 for file in `$cat .shlist`; do
145 $echo `$expr X$file : 'X\(.*\).SH`: $file config.sh \; \
146 /bin/sh $file >> Makefile.new
150 $cp Makefile Makefile.old
151 $cp Makefile.new Makefile
153 $echo "# WARNING: Put nothing here or make depend will gobble it up!" >> Makefile
154 $rm -f .deptmp `sed 's/\.c/.c.c/' .clist` .shlist .clist .hlist .hsed
157 $eunicefix makedepend
162 ln makedepend ../makedepend