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