blob: 4578b710c0f2670b41a50b5ec98eb40dd2145c43 (
plain)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
XCOMM!/bin/sh
XCOMM
XCOMM makedepend which uses 'gcc -M'
XCOMM
XCOMM $XFree86: xc/config/util/gccmdep.cpp,v 3.10 2002/11/25 14:04:48 eich Exp $
XCOMM
XCOMM Based on mdepend.cpp and code supplied by Hongjiu Lu <hjl@nynexst.com>
XCOMM
TMP=${TMPDIR-/tmp}/mdep$$
CC=CCCMD
RM=RMCMD
LN=LNCMD
MV=MVCMD
XCOMM Security: if $tmp exists exit immediately
rm -f ${TMP}
if [ -e ${TMP} ] ; then
echo "$0: ${TMP} exists already, exit." 1>&2
exit 1;
fi
if [ -n "`type -p mktemp`" ] ; then
TMP="`mktemp ${TMP}.XXXXXX`" || exit 1
fi
trap "$RM ${TMP}*; exit 1" 1 2 15
trap "$RM ${TMP}*; exit 0" 1 2 13
files=
makefile=
endmarker=
magic_string='# DO NOT DELETE'
append=n
args=
while [ $# != 0 ]; do
if [ "$endmarker"x != x -a "$endmarker" = "$1" ]; then
endmarker=
else
case "$1" in
-D*|-I*|-U*)
args="$args '$1'"
;;
-g*|-O*)
;;
*)
if [ "$endmarker"x = x ]; then
case $1 in
XCOMM ignore these flags
-w|-o|-cc)
shift
;;
-v)
;;
-s)
magic_string="$2"
shift
;;
-f*)
if [ "$1" = "-f-" ]; then
makefile="-"
elif [ "$1" = "-f" ]; then
makefile="$2"
shift
else
echo "$1" | sed 's/^\-f//' >${TMP}arg
makefile="`cat ${TMP}arg`"
rm -f ${TMP}arg
fi
;;
--*)
endmarker=`echo $1 | sed 's/^\-\-//'`
if [ "$endmarker"x = x ]; then
endmarker="--"
fi
;;
-a)
append=y
;;
-*)
echo "Unknown option '$1' ignored" 1>&2
;;
*)
files="$files $1"
;;
esac
fi
;;
esac
fi
shift
done
if [ x"$files" = x ]; then
XCOMM Nothing to do
exit 0
fi
case "$makefile" in
'')
if [ -r makefile ]; then
makefile=makefile
elif [ -r Makefile ]; then
makefile=Makefile
else
echo 'no makefile or Makefile found' 1>&2
exit 1
fi
;;
esac
if [ X"$makefile" != X- ]; then
if [ x"$append" = xn ]; then
sed -e "/^$magic_string/,\$d" < $makefile > $TMP
echo "$magic_string" >> $TMP
else
cp $makefile $TMP
fi
fi
CMD="$CC -M $args $files"
if [ X"$makefile" != X- ]; then
CMD="$CMD >> $TMP"
fi
eval $CMD
if [ X"$makefile" != X- ]; then
$RM ${makefile}.bak
$MV $makefile ${makefile}.bak
$MV $TMP $makefile
fi
$RM ${TMP}*
exit 0
|