etc/services - sync with NetBSD-8
[minix.git] / external / bsd / bind / dist / make / mkdep.in
blob2ba9495e820b08267ef7dd70a27635276fed1806
1 #!/bin/sh -
3 ##
4 ## Modified to handle -vpath <path> option by Michael Graff, ISC.
5 ## The purpose of this is to allow this script to run outside of the
6 ## source directory, for instance when running configure with
7 ## ../bind9-mainline/configure
8 ## and still have "make depend" work.
9 ##
11 ## ++Copyright++ 1987
12 ## -
13 ## Copyright (c) 1987 Regents of the University of California.
14 ## All rights reserved.
16 ## Redistribution and use in source and binary forms, with or without
17 ## modification, are permitted provided that the following conditions
18 ## are met:
19 ## 1. Redistributions of source code must retain the above copyright
20 ## notice, this list of conditions and the following disclaimer.
21 ## 2. Redistributions in binary form must reproduce the above copyright
22 ## notice, this list of conditions and the following disclaimer in the
23 ## documentation and/or other materials provided with the distribution.
24 ## 3. Neither the name of the University nor the names of its contributors
25 ## may be used to endorse or promote products derived from this software
26 ## without specific prior written permission.
27 ## THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 ## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 ## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 ## ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 ## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 ## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 ## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 ## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 ## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 ## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 ## SUCH DAMAGE.
38 ## -
39 ## Portions Copyright (c) 1993 by Digital Equipment Corporation.
41 ## Permission to use, copy, modify, and distribute this software for any
42 ## purpose with or without fee is hereby granted, provided that the above
43 ## copyright notice and this permission notice appear in all copies, and that
44 ## the name of Digital Equipment Corporation not be used in advertising or
45 ## publicity pertaining to distribution of the document or software without
46 ## specific, written prior permission.
48 ## THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
49 ## WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
50 ## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
51 ## CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
52 ## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
53 ## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
54 ## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
55 ## SOFTWARE.
56 ## -
57 ## --Copyright--
60 # @(#)mkdep.sh 5.12 (Berkeley) 6/30/88
63 MAKE=Makefile # default makefile name is "Makefile"
65 while :
66 do case "$1" in
67 # -vpath allows one to select a virtual path for .c files
68 -vpath)
69 VPATH=$2;
70 shift; shift ;;
71 # -f allows you to select a makefile name
72 -f)
73 MAKE=$2
74 shift; shift ;;
76 # the -p flag produces "program: program.c" style dependencies
77 # so .o's don't get produced
78 -p)
79 SED='s;\.o;;'
80 shift ;;
82 break ;;
83 esac
84 done
86 if [ $# = 0 ] ; then
87 echo 'usage: mkdep [-vpath path] [-p] [-f makefile] [flags] file ...'
88 exit 1
91 if [ ! -w $MAKE ]; then
92 echo "mkdep: no writeable file \"$MAKE\""
93 exit 1
96 TMP=mkdep$$
98 trap 'rm -f $TMP ; exit 1' 1 2 3 13 15
100 cp $MAKE ${MAKE}.bak
102 sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP
104 cat << _EOF_ >> $TMP
105 # DO NOT DELETE THIS LINE -- mkdep uses it.
106 # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
108 _EOF_
110 # If your compiler doesn't have -M, add it. If you can't, the next two
111 # lines will try and replace the "cc -M". The real problem is that this
112 # hack can't deal with anything that requires a search path, and doesn't
113 # even try for anything using bracket (<>) syntax.
115 # egrep '^#include[ ]*".*"' /dev/null $* |
116 # sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' |
118 if [ X"${VPATH}" != X ] ; then
119 for arg in $* ; do
120 case "$arg" in
122 newargs="$newargs $arg"
125 newargs="$newargs $VPATH/$arg"
127 esac
128 done
129 else
130 newargs="$*";
133 MKDEPPROG="@MKDEPPROG@"
134 if [ X"${MKDEPPROG}" != X ]; then
135 @SHELL@ -c "${MKDEPPROG} ${newargs}"
136 else
137 @MKDEPCC@ @MKDEPCFLAGS@ ${newargs} |
138 sed "
139 s; \\./; ;g
140 s; \\\\; ;g
141 @LIBTOOL_MKDEP_SED@
142 $SED" |
143 awk '$1 ~ /:$/ {
144 if (rec != "")
145 print rec;
146 if (NF == 1)
147 rec = $1;
148 else
149 rec = $1 " " $2;
150 for (i = 3; i <= NF; i++) {
151 if (length(rec $i) > 76) {
152 print rec " \\";
153 rec = " " $i;
154 } else {
155 rec = rec " " $i;
158 next;
161 for (i = 1; i <= NF; i++) {
162 if (length(rec $i) > 76) {
163 print rec, "\\";
164 rec = " " $i;
165 } else {
166 rec = rec " " $i;
170 END {
171 print rec
172 }' >> $TMP
175 cat << _EOF_ >> $TMP
177 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
178 _EOF_
180 # copy to preserve permissions
181 cp $TMP $MAKE
182 rm -f ${MAKE}.bak $TMP
183 exit 0