-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakedepend.SH
103 lines (95 loc) · 2.68 KB
/
makedepend.SH
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
case $CONFIG in
'') . ./config.sh ;;
esac
echo "Extracting makedepend (with variable substitutions)"
if test "X$src" = "X." ; then
vincludes=''
else
vincludes="-I. -I$src"
fi
$spitshell >makedepend <<!GROK!THIS!
$startsh
# makedepend.SH
#
# This software is copyrighted as detailed in the LICENSE file.
#
export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh \$0; kill \$\$)
srcdir=$src
objdir=`pwd`
objext='.\\$\(o\)'
cc_cmd="$cppstdin -I\$objdir -I$usrinc $vincludes $tkinc $cppminus"
ignorefiles="$usrinc|typedef\.h|/lib/gcc-lib/"
test=${test-test}
sed=${sed-sed}
echo=${echo-echo}
cat=${cat-cat}
egrep=${egrep-egrep}
rm=${rm-rm}
mv=${mv-mv}
uniq=${uniq-uniq}
sort=${sort-sort}
basename=${basename-basename}
!GROK!THIS!
$spitshell >>makedepend <<'!NO!SUBS!'
deptmp=$objdir/.deptmp
$cat /dev/null >$deptmp
$echo "(Note: this is going to take a while.)"
cd $srcdir
for file in *.[cy]; do
case "$file" in
*.c) filebase=`$basename $file .c`;;
*.y) filebase=`$basename $file .y`;;
esac
$echo "Finding dependencies for $filebase.o."
$sed -n <$file \
-e '/^#/{' \
-e 's|/\*.*$||' \
-e 's/\\[ ]*$//' \
-e p \
-e '}' | $cc_cmd | $sed \
-e '/^# *line/s/line//' \
-e '/^# *[0-9]*[ ]*"/!d' \
-e 's/^.*"\(.*\)".*$/'$filebase$objext': \1/' \
-e 's|: \./|: |' \
-e "s|$objdir/||" \
-e 's/: *$/: '$file'/' \
-e 's/: .*\.c/: '$file'/' | \
$uniq | $sort | $uniq >>$deptmp
done
for file in *.SH; do
case "$file" in
Makefile.SH) ;;
newsnews.SH)
$echo `$basename $file .SH | $sed -e 's/_/./'`: $file \; /bin/sh "\$(srcdir)/$file" >>$deptmp
;;
environment.SH)
$echo HelpFiles/config/environment: $file config.sh makedir \; /bin/sh "\$(srcdir)/$file" >>$deptmp
;;
*)
$echo `$basename $file .SH | $sed -e 's/_/./'`: $file config.sh \; /bin/sh "\$(srcdir)/$file" >>$deptmp
;;
esac
done
cd $objdir
$sed <Makefile >Makefile.new -e '1,/^# AUTOMATICALLY/!d'
if $test -s $deptmp; then
$echo "Updating Makefile..."
$sed -e 's/\$[^(]/$$/g' $deptmp | $egrep -v "$ignorefiles" >dependencies
else
$echo "You don't seem to have a proper C preprocessor. Using egrep instead."
cd $srcdir
$egrep '^#include ' *.[cyh] ?.[cyh] >$deptmp
cd $objdir
$echo "Updating Makefile..."
<$deptmp $sed -n 's|c:#include "\(.*\)".*$$|o: \1|p' > dependencies
<$deptmp $sed -n 's|y:#include "\(.*\)".*$$|o: \1|p' >> dependencies
<$deptmp $sed -n 's|h:#include "\(.*\)".*$$|h: \1|p' >> dependencies
fi
$echo "# WARNING: Put nothing here or make depend will gobble it up!" >> dependencies
$mv Makefile Makefile.old
$mv Makefile.new Makefile
$cat dependencies >>Makefile
$rm $deptmp
!NO!SUBS!
$eunicefix makedepend
chmod 755 makedepend