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