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
36 : ${CC_MKDEP=$CC} # select default compiler to generate dependencies
37 : ${CC_MKDEP_FLAGS="-M"} # cc -M usually produces dependencies
41 # the -s flag removes dependencies to files that begin with /
46 # -f allows you to select a makefile name
51 # -d allows you to select a VPATH directory
56 # -c allows you to select a compiler to use to generate
57 # dependencies. Leaves $CC alone.
62 # the -p flag produces "program: program.c" style dependencies
63 # so .o's don't get produced
69 # the -l flag produces libtool compatible dependencies
71 SED='sed -e s;\.o:;.lo:;'
82 echo 'usage: mkdep [-p] [-s] [-c cc] [-f makefile] [-d srcdir] [flags] file ...'
86 if test ! -w $MAKE ; then
87 echo "mkdep: no writeable file \"$MAKE\""
93 trap 'rm -f $TMP.sed $TMP ; exit 1' 1 2 3 13 15
97 sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP
100 # DO NOT DELETE THIS LINE -- mkdep uses it.
101 # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
105 # If your compiler doesn't have -M, add it. If you can't, the next two
106 # lines will try and replace the "cc -M". The real problem is that this
107 # hack can't deal with anything that requires a search path, and doesn't
108 # even try for anything using bracket (<>) syntax.
110 # egrep '^#include[ ]*".*"' /dev/null $* |
111 # sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' |
113 if test "x$SRCDIR" = "x" ; then
120 elif test -f $SRCDIR/$i ; then
121 files="$files $SRCDIR/$i"
133 # command: $CC_MKDEP $CC_MKDEP_FLAGS $files
138 $CC_MKDEP $CC_MKDEP_FLAGS $files | \
139 sed -e 's; \./; ;g' | \
141 # dont pipe to awk. SGI awk wants a filename as argument.
142 # (or '-', but I do not know if all other awks support that.)
146 dep=substr($0, length(filenm)+1);
152 split(dep, depends, " ");
155 if (( noslash == "yes") && (dfile ~ /^\// )) next
156 if ( length(dfile) < 2 ) continue
157 rec = filenm " " dfile;
161 ' noslash="$NOSLASH" $TMP.sed >> $TMP
166 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
169 # copy to preserve permissions
171 rm -f ${MAKE}.bak $TMP.sed $TMP