3 XCOMM $TOG: mdepend.cpp /main/13 1997/06/20 21:12:18 kaleb $
5 XCOMM Do the equivalent of the 'makedepend' program, but do it right.
9 XCOMM makedepend [cpp-flags] [-w width] [-s magic-string] [-f makefile]
10 XCOMM [-o object-suffix]
14 XCOMM The C compiler used can be overridden with the environment
17 XCOMM The "-v" switch of the "makedepend" program is not supported.
20 XCOMM This script should
21 XCOMM work on both USG and BSD systems. However, when System V.4 comes out,
22 XCOMM USG users will probably have to change "silent" to "-s" instead of
23 XCOMM "-" (at least, that is what the documentation implies).
25 XCOMM $XFree86: xc/config/util/mdepend.cpp,v 3.1.8.1 1997/06/29 08:43:27 dawes Exp $
39 trap "rm -f ${TMP}*; exit 1" 1 2 15
40 trap "rm -f ${TMP}*; exit 0" 1 2 13
43 if [ `wc -c < $CPPCMD` -eq 1 ]
56 magic_string='# DO NOT DELETE'
65 if [ "$endmarker"x != x ] && [ "$endmarker" = "$1" ]; then
70 echo $n " '$1'$c" >> $ARGS
73 -g|-O) # ignore so we can just pass $(CFLAGS) in
77 if [ "$endmarker"x = x ]; then
88 if [ "$1" = "-f-" ]; then
101 echo "$1" | sed 's/^\-\-//' >${TMP}end
102 endmarker="`cat ${TMP}end`"
104 if [ "$endmarker"x = x ]; then
122 echo "Unknown option '$1' ignored" 1>&2
136 echo "#!/bin/sh" > $CPPCMD
137 echo "exec $CC `cat $ARGS`" >> $CPPCMD
150 echo 'no makefile or Makefile found' 1>&2
155 makefile=$TMPMAKEFILE
159 if [ "$verbose"x = "y"x ]; then
163 echo '' > $DEPENDLINES
167 | sed -n "/^#/s;^;$i ;p"
169 | sed -e 's|/[^/.][^/]*/\.\.||g' -e 's|/\.[^.][^/]*/\.\.||g' \
170 -e 's|"||g' -e 's| \./| |' \
172 if ($1 != $4 && $2 != "#ident" && $2 != "#pragma")
174 ofile = substr ($1, 1, length ($1) - 2) "'"$objsuffix"'"
189 else if (length (newrec) > '"$width"')
202 | egrep -v '^[^:]*:[ ]*$' >> $DEPENDLINES
204 trap "" 1 2 13 15 # Now we are committed
210 cp $makefile $makefile.bak
211 echo "Appending dependencies to $makefile"
216 XCOMM If not -a, append the magic string and a blank line so that
217 XCOMM /^$magic_string/+1,\$d can be used to delete everything from after
218 XCOMM the magic string to the end of the file. Then, append a blank
219 XCOMM line again and then the dependencies.
221 if [ "$append" = "n" ]
223 cat >> $makefile << END_OF_APPEND
228 ed $silent $makefile << END_OF_ED_SCRIPT
229 /^$magic_string/+1,\$d
236 cat $DEPENDLINES >>$makefile