4 if 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=../../..;
8 elif test -f ../../../../config.sh; then TOP=../../../..;
10 echo "Can't find config.sh."; exit 1
15 : This forces SH files to create target in same directory as SH file.
16 : This is so that make depend always knows where to find SH derivatives.
18 */*) cd `expr X$0 : 'X\(.*\)/'` ;;
23 echo "Extracting makedepend (with variable substitutions)"
25 $spitshell >makedepend <<!GROK!THIS!
29 ## To use an alternate make, set \$altmake in config.sh.
32 $spitshell >>makedepend <<'!NO!SUBS!'
34 export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh \$0; kill \$\$)
38 if test -f config.sh; then TOP=.;
39 elif test -f ../config.sh; then TOP=..;
40 elif test -f ../../config.sh; then TOP=../..;
41 elif test -f ../../../config.sh; then TOP=../../..;
42 elif test -f ../../../../config.sh; then TOP=../../../..;
44 echo "Can't find config.sh."; exit 1
50 # We need .. when we are in the x2p directory if we are using the
51 # cppstdin wrapper script.
52 # Put .. and . first so that we pick up the present cppstdin, not
53 # an older one lying about in /usr/local/bin.
57 $cat /dev/null >.deptmp
59 if test -f Makefile; then
61 cp Makefile $firstmakefile
65 defrule=`<$mf sed -n \
66 -e '/^\.c\(\$(OBJ_EXT)\|\.o\):.*;/{' \
68 -e 's/^[^;]*;[ ]*//p' \
71 -e '/^\.c\(\$(OBJ_EXT)\|\.o\): *$/{' \
79 '') defrule='$(CC) -c $(CFLAGS)' ;;
82 : Create files in UU directory to avoid problems with long filenames
83 : on systems with 14 character filename limits so file.c.c and file.c
85 $test -d UU || mkdir UU
87 $MAKE clist || ($echo "Searching for .c files..."; \
88 $echo *.c | $tr ' ' '\012' | $egrep -v '\*' >.clist)
89 for file in `$cat .clist`; do
90 # for file in `cat /dev/null`; do
92 *.c) filebase=`basename $file .c` ;;
93 *.y) filebase=`basename $file .y` ;;
96 */*) finc="-I`echo $file | sed 's#/[^/]*$##`" ;;
99 $echo "Finding dependencies for $filebase$obj_ext."
100 ( $echo "#line 1 \"$file\""; \
102 -e "/^${filebase}_init(/q" \
109 $cppstdin $finc -I/usr/local/include -I. $cppflags $cppminus <UU/$file.c |
111 -e '/^#.*<stdin>/d' \
112 -e 's#\.[0-9][0-9]*\.c#'"$file.c#" \
113 -e 's/^[ ]*#[ ]*line/#/' \
114 -e '/^# *[0-9][0-9]* *[".\/]/!d' \
115 -e 's/^.*"\(.*\)".*$/'$filebase'\$(OBJ_EXT): \1/' \
116 -e 's/^# *[0-9][0-9]* \(.*\)$/'$filebase'\$(OBJ_EXT): \1/' \
118 -e 's|\.c\.c|.c|' | \
119 $uniq | $sort | $uniq >> .deptmp
122 $sed <$mf >$mf.new -e '1,/^# AUTOMATICALLY/!d'
124 $MAKE shlist || ($echo "Searching for .SH files..."; \
125 $echo *.SH | $tr ' ' '\012' | $egrep -v '\*' >.shlist)
127 # Now extract the dependency on makedepend.SH
128 # (it should reside in the main Makefile):
129 mv .shlist .shlist.old
130 $egrep -v '^makedepend\.SH' <.shlist.old >.shlist
133 if $test -s .deptmp; then
134 for file in `cat .shlist`; do
135 $echo `$expr X$file : 'X\(.*\).SH'`: $file $TOP/config.sh \; \
136 $bin_sh $file >> .deptmp
138 $echo "Updating $mf..."
139 $echo "# If this runs make out of memory, delete /usr/include lines." \
141 $sed 's|^\(.*\(\$(OBJ_EXT)\|\.o\):\) *\(.*/.*\.c\) *$|\1 \3; '"$defrule \2|" .deptmp \
144 $MAKE hlist || ($echo "Searching for .h files..."; \
145 $echo *.h | $tr ' ' '\012' | $egrep -v '\*' >.hlist)
146 $echo "You don't seem to have a proper C preprocessor. Using grep instead."
147 $egrep '^#include ' `cat .clist` `cat .hlist` >.deptmp
148 $echo "Updating $mf..."
151 -e 's|^\(.*\)/\(.*\)\.c|\2\$(OBJ_EXT): \1/\2.c; '"$defrule \1/\2.c|p" \
154 -e 's|^\(.*\)\.c|\1\$(OBJ_EXT): \1.c|p' >> $mf.new
155 <.hlist $sed -n 's|\(.*/\)\(.*\)|s= \2= \1\2=|p' >.hsed
156 <.deptmp $sed -n 's|c:#include "\(.*\)".*$|o: \1|p' | \
157 $sed 's|^[^;]*/||' | \
158 $sed -f .hsed >> $mf.new
159 <.deptmp $sed -n 's|h:#include "\(.*\)".*$|h: \1|p' | \
160 $sed -f .hsed >> $mf.new
161 for file in `$cat .shlist`; do
162 $echo `$expr X$file : 'X\(.*\).SH'`: $file $TOP/config.sh \; \
163 $bin_sh $file >> $mf.new
171 $echo "# WARNING: Put nothing here or make depend will gobble it up!" >> $mf
172 $rm -rf .deptmp UU .shlist .clist .hlist .hsed
175 $eunicefix makedepend
180 ln makedepend ../makedepend