1 |
#! /usr/bin/env sh |
#! /usr/bin/env sh |
2 |
# |
# |
3 |
|
# $Header$ |
4 |
|
# $Name$ |
5 |
|
# |
6 |
# $TOG: mdepend.cpp /main/13 1997/06/20 21:12:18 kaleb $ |
# $TOG: mdepend.cpp /main/13 1997/06/20 21:12:18 kaleb $ |
7 |
# |
# |
8 |
# Do the equivalent of the 'makedepend' program, but do it right. |
# Do the equivalent of the 'makedepend' program, but do it right. |
26 |
# "-" (at least, that is what the documentation implies). |
# "-" (at least, that is what the documentation implies). |
27 |
# |
# |
28 |
# $XFree86: xc/config/util/mdepend.cpp,v 3.2 1997/06/29 07:54:20 dawes Exp $ |
# $XFree86: xc/config/util/mdepend.cpp,v 3.2 1997/06/29 07:54:20 dawes Exp $ |
|
# |
|
29 |
|
|
30 |
CPPARGS="-traditional -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE " |
CPPARGS="-Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE " |
31 |
|
CPPARGS="-traditional $CPPARGS" |
32 |
|
|
33 |
if test -r ./genmake_optfile ; then |
CC="cpp $CPPARGS" |
34 |
. ./genmake_optfile |
if test -x /lib/cpp ; then |
35 |
fi |
CC="/lib/cpp $CPPARGS" |
|
if test "x$CPP" != x0 ; then |
|
|
CC="$CPP $CPPARGS" |
|
|
else |
|
|
CC="cpp $CPPARGS" |
|
36 |
fi |
fi |
37 |
|
|
38 |
silent='-' |
silent='-' |
39 |
|
|
40 |
TMP=./mdep$$ |
#TMP=./mdep$$ |
41 |
|
#- try to put temporary files in system-local /tmp dir |
42 |
|
TMP=/tmp/mdep$$ |
43 |
|
touch $TMP ; retVal=$? |
44 |
|
if [ $retVal -eq 0 ] ; then |
45 |
|
if test ! -r $TMP ; then TMP=./mdep$$ ; fi |
46 |
|
else |
47 |
|
TMP=./mdep$$ |
48 |
|
fi |
49 |
|
rm -f $TMP |
50 |
|
#echo "temp files: $TMP" |
51 |
|
|
52 |
CPPCMD=${TMP}a |
CPPCMD=${TMP}a |
53 |
DEPENDLINES=${TMP}b |
DEPENDLINES=${TMP}b |
54 |
TMPMAKEFILE=${TMP}c |
TMPMAKEFILE=${TMP}c |
180 |
;; |
;; |
181 |
esac |
esac |
182 |
|
|
183 |
if [ "$verbose"x = "y"x ]; then |
if [ "$verbose"x = "y"x ]; then |
184 |
cat $CPPCMD |
cat $CPPCMD |
185 |
fi |
fi |
186 |
|
|
189 |
do |
do |
190 |
$CPPCMD $i | sed -n "/^#/s;^;$i ;p" |
$CPPCMD $i | sed -n "/^#/s;^;$i ;p" |
191 |
|
|
192 |
done | sed -e 's|/[^/.][^/]*/\.\.||g' -e 's|/\.[^.][^/]*/\.\.||g' -e 's|"||g' -e 's| \./| |' | awk '{ |
done | sed -e 's|/[^/.][^/]*/\.\.||g' -e 's|/\.[^.][^/]*/\.\.||g' -e 's|"||g' -e 's| \./| |' | awk '!/<.*>/{ |
193 |
if ($1 != $4 && $2 != "#ident" && $2 != "#pragma") |
if ($1 != $4 && $2 != "#ident" && $2 != "#pragma") |
194 |
|
|
|
|
|
|
|
|
195 |
{ |
{ |
196 |
ofile = substr ($1, 1, length ($1) - 2) "'"$objsuffix"'" |
ofile = substr ($1, 1, length ($1) - 2) "'"$objsuffix"'" |
197 |
print ofile, $4 |
print ofile, $4 |
198 |
} |
} |
199 |
}' | sort -u | awk ' |
}' | sort -u | awk ' |
200 |
|
|
|
|
|
201 |
{ |
{ |
202 |
newrec = rec " " $2 |
newrec = rec " " $2 |
203 |
if ($1 != old1) |
if ($1 != old1) |
221 |
print rec |
print rec |
222 |
}' | egrep -v '^[^:]*:[ ]*$' >> $DEPENDLINES |
}' | egrep -v '^[^:]*:[ ]*$' >> $DEPENDLINES |
223 |
|
|
|
|
|
224 |
trap "" 1 2 13 15 # Now we are committed |
trap "" 1 2 13 15 # Now we are committed |
225 |
case "$makefile" in |
case "$makefile" in |
226 |
$TMPMAKEFILE) |
$TMPMAKEFILE) |
232 |
;; |
;; |
233 |
esac |
esac |
234 |
|
|
|
# |
|
235 |
# If not -a, append the magic string and a blank line so that |
# If not -a, append the magic string and a blank line so that |
236 |
# /^$magic_string/+1,\$d can be used to delete everything from after |
# /^$magic_string/+1,\$d can be used to delete everything from after |
237 |
# the magic string to the end of the file. Then, append a blank |
# the magic string to the end of the file. Then, append a blank |
238 |
# line again and then the dependencies. |
# line again and then the dependencies. |
|
# |
|
239 |
if [ "$append" = "n" ] |
if [ "$append" = "n" ] |
240 |
then |
then |
241 |
cat >> $makefile << END_OF_APPEND |
cat >> $makefile << END_OF_APPEND |
257 |
$TMPMAKEFILE) |
$TMPMAKEFILE) |
258 |
cat $TMPMAKEFILE |
cat $TMPMAKEFILE |
259 |
;; |
;; |
|
|
|
260 |
esac |
esac |
261 |
|
|
262 |
rm -f ${TMP}* |
rm -f ${TMP}* |