0
|
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)
|
|
8 fi
|
|
9 . ./config.sh
|
|
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
|
|
18 # $Header: makedepend.SH,v 1.0.1.4 88/02/25 11:41:46 root Exp $
|
|
19 #
|
|
20 # $Log: makedepend.SH,v $
|
|
21 # Revision 1.0.1.4 88/02/25 11:41:46 root
|
|
22 # patch23: changed cpp to cppstdin
|
|
23 #
|
|
24 # Revision 1.0.1.3 88/02/12 10:25:22 root
|
|
25 # patch22: fix for systems without . in path
|
|
26 #
|
|
27 # Revision 1.0.1.2 88/02/04 10:26:06 root
|
|
28 # patch17: changed chmod 755 to +x.
|
|
29 #
|
|
30 # Revision 1.0.1.1 88/02/02 11:24:05 root
|
|
31 # patch13: removed spurious -I./h.
|
|
32 #
|
|
33 # Revision 1.0 87/12/18 17:54:32 root
|
|
34 # Initial revision
|
|
35 #
|
|
36 #
|
|
37
|
|
38 export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh \$0; kill \$\$)
|
|
39
|
|
40 cat='$cat'
|
|
41 cp='$cp'
|
|
42 cpp='$cppstdin'
|
|
43 echo='$echo'
|
|
44 egrep='$egrep'
|
|
45 expr='$expr'
|
|
46 mv='$mv'
|
|
47 rm='$rm'
|
|
48 sed='$sed'
|
|
49 sort='$sort'
|
|
50 test='$test'
|
|
51 tr='$tr'
|
|
52 uniq='$uniq'
|
|
53 !GROK!THIS!
|
|
54
|
|
55 $spitshell >>makedepend <<'!NO!SUBS!'
|
|
56
|
|
57 $cat /dev/null >.deptmp
|
|
58 $rm -f *.c.c c/*.c.c
|
|
59 if test -f Makefile; then
|
|
60 mf=Makefile
|
|
61 else
|
|
62 mf=makefile
|
|
63 fi
|
|
64 if test -f $mf; then
|
|
65 defrule=`<$mf sed -n \
|
|
66 -e '/^\.c\.o:.*;/{' \
|
|
67 -e 's/\$\*\.c//' \
|
|
68 -e 's/^[^;]*;[ ]*//p' \
|
|
69 -e q \
|
|
70 -e '}' \
|
|
71 -e '/^\.c\.o: *$/{' \
|
|
72 -e N \
|
|
73 -e 's/\$\*\.c//' \
|
|
74 -e 's/^.*\n[ ]*//p' \
|
|
75 -e q \
|
|
76 -e '}'`
|
|
77 fi
|
|
78 case "$defrule" in
|
|
79 '') defrule='$(CC) -c $(CFLAGS)' ;;
|
|
80 esac
|
|
81
|
|
82 make clist || ($echo "Searching for .c files..."; \
|
|
83 $echo *.c */*.c | $tr ' ' '\012' | $egrep -v '\*' >.clist)
|
|
84 for file in `$cat .clist`; do
|
|
85 # for file in `cat /dev/null`; do
|
|
86 case "$file" in
|
|
87 *.c) filebase=`basename $file .c` ;;
|
|
88 *.y) filebase=`basename $file .c` ;;
|
|
89 esac
|
|
90 $echo "Finding dependencies for $filebase.o."
|
|
91 $sed -n <$file >$file.c \
|
|
92 -e "/^${filebase}_init(/q" \
|
|
93 -e '/^#/{' \
|
|
94 -e 's|/\*.*$||' \
|
|
95 -e 's|\\$||' \
|
|
96 -e p \
|
|
97 -e '}'
|
|
98 $cpp -I/usr/local/include -I. $file.c | \
|
|
99 $sed \
|
|
100 -e '/^#.*<stdin>/d' \
|
|
101 -e '/^#.*<builtin>/d' \
|
|
102 -e '/^#.*<built-in>/d' \
|
|
103 -e '/^#.*<command line>/d' \
|
|
104 -e '/^#.*<command-line>/d' \
|
|
105 -e '/^# *[0-9]/!d' \
|
|
106 -e 's/^.*"\(.*\)".*$/'$filebase'.o: \1/' \
|
|
107 -e 's|: \./|: |' \
|
|
108 -e 's|\.c\.c|.c|' | \
|
|
109 $uniq | $sort | $uniq >> .deptmp
|
|
110 done
|
|
111
|
|
112 $sed <Makefile >Makefile.new -e '1,/^# AUTOMATICALLY/!d'
|
|
113
|
|
114 make shlist || ($echo "Searching for .SH files..."; \
|
|
115 $echo *.SH */*.SH | $tr ' ' '\012' | $egrep -v '\*' >.shlist)
|
|
116 if $test -s .deptmp; then
|
|
117 for file in `cat .shlist`; do
|
|
118 $echo `$expr X$file : 'X\(.*\).SH'`: $file config.sh \; \
|
|
119 /bin/sh $file >> .deptmp
|
|
120 done
|
|
121 $echo "Updating Makefile..."
|
|
122 $echo "# If this runs make out of memory, delete /usr/include lines." \
|
|
123 >> Makefile.new
|
|
124 $sed 's|^\(.*\.o:\) *\(.*/.*\.c\) *$|\1 \2; '"$defrule \2|" .deptmp \
|
|
125 >>Makefile.new
|
|
126 else
|
|
127 make hlist || ($echo "Searching for .h files..."; \
|
|
128 $echo *.h */*.h | $tr ' ' '\012' | $egrep -v '\*' >.hlist)
|
|
129 $echo "You don't seem to have a proper C preprocessor. Using grep instead."
|
|
130 $egrep '^#include ' `cat .clist` `cat .hlist` >.deptmp
|
|
131 $echo "Updating Makefile..."
|
|
132 <.clist $sed -n \
|
|
133 -e '/\//{' \
|
|
134 -e 's|^\(.*\)/\(.*\)\.c|\2.o: \1/\2.c; '"$defrule \1/\2.c|p" \
|
|
135 -e d \
|
|
136 -e '}' \
|
|
137 -e 's|^\(.*\)\.c|\1.o: \1.c|p' >> Makefile.new
|
|
138 <.hlist $sed -n 's|\(.*/\)\(.*\)|s= \2= \1\2=|p' >.hsed
|
|
139 <.deptmp $sed -n 's|c:#include "\(.*\)".*$|o: \1|p' | \
|
|
140 $sed 's|^[^;]*/||' | \
|
|
141 $sed -f .hsed >> Makefile.new
|
|
142 <.deptmp $sed -n 's|c:#include <\(.*\)>.*$|o: /usr/include/\1|p' \
|
|
143 >> Makefile.new
|
|
144 <.deptmp $sed -n 's|h:#include "\(.*\)".*$|h: \1|p' | \
|
|
145 $sed -f .hsed >> Makefile.new
|
|
146 <.deptmp $sed -n 's|h:#include <\(.*\)>.*$|h: /usr/include/\1|p' \
|
|
147 >> Makefile.new
|
|
148 for file in `$cat .shlist`; do
|
|
149 $echo `$expr X$file : 'X\(.*\).SH'`: $file config.sh \; \
|
|
150 /bin/sh $file >> Makefile.new
|
|
151 done
|
|
152 fi
|
|
153 $rm -f Makefile.old
|
|
154 $cp Makefile Makefile.old
|
|
155 $cp Makefile.new Makefile
|
|
156 $rm Makefile.new
|
|
157 $echo "# WARNING: Put nothing here or make depend will gobble it up!" >> Makefile
|
|
158 $rm -f .deptmp `sed 's/\.c/.c.c/' .clist` .shlist .clist .hlist .hsed
|
|
159
|
|
160 !NO!SUBS!
|
|
161 $eunicefix makedepend
|
|
162 chmod +x makedepend
|
|
163 case `pwd` in
|
|
164 *SH)
|
|
165 $rm -f ../makedepend
|
|
166 ln makedepend ../makedepend
|
|
167 ;;
|
|
168 esac
|