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 <<!GROK!THIS!
25 ## To use an alternate make, set \$altmake in config.sh.
28 $spitshell >>makedepend <<'!NO!SUBS!'
30 export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh \$0; kill \$\$)
34 if test -f config.sh; then TOP=.;
35 elif test -f ../config.sh; then TOP=..;
36 elif test -f ../../config.sh; then TOP=../..;
37 elif test -f ../../../config.sh; then TOP=../../..;
38 elif test -f ../../../../config.sh; then TOP=../../../..;
40 echo "Can't find config.sh."; exit 1
46 # We need .. when we are in the x2p directory if we are using the
47 # cppstdin wrapper script.
51 $cat /dev/null >.deptmp
53 if test -f Makefile; then
58 defrule=`<$mf sed -n \
61 -e 's/^[^;]*;[ ]*//p' \
72 '') defrule='$(CC) -c $(CFLAGS)' ;;
75 : Create files in UU directory to avoid problems with long filenames
76 : on systems with 14 character filename limits so file.c.c and file.c
78 $test -d UU || mkdir UU
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 .y` ;;
89 */*) finc="-I`echo $file | sed 's#/[^/]*$##`" ;;
92 $echo "Finding dependencies for $filebase.o."
93 ( $echo "#line 1 \"$file\""; \
95 -e "/^${filebase}_init(/q" \
102 $cppstdin $finc -I/usr/local/include -I. $cppflags $cppminus <UU/$file.c |
104 -e '/^#.*<stdin>/d' \
105 -e 's#\.[0-9][0-9]*\.c#'"$file.c#" \
106 -e 's/^[ ]*#[ ]*line/#/' \
107 -e '/^# *[0-9][0-9]* *[".\/]/!d' \
108 -e 's/^.*"\(.*\)".*$/'$filebase'.o: \1/' \
109 -e 's/^# *[0-9][0-9]* \(.*\)$/'$filebase'.o: \1/' \
111 -e 's|\.c\.c|.c|' | \
112 $uniq | $sort | $uniq >> .deptmp
115 $sed <$mf >$mf.new -e '1,/^# AUTOMATICALLY/!d'
117 $MAKE shlist || ($echo "Searching for .SH files..."; \
118 $echo *.SH | $tr ' ' '\012' | $egrep -v '\*' >.shlist)
119 if $test -s .deptmp; then
120 for file in `cat .shlist`; do
121 $echo `$expr X$file : 'X\(.*\).SH'`: $file $TOP/config.sh \; \
122 /bin/sh $file >> .deptmp
124 $echo "Updating $mf..."
125 $echo "# If this runs make out of memory, delete /usr/include lines." \
127 $sed 's|^\(.*\.o:\) *\(.*/.*\.c\) *$|\1 \2; '"$defrule \2|" .deptmp \
130 $MAKE hlist || ($echo "Searching for .h files..."; \
131 $echo *.h | $tr ' ' '\012' | $egrep -v '\*' >.hlist)
132 $echo "You don't seem to have a proper C preprocessor. Using grep instead."
133 $egrep '^#include ' `cat .clist` `cat .hlist` >.deptmp
134 $echo "Updating $mf..."
137 -e 's|^\(.*\)/\(.*\)\.c|\2.o: \1/\2.c; '"$defrule \1/\2.c|p" \
140 -e 's|^\(.*\)\.c|\1.o: \1.c|p' >> $mf.new
141 <.hlist $sed -n 's|\(.*/\)\(.*\)|s= \2= \1\2=|p' >.hsed
142 <.deptmp $sed -n 's|c:#include "\(.*\)".*$|o: \1|p' | \
143 $sed 's|^[^;]*/||' | \
144 $sed -f .hsed >> $mf.new
145 <.deptmp $sed -n 's|h:#include "\(.*\)".*$|h: \1|p' | \
146 $sed -f .hsed >> $mf.new
147 for file in `$cat .shlist`; do
148 $echo `$expr X$file : 'X\(.*\).SH'`: $file $TOP/config.sh \; \
149 /bin/sh $file >> $mf.new
156 $echo "# WARNING: Put nothing here or make depend will gobble it up!" >> $mf
157 $rm -rf .deptmp UU .shlist .clist .hlist .hsed
160 $eunicefix makedepend
165 ln makedepend ../makedepend