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 # $RCSfile: makedepend.SH,v $$Revision: 4.0.1.3 $$Date: 91/11/05 17:56:33 $
20 # $Log: makedepend.SH,v $
21 # Revision 4.0.1.3 91/11/05 17:56:33 lwall
22 # patch11: various portability fixes
24 # Revision 4.0.1.2 91/06/07 15:40:06 lwall
25 # patch4: fixed cppstdin to run in the right directory
27 # Revision 4.0.1.1 91/06/07 11:20:06 lwall
28 # patch4: Makefile is no longer self-modifying code under makedepend
30 # Revision 4.0 91/03/20 01:27:04 lwall
35 export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh \$0; kill \$\$)
54 $spitshell >>makedepend <<'!NO!SUBS!'
56 $cat /dev/null >.deptmp
58 if test -f Makefile; then
63 defrule=`<$mf sed -n \
66 -e 's/^[^;]*;[ ]*//p' \
77 '') defrule='$(CC) -c $(CFLAGS)' ;;
80 make clist || ($echo "Searching for .c files..."; \
81 $echo *.c | $tr ' ' '\012' | $egrep -v '\*' >.clist)
82 for file in `$cat .clist`; do
83 # for file in `cat /dev/null`; do
85 *.c) filebase=`basename $file .c` ;;
86 *.y) filebase=`basename $file .c` ;;
88 $echo "Finding dependencies for $filebase.o."
89 $sed -n <$file >$file.c \
90 -e "/^${filebase}_init(/q" \
96 $cppstdin -I/usr/local/include -I. $cppflags $cppminus <$file.c | sed -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/' \
102 -e 's|\.c\.c|.c|' | \
103 $uniq | $sort | $uniq >> .deptmp
106 $sed <$mf >$mf.new -e '1,/^# AUTOMATICALLY/!d'
108 make shlist || ($echo "Searching for .SH files..."; \
109 $echo *.SH | $tr ' ' '\012' | $egrep -v '\*' >.shlist)
110 if $test -s .deptmp; then
111 for file in `cat .shlist`; do
112 $echo `$expr X$file : 'X\(.*\).SH'`: $file config.sh \; \
113 /bin/sh $file >> .deptmp
115 $echo "Updating $mf..."
116 $echo "# If this runs make out of memory, delete /usr/include lines." \
118 $sed 's|^\(.*\.o:\) *\(.*/.*\.c\) *$|\1 \2; '"$defrule \2|" .deptmp \
121 make hlist || ($echo "Searching for .h files..."; \
122 $echo *.h | $tr ' ' '\012' | $egrep -v '\*' >.hlist)
123 $echo "You don't seem to have a proper C preprocessor. Using grep instead."
124 $egrep '^#include ' `cat .clist` `cat .hlist` >.deptmp
125 $echo "Updating $mf..."
128 -e 's|^\(.*\)/\(.*\)\.c|\2.o: \1/\2.c; '"$defrule \1/\2.c|p" \
131 -e 's|^\(.*\)\.c|\1.o: \1.c|p' >> $mf.new
132 <.hlist $sed -n 's|\(.*/\)\(.*\)|s= \2= \1\2=|p' >.hsed
133 <.deptmp $sed -n 's|c:#include "\(.*\)".*$|o: \1|p' | \
134 $sed 's|^[^;]*/||' | \
135 $sed -f .hsed >> $mf.new
136 <.deptmp $sed -n 's|c:#include <\(.*\)>.*$|o: /usr/include/\1|p' \
138 <.deptmp $sed -n 's|h:#include "\(.*\)".*$|h: \1|p' | \
139 $sed -f .hsed >> $mf.new
140 <.deptmp $sed -n 's|h:#include <\(.*\)>.*$|h: /usr/include/\1|p' \
142 for file in `$cat .shlist`; do
143 $echo `$expr X$file : 'X\(.*\).SH'`: $file config.sh \; \
144 /bin/sh $file >> $mf.new
151 $echo "# WARNING: Put nothing here or make depend will gobble it up!" >> $mf
152 $rm -f .deptmp `sed 's/\.c/.c.c/' .clist` .shlist .clist .hlist .hsed
155 $eunicefix makedepend
160 ln makedepend ../makedepend