2 ## Copyright 1998,1999 The OpenLDAP Foundation
3 ## COPYING RESTRICTIONS APPLY. See COPYRIGHT File in top level directory
4 ## of this package for details.
7 # Copyright (c) 1987 Regents of the University of California.
10 # Redistribution and use in source and binary forms are permitted
11 # provided that the above copyright notice and this paragraph are
12 # duplicated in all such forms and that any documentation,
13 # advertising materials, and other materials related to such
14 # distribution and use acknowledge that the software was developed
15 # by the University of California, Berkeley. The name of the
16 # University may not be used to endorse or promote products derived
17 # from this software without specific prior written permission.
18 # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
19 # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
20 # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 # @(#)mkdep.sh 5.12 (Berkeley) 6/30/88
24 # We now use whatever path is already set by the invoker
25 #PATH=/bin:/usr/bin:/usr/ucb
28 set -e # exit immediately if any errors occur
30 MAKE=Makefile # default makefile name is "Makefile"
31 NOSLASH="no" # by default, / dependencies are included
35 : ${CC=cc} # use cc by default
37 # We generally set these via the command line options
38 : ${MKDEP_CC=$CC} # select default compiler to generate dependencies
39 : ${MKDEP_CFLAGS="-M"} # cc -M usually produces dependencies
43 # the -s flag removes dependencies to files that begin with /
48 # -f allows you to select a makefile name
53 # -d allows you to select a VPATH directory
58 # -c allows you to override the compiler used to generate dependencies
63 # -m allows you to override the compiler flags used to generate
69 # the -p flag produces "program: program.c" style dependencies
70 # so .o's don't get produced
75 # the -l flag produces libtool compatible dependencies
77 SED='sed -e s;\.o:;.lo:;'
88 echo 'usage: mkdep [-p] [-s] [-c cc] [-m flags] [-f makefile] [-d srcdir] [cppflags] file ...'
92 if test ! -w $MAKE ; then
93 echo "mkdep: no writeable file \"$MAKE\""
99 trap 'rm -f $TMP.sed $TMP ; exit 1' 1 2 3 13 15
103 sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP
106 # DO NOT DELETE THIS LINE -- mkdep uses it.
107 # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
111 # If your compiler doesn't have -M, add it. If you can't, the next two
112 # lines will try and replace the "cc -M". The real problem is that this
113 # hack can't deal with anything that requires a search path, and doesn't
114 # even try for anything using bracket (<>) syntax.
116 # egrep '^#include[ ]*".*"' /dev/null $* |
117 # sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' |
119 if test "x$SRCDIR" = "x" ; then
126 elif test -f $SRCDIR/$i ; then
127 files="$files $SRCDIR/$i"
133 MKDEP_CFLAGS="$MKDEP_CFLAGS -I$SRCDIR"
140 # command: $MKDEP_CC $MKDEP_CFLAGS $files
145 $MKDEP_CC $MKDEP_CFLAGS $files | \
146 sed -e 's; \./; ;g' | \
148 # dont pipe to awk. SGI awk wants a filename as argument.
149 # (or '-', but I do not know if all other awks support that.)
153 dep=substr($0, length(filenm)+1);
159 split(dep, depends, " ");
162 if (( noslash == "yes") && (dfile ~ /^\// )) next
163 if ( length(dfile) < 2 ) continue
164 rec = filenm " " dfile;
168 ' noslash="$NOSLASH" $TMP.sed >> $TMP
173 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
176 # copy to preserve permissions
178 rm -f ${MAKE}.bak $TMP.sed $TMP