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)" |
16 | $spitshell >makedepend <<!GROK!THIS! |
17 | $startsh |
352d5a3a |
18 | # $RCSfile: makedepend.SH,v $$Revision: 4.0.1.2 $$Date: 91/06/07 15:40:06 $ |
8d063cd8 |
19 | # |
20 | # $Log: makedepend.SH,v $ |
352d5a3a |
21 | # Revision 4.0.1.2 91/06/07 15:40:06 lwall |
22 | # patch4: fixed cppstdin to run in the right directory |
23 | # |
24 | # Revision 4.0.1.1 91/06/07 11:20:06 lwall |
25 | # patch4: Makefile is no longer self-modifying code under makedepend |
26 | # |
fe14fcc3 |
27 | # Revision 4.0 91/03/20 01:27:04 lwall |
28 | # 4.0 baseline. |
bf38876a |
29 | # |
8d063cd8 |
30 | # |
31 | |
32 | export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh \$0; kill \$\$) |
33 | |
34 | cat='$cat' |
bf38876a |
35 | cppflags='$cppflags' |
8d063cd8 |
36 | cp='$cp' |
352d5a3a |
37 | cppstdin='$cppstdin' |
38 | cppminus='$cppminus' |
8d063cd8 |
39 | echo='$echo' |
40 | egrep='$egrep' |
41 | expr='$expr' |
42 | mv='$mv' |
43 | rm='$rm' |
44 | sed='$sed' |
45 | sort='$sort' |
46 | test='$test' |
47 | tr='$tr' |
48 | uniq='$uniq' |
49 | !GROK!THIS! |
50 | |
51 | $spitshell >>makedepend <<'!NO!SUBS!' |
52 | |
53 | $cat /dev/null >.deptmp |
54 | $rm -f *.c.c c/*.c.c |
55 | if test -f Makefile; then |
352d5a3a |
56 | cp Makefile makefile |
8d063cd8 |
57 | fi |
352d5a3a |
58 | mf=makefile |
8d063cd8 |
59 | if test -f $mf; then |
60 | defrule=`<$mf sed -n \ |
61 | -e '/^\.c\.o:.*;/{' \ |
62 | -e 's/\$\*\.c//' \ |
63 | -e 's/^[^;]*;[ ]*//p' \ |
64 | -e q \ |
65 | -e '}' \ |
66 | -e '/^\.c\.o: *$/{' \ |
67 | -e N \ |
68 | -e 's/\$\*\.c//' \ |
69 | -e 's/^.*\n[ ]*//p' \ |
70 | -e q \ |
71 | -e '}'` |
72 | fi |
73 | case "$defrule" in |
74 | '') defrule='$(CC) -c $(CFLAGS)' ;; |
75 | esac |
76 | |
77 | make clist || ($echo "Searching for .c files..."; \ |
a687059c |
78 | $echo *.c | $tr ' ' '\012' | $egrep -v '\*' >.clist) |
8d063cd8 |
79 | for file in `$cat .clist`; do |
80 | # for file in `cat /dev/null`; do |
81 | case "$file" in |
82 | *.c) filebase=`basename $file .c` ;; |
83 | *.y) filebase=`basename $file .c` ;; |
84 | esac |
85 | $echo "Finding dependencies for $filebase.o." |
86 | $sed -n <$file >$file.c \ |
87 | -e "/^${filebase}_init(/q" \ |
88 | -e '/^#/{' \ |
89 | -e 's|/\*.*$||' \ |
90 | -e 's|\\$||' \ |
91 | -e p \ |
92 | -e '}' |
352d5a3a |
93 | $cppstdin -I/usr/local/include -I. $cppflags $cppminus <$file.c | sed -e 's#\.[0-9][0-9]*\.c#'"$file.c#" | \ |
8d063cd8 |
94 | $sed \ |
95 | -e '/^# *[0-9]/!d' \ |
96 | -e 's/^.*"\(.*\)".*$/'$filebase'.o: \1/' \ |
97 | -e 's|: \./|: |' \ |
98 | -e 's|\.c\.c|.c|' | \ |
99 | $uniq | $sort | $uniq >> .deptmp |
100 | done |
101 | |
352d5a3a |
102 | $sed <$mf >$mf.new -e '1,/^# AUTOMATICALLY/!d' |
8d063cd8 |
103 | |
104 | make shlist || ($echo "Searching for .SH files..."; \ |
a687059c |
105 | $echo *.SH | $tr ' ' '\012' | $egrep -v '\*' >.shlist) |
8d063cd8 |
106 | if $test -s .deptmp; then |
107 | for file in `cat .shlist`; do |
352d5a3a |
108 | $echo `$expr X$file : 'X\(.*\).SH'`: $file config.sh \; \ |
8d063cd8 |
109 | /bin/sh $file >> .deptmp |
110 | done |
352d5a3a |
111 | $echo "Updating $mf..." |
8d063cd8 |
112 | $echo "# If this runs make out of memory, delete /usr/include lines." \ |
352d5a3a |
113 | >> $mf.new |
8d063cd8 |
114 | $sed 's|^\(.*\.o:\) *\(.*/.*\.c\) *$|\1 \2; '"$defrule \2|" .deptmp \ |
352d5a3a |
115 | >>$mf.new |
8d063cd8 |
116 | else |
117 | make hlist || ($echo "Searching for .h files..."; \ |
a687059c |
118 | $echo *.h | $tr ' ' '\012' | $egrep -v '\*' >.hlist) |
8d063cd8 |
119 | $echo "You don't seem to have a proper C preprocessor. Using grep instead." |
120 | $egrep '^#include ' `cat .clist` `cat .hlist` >.deptmp |
352d5a3a |
121 | $echo "Updating $mf..." |
8d063cd8 |
122 | <.clist $sed -n \ |
123 | -e '/\//{' \ |
124 | -e 's|^\(.*\)/\(.*\)\.c|\2.o: \1/\2.c; '"$defrule \1/\2.c|p" \ |
125 | -e d \ |
126 | -e '}' \ |
352d5a3a |
127 | -e 's|^\(.*\)\.c|\1.o: \1.c|p' >> $mf.new |
8d063cd8 |
128 | <.hlist $sed -n 's|\(.*/\)\(.*\)|s= \2= \1\2=|p' >.hsed |
129 | <.deptmp $sed -n 's|c:#include "\(.*\)".*$|o: \1|p' | \ |
130 | $sed 's|^[^;]*/||' | \ |
352d5a3a |
131 | $sed -f .hsed >> $mf.new |
8d063cd8 |
132 | <.deptmp $sed -n 's|c:#include <\(.*\)>.*$|o: /usr/include/\1|p' \ |
352d5a3a |
133 | >> $mf.new |
8d063cd8 |
134 | <.deptmp $sed -n 's|h:#include "\(.*\)".*$|h: \1|p' | \ |
352d5a3a |
135 | $sed -f .hsed >> $mf.new |
8d063cd8 |
136 | <.deptmp $sed -n 's|h:#include <\(.*\)>.*$|h: /usr/include/\1|p' \ |
352d5a3a |
137 | >> $mf.new |
8d063cd8 |
138 | for file in `$cat .shlist`; do |
352d5a3a |
139 | $echo `$expr X$file : 'X\(.*\).SH'`: $file config.sh \; \ |
140 | /bin/sh $file >> $mf.new |
8d063cd8 |
141 | done |
142 | fi |
352d5a3a |
143 | $rm -f $mf.old |
144 | $cp $mf $mf.old |
145 | $cp $mf.new $mf |
146 | $rm $mf.new |
147 | $echo "# WARNING: Put nothing here or make depend will gobble it up!" >> $mf |
8d063cd8 |
148 | $rm -f .deptmp `sed 's/\.c/.c.c/' .clist` .shlist .clist .hlist .hsed |
149 | |
150 | !NO!SUBS! |
151 | $eunicefix makedepend |
378cc40b |
152 | chmod +x makedepend |
8d063cd8 |
153 | case `pwd` in |
154 | *SH) |
155 | $rm -f ../makedepend |
156 | ln makedepend ../makedepend |
157 | ;; |
158 | esac |