aboutsummaryrefslogtreecommitdiff
path: root/contrib/libpcap/mkdep
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libpcap/mkdep')
-rwxr-xr-xcontrib/libpcap/mkdep55
1 files changed, 32 insertions, 23 deletions
diff --git a/contrib/libpcap/mkdep b/contrib/libpcap/mkdep
index 1486b185aa43..f85a447a79c6 100755
--- a/contrib/libpcap/mkdep
+++ b/contrib/libpcap/mkdep
@@ -16,7 +16,10 @@
MAKE=Makefile # default makefile name is "Makefile"
CC=cc # default C compiler is "cc"
DEPENDENCY_CFLAG=-M # default dependency-generation flag is -M
+SOURCE_DIRECTORY=. # default source directory is the current directory
+# No command-line flags seen yet.
+flags=""
while :
do case "$1" in
# -c allows you to specify the C compiler
@@ -39,13 +42,29 @@ while :
-p)
SED='s;\.o;;'
shift ;;
+
+ # -s allows you to specify the source directory
+ -s)
+ SOURCE_DIRECTORY=$2
+ shift; shift ;;
+
+ # -include takes an argument
+ -include)
+ flags="$flags $1 $2"
+ shift; shift ;;
+
+ # other command-line flag
+ -*)
+ flags="$flags $1"
+ shift ;;
+
*)
break ;;
esac
done
if [ $# = 0 ] ; then
- echo 'usage: mkdep [-p] [-c cc] [-f makefile] [-m dependency-cflag] [flags] file ...'
+ echo 'usage: mkdep [-p] [-c cc] [-f makefile] [-m dependency-cflag] [-s source-directory] [flags] file ...'
exit 1
fi
@@ -73,33 +92,23 @@ _EOF_
# hack can't deal with anything that requires a search path, and doesn't
# even try for anything using bracket (<>) syntax.
#
-# egrep '^#include[ ]*".*"' /dev/null $* |
+# grep -E '^#include[[:blank:]]*".*"' /dev/null $* |
# sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' |
+#
+# Construct a list of source files with paths relative to the source directory.
+#
+sources=""
+for srcfile in $*
+do
+ sources="$sources $SOURCE_DIRECTORY/$srcfile"
+done
+
# XXX this doesn't work with things like "-DDECLWAITSTATUS=union\ wait"
-$CC $DEPENDENCY_CFLAG $* |
+$CC $DEPENDENCY_CFLAG $flags $sources |
sed "
s; \./; ;g
- $SED" |
-awk '{
- if ($1 != prev) {
- if (rec != "")
- print rec;
- rec = $0;
- prev = $1;
- }
- else {
- if (length(rec $2) > 78) {
- print rec;
- rec = $0;
- }
- else
- rec = rec " " $2
- }
-}
-END {
- print rec
-}' >> $TMP
+ $SED" >> $TMP
cat << _EOF_ >> $TMP