]>
The Tcpdump Group git mirrors - libpcap/blob - mkdep
3 # Copyright (c) 1994, 1996
4 # The Regents of the University of California. All rights reserved.
6 # Redistribution and use in source and binary forms are permitted
7 # provided that this notice is preserved and that due credit is given
8 # to the University of California at Berkeley. The name of the University
9 # may not be used to endorse or promote products derived from this
10 # software without specific prior written permission. This software
11 # is provided ``as is'' without express or implied warranty.
13 # @(#)mkdep.sh 5.11 (Berkeley) 5/5/88
16 MAKE
=Makefile
# default makefile name is "Makefile"
17 CC
=cc
# default C compiler is "cc"
18 DEPENDENCY_CFLAG
=-M # default dependency-generation flag is -M
19 SOURCE_DIRECTORY
=.
# default source directory is the current directory
21 # No command-line flags seen yet.
25 # -c allows you to specify the C compiler
30 # -f allows you to select a makefile name
35 # -m allows you to specify the dependency-generation flag
40 # the -p flag produces "program: program.c" style dependencies
41 # so .o's don't get produced
46 # -s allows you to specify the source directory
51 # -include takes an argument
56 # other command-line flag
67 echo 'usage: mkdep [-p] [-c cc] [-f makefile] [-m dependency-cflag] [-s source-directory] [flags] file ...'
71 if [ ! -w "$MAKE" ]; then
72 echo "mkdep: no writeable file \"$MAKE\""
76 TMP
=${TMPDIR:-/tmp}/mkdep$$
78 trap 'rm -f "$TMP" ; exit 1' HUP INT QUIT PIPE TERM
80 cp "$MAKE" "${MAKE}.bak"
82 sed -e '/DO NOT DELETE THIS LINE/,$d' < "$MAKE" > "$TMP"
84 cat << _EOF_ >> "$TMP"
85 # DO NOT DELETE THIS LINE -- mkdep uses it.
86 # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
90 # If your compiler doesn't have -M, add it. If you can't, the next two
91 # lines will try and replace the "cc -M". The real problem is that this
92 # hack can't deal with anything that requires a search path, and doesn't
93 # even try for anything using bracket (<>) syntax.
95 # grep -E '^#include[[:blank:]]*".*"' /dev/null $* |
96 # sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' |
99 # Construct a list of source files with paths relative to the source directory.
104 sources
="$sources $SOURCE_DIRECTORY/$srcfile"
107 # XXX this doesn't work with things like "-DDECLWAITSTATUS=union\ wait"
108 # $flags and $sources are meant to expand
109 # shellcheck disable=SC2086
110 "$CC" "$DEPENDENCY_CFLAG" $flags $sources |
115 cat << _EOF_ >> "$TMP"
117 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
120 # copy to preserve permissions
122 rm -f "${MAKE}.bak" "$TMP"