Commit | Line | Data |
8d063cd8 |
1 | case $CONFIG in |
2 | '') |
a0d0e21e |
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=../../../..; |
8 | else |
9 | echo "Can't find config.sh."; exit 1 |
10 | fi |
11 | . $TOP/config.sh |
12 | ;; |
8d063cd8 |
13 | esac |
a0d0e21e |
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. |
8d063cd8 |
16 | case "$0" in |
17 | */*) cd `expr X$0 : 'X\(.*\)/'` ;; |
18 | esac |
19 | echo "Extracting makedepend (with variable substitutions)" |
7b0cd887 |
20 | rm -f makedepend |
75f92628 |
21 | $spitshell >makedepend <<!GROK!THIS! |
22 | $startsh |
a0d0e21e |
23 | # makedepend.SH |
8d063cd8 |
24 | # |
1aef975c |
25 | ## To use an alternate make, set \$altmake in config.sh. |
26 | MAKE=${altmake-make} |
27 | !GROK!THIS! |
28 | $spitshell >>makedepend <<'!NO!SUBS!' |
8d063cd8 |
29 | |
30 | export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh \$0; kill \$\$) |
31 | |
a0d0e21e |
32 | case $CONFIG in |
33 | '') |
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=../../../..; |
39 | else |
40 | echo "Can't find config.sh."; exit 1 |
41 | fi |
42 | . $TOP/config.sh |
43 | ;; |
44 | esac |
8d063cd8 |
45 | |
7b0cd887 |
46 | PATH="$PATH:." |
47 | export PATH |
48 | |
8d063cd8 |
49 | $cat /dev/null >.deptmp |
50 | $rm -f *.c.c c/*.c.c |
51 | if test -f Makefile; then |
352d5a3a |
52 | cp Makefile makefile |
8d063cd8 |
53 | fi |
352d5a3a |
54 | mf=makefile |
8d063cd8 |
55 | if test -f $mf; then |
56 | defrule=`<$mf sed -n \ |
57 | -e '/^\.c\.o:.*;/{' \ |
58 | -e 's/\$\*\.c//' \ |
59 | -e 's/^[^;]*;[ ]*//p' \ |
60 | -e q \ |
61 | -e '}' \ |
62 | -e '/^\.c\.o: *$/{' \ |
63 | -e N \ |
64 | -e 's/\$\*\.c//' \ |
65 | -e 's/^.*\n[ ]*//p' \ |
66 | -e q \ |
67 | -e '}'` |
68 | fi |
69 | case "$defrule" in |
70 | '') defrule='$(CC) -c $(CFLAGS)' ;; |
71 | esac |
72 | |
85e6fe83 |
73 | : Create files in UU directory to avoid problems with long filenames |
74 | : on systems with 14 character filename limits so file.c.c and file.c |
75 | : might be identical |
76 | $test -d UU || mkdir UU |
77 | |
1aef975c |
78 | $MAKE clist || ($echo "Searching for .c files..."; \ |
a687059c |
79 | $echo *.c | $tr ' ' '\012' | $egrep -v '\*' >.clist) |
8d063cd8 |
80 | for file in `$cat .clist`; do |
81 | # for file in `cat /dev/null`; do |
82 | case "$file" in |
83 | *.c) filebase=`basename $file .c` ;; |
7b0cd887 |
84 | *.y) filebase=`basename $file .y` ;; |
85 | esac |
86 | case "$file" in |
87 | */*) finc="-I`echo $file | sed 's#/[^/]*$##`" ;; |
88 | *) finc= ;; |
8d063cd8 |
89 | esac |
90 | $echo "Finding dependencies for $filebase.o." |
7b0cd887 |
91 | ( $echo "#line 1 \"$file\""; \ |
92 | $sed -n <$file \ |
8d063cd8 |
93 | -e "/^${filebase}_init(/q" \ |
2304df62 |
94 | -e '/^#line/d' \ |
8d063cd8 |
95 | -e '/^#/{' \ |
96 | -e 's|/\*.*$||' \ |
97 | -e 's|\\$||' \ |
98 | -e p \ |
85e6fe83 |
99 | -e '}' ) >UU/$file.c |
100 | $cppstdin $finc -I/usr/local/include -I. $cppflags $cppminus <UU/$file.c | |
8d063cd8 |
101 | $sed \ |
75f92628 |
102 | -e '/^#.*<stdin>/d' \ |
7b0cd887 |
103 | -e 's#\.[0-9][0-9]*\.c#'"$file.c#" \ |
55204971 |
104 | -e 's/^[ ]*#[ ]*line/#/' \ |
7b0cd887 |
105 | -e '/^# *[0-9][0-9]* *[".\/]/!d' \ |
8d063cd8 |
106 | -e 's/^.*"\(.*\)".*$/'$filebase'.o: \1/' \ |
7b0cd887 |
107 | -e 's/^# *[0-9][0-9]* \(.*\)$/'$filebase'.o: \1/' \ |
8d063cd8 |
108 | -e 's|: \./|: |' \ |
109 | -e 's|\.c\.c|.c|' | \ |
110 | $uniq | $sort | $uniq >> .deptmp |
111 | done |
112 | |
352d5a3a |
113 | $sed <$mf >$mf.new -e '1,/^# AUTOMATICALLY/!d' |
8d063cd8 |
114 | |
1aef975c |
115 | $MAKE shlist || ($echo "Searching for .SH files..."; \ |
a687059c |
116 | $echo *.SH | $tr ' ' '\012' | $egrep -v '\*' >.shlist) |
8d063cd8 |
117 | if $test -s .deptmp; then |
118 | for file in `cat .shlist`; do |
a0d0e21e |
119 | $echo `$expr X$file : 'X\(.*\).SH'`: $file $TOP/config.sh \; \ |
8d063cd8 |
120 | /bin/sh $file >> .deptmp |
121 | done |
352d5a3a |
122 | $echo "Updating $mf..." |
8d063cd8 |
123 | $echo "# If this runs make out of memory, delete /usr/include lines." \ |
352d5a3a |
124 | >> $mf.new |
8d063cd8 |
125 | $sed 's|^\(.*\.o:\) *\(.*/.*\.c\) *$|\1 \2; '"$defrule \2|" .deptmp \ |
352d5a3a |
126 | >>$mf.new |
8d063cd8 |
127 | else |
1aef975c |
128 | $MAKE hlist || ($echo "Searching for .h files..."; \ |
a687059c |
129 | $echo *.h | $tr ' ' '\012' | $egrep -v '\*' >.hlist) |
8d063cd8 |
130 | $echo "You don't seem to have a proper C preprocessor. Using grep instead." |
131 | $egrep '^#include ' `cat .clist` `cat .hlist` >.deptmp |
352d5a3a |
132 | $echo "Updating $mf..." |
8d063cd8 |
133 | <.clist $sed -n \ |
134 | -e '/\//{' \ |
135 | -e 's|^\(.*\)/\(.*\)\.c|\2.o: \1/\2.c; '"$defrule \1/\2.c|p" \ |
136 | -e d \ |
137 | -e '}' \ |
352d5a3a |
138 | -e 's|^\(.*\)\.c|\1.o: \1.c|p' >> $mf.new |
8d063cd8 |
139 | <.hlist $sed -n 's|\(.*/\)\(.*\)|s= \2= \1\2=|p' >.hsed |
140 | <.deptmp $sed -n 's|c:#include "\(.*\)".*$|o: \1|p' | \ |
141 | $sed 's|^[^;]*/||' | \ |
352d5a3a |
142 | $sed -f .hsed >> $mf.new |
8d063cd8 |
143 | <.deptmp $sed -n 's|h:#include "\(.*\)".*$|h: \1|p' | \ |
352d5a3a |
144 | $sed -f .hsed >> $mf.new |
8d063cd8 |
145 | for file in `$cat .shlist`; do |
a0d0e21e |
146 | $echo `$expr X$file : 'X\(.*\).SH'`: $file $TOP/config.sh \; \ |
352d5a3a |
147 | /bin/sh $file >> $mf.new |
8d063cd8 |
148 | done |
149 | fi |
352d5a3a |
150 | $rm -f $mf.old |
151 | $cp $mf $mf.old |
152 | $cp $mf.new $mf |
153 | $rm $mf.new |
154 | $echo "# WARNING: Put nothing here or make depend will gobble it up!" >> $mf |
85e6fe83 |
155 | $rm -rf .deptmp UU .shlist .clist .hlist .hsed |
8d063cd8 |
156 | |
157 | !NO!SUBS! |
158 | $eunicefix makedepend |
378cc40b |
159 | chmod +x makedepend |
8d063cd8 |
160 | case `pwd` in |
161 | *SH) |
162 | $rm -f ../makedepend |
163 | ln makedepend ../makedepend |
164 | ;; |
165 | esac |