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
32 CC=${CC_MKDEP-${CC-cc}} # default compiler is cc
33 : ${CC_MKDEP_FLAGS="-M"} # cc -M usually produces dependencies
39 # the -s flag removes dependencies to files that begin with /
44 # -f allows you to select a makefile name
49 # -d allows you to select a VPATH directory
54 # -c allows you to select a compiler to use (default is cc)
56 [ -z "$CC_MKDEP" ] && CC=$2
59 # the -p flag produces "program: program.c" style dependencies
60 # so .o's don't get produced
66 # the -l flag produces libtool compatible dependencies
68 SED='sed -e s;\.o:;.lo:;'
79 echo 'usage: mkdep [-p] [-s] [-c cc] [-f makefile] [-d srcdir] [flags] file ...'
83 if [ ! -w $MAKE ]; then
84 echo "mkdep: no writeable file \"$MAKE\""
90 trap 'rm -f $TMP.sed $TMP ; exit 1' 1 2 3 13 15
94 sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP
97 # DO NOT DELETE THIS LINE -- mkdep uses it.
98 # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
102 # If your compiler doesn't have -M, add it. If you can't, the next two
103 # lines will try and replace the "cc -M". The real problem is that this
104 # hack can't deal with anything that requires a search path, and doesn't
105 # even try for anything using bracket (<>) syntax.
107 # egrep '^#include[ ]*".*"' /dev/null $* |
108 # sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' |
110 if test "x$SRCDIR" = "x" ; then
117 elif test -f $SRCDIR/$i ; then
118 files="$files $SRCDIR/$i"
130 # command: $CC $CC_MKDEP_FLAGS $files
135 $CC $CC_MKDEP_FLAGS $files | \
136 sed -e 's; \./; ;g' | \
138 # dont pipe to awk. SGI awk wants a filename as argument.
139 # (or '-', but I do not know if all other awks support that.)
143 dep=substr($0, length(filenm)+1);
149 split(dep, depends, " ");
152 if (( noslash == "yes") && (dfile ~ /^\// )) next
153 if ( length(dfile) < 2 ) continue
154 rec = filenm " " dfile;
158 ' noslash="$NOSLASH" $TMP.sed >> $TMP
163 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
166 # copy to preserve permissions
168 rm -f ${MAKE}.bak $TMP.sed $TMP