cxgbe/t4_tom: Read the chip's DDP page sizes and save them in a
[freebsd-src.git] / contrib / libpcap / mkdep
blobbfe4a2614a4f02d2c2c18c23cdd8df7d031158e0
1 #!/bin/sh -
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 PATH=/bin:/usr/bin:/usr/ucb:/usr/local:/usr/local/bin:/usr/sfw/bin
17 export PATH
19 MAKE=Makefile # default makefile name is "Makefile"
20 CC=cc # default C compiler is "cc"
21 DEPENDENCY_CFLAG=-M # default dependency-generation flag is -M
23 while :
24 do case "$1" in
25 # -c allows you to specify the C compiler
26 -c)
27 CC=$2
28 shift; shift ;;
30 # -f allows you to select a makefile name
31 -f)
32 MAKE=$2
33 shift; shift ;;
35 # -m allows you to specify the dependency-generation flag
36 -m)
37 DEPENDENCY_CFLAG=$2
38 shift; shift ;;
40 # the -p flag produces "program: program.c" style dependencies
41 # so .o's don't get produced
42 -p)
43 SED='s;\.o;;'
44 shift ;;
46 break ;;
47 esac
48 done
50 if [ $# = 0 ] ; then
51 echo 'usage: mkdep [-p] [-c cc] [-f makefile] [-m dependency-cflag] [flags] file ...'
52 exit 1
55 if [ ! -w $MAKE ]; then
56 echo "mkdep: no writeable file \"$MAKE\""
57 exit 1
60 TMP=/tmp/mkdep$$
62 trap 'rm -f $TMP ; exit 1' 1 2 3 13 15
64 cp $MAKE ${MAKE}.bak
66 sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP
68 cat << _EOF_ >> $TMP
69 # DO NOT DELETE THIS LINE -- mkdep uses it.
70 # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
72 _EOF_
74 # If your compiler doesn't have -M, add it. If you can't, the next two
75 # lines will try and replace the "cc -M". The real problem is that this
76 # hack can't deal with anything that requires a search path, and doesn't
77 # even try for anything using bracket (<>) syntax.
79 # egrep '^#include[ ]*".*"' /dev/null $* |
80 # sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' |
82 # XXX this doesn't work with things like "-DDECLWAITSTATUS=union\ wait"
83 $CC $DEPENDENCY_CFLAG $* |
84 sed "
85 s; \./; ;g
86 $SED" |
87 awk '{
88 if ($1 != prev) {
89 if (rec != "")
90 print rec;
91 rec = $0;
92 prev = $1;
94 else {
95 if (length(rec $2) > 78) {
96 print rec;
97 rec = $0;
99 else
100 rec = rec " " $2
103 END {
104 print rec
105 }' >> $TMP
107 cat << _EOF_ >> $TMP
109 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
110 _EOF_
112 # copy to preserve permissions
113 cp $TMP $MAKE
114 rm -f ${MAKE}.bak $TMP
115 exit 0