chiark / gitweb /
wip compile
[inn-innduct.git] / support / makedepend
1 #! /bin/sh
2
3 ##  $Id: makedepend 5787 2002-09-29 23:32:52Z rra $
4 ##
5 ##  Generate dependencies for INN makefiles
6 ##
7 ##  This shell script automates the process of updating the dependencies in
8 ##  INN's Makefiles.  It uses gcc -MM to do this, since only the maintainers
9 ##  should normally have to do this and using a compiler to parse include
10 ##  directives is more reliable than more ad hoc methods.  It takes compiler
11 ##  flags as its first argument and then a list of all source files to
12 ##  process.
13 ##
14 ##  The Makefile is updated in place, and everything after "DO NOT DELETE
15 ##  THIS LINE" is removed and replaced by the dependencies.
16
17 flags="$1"
18 shift
19 sed '1,/DO NOT DELETE THIS LINE/!d' < Makefile > .makefile.tmp
20 for source in "$@" ; do
21     case $source in
22     */*)
23         base=`echo "$source" | sed 's/\..*//'`
24         gcc -MM $flags "$source" | sed "s%^[^.: ][^.: ]*%$base%" \
25             >> .makefile.tmp
26         ;;
27     *)
28         gcc -MM $flags "$source" >> .makefile.tmp
29         ;;
30     esac
31     if [ $? != 0 ] ; then
32         rm .makefile.tmp
33         exit
34     fi
35 done
36 mv -f .makefile.tmp Makefile