1#!/bin/sh - 2 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## 10 11## ++Copyright++ 1987 12## - 13## Copyright (c) 1987 Regents of the University of California. 14## All rights reserved. 15## 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. All advertising materials mentioning features or use of this software 25## must display the following acknowledgement: 26## This product includes software developed by the University of 27## California, Berkeley and its contributors. 28## 4. Neither the name of the University nor the names of its contributors 29## may be used to endorse or promote products derived from this software 30## without specific prior written permission. 31## THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 32## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 33## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 34## ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 35## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 39## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 40## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 41## SUCH DAMAGE. 42## - 43## Portions Copyright (c) 1993 by Digital Equipment Corporation. 44## 45## Permission to use, copy, modify, and distribute this software for any 46## purpose with or without fee is hereby granted, provided that the above 47## copyright notice and this permission notice appear in all copies, and that 48## the name of Digital Equipment Corporation not be used in advertising or 49## publicity pertaining to distribution of the document or software without 50## specific, written prior permission. 51## 52## THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL 53## WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES 54## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT 55## CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 56## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 57## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 58## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 59## SOFTWARE. 60## - 61## --Copyright-- 62 63# 64# @(#)mkdep.sh 5.12 (Berkeley) 6/30/88 65# 66 67MAKE=Makefile # default makefile name is "Makefile" 68 69while : 70 do case "$1" in 71 # -vpath allows one to select a virtual path for .c files 72 -vpath) 73 VPATH=$2; 74 shift; shift ;; 75 # -f allows you to select a makefile name 76 -f) 77 MAKE=$2 78 shift; shift ;; 79 80 # the -p flag produces "program: program.c" style dependencies 81 # so .o's don't get produced 82 -p) 83 SED='s;\.o;;' 84 shift ;; 85 *) 86 break ;; 87 esac 88done 89 90if [ $# = 0 ] ; then 91 echo 'usage: mkdep [-vpath path] [-p] [-f makefile] [flags] file ...' 92 exit 1 93fi 94 95if [ ! -w $MAKE ]; then 96 echo "mkdep: no writeable file \"$MAKE\"" 97 exit 1 98fi 99 100TMP=mkdep$$ 101 102trap 'rm -f $TMP ; exit 1' 1 2 3 13 15 103 104cp $MAKE ${MAKE}.bak 105 106sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP 107 108cat << _EOF_ >> $TMP 109# DO NOT DELETE THIS LINE -- mkdep uses it. 110# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. 111 112_EOF_ 113 114# If your compiler doesn't have -M, add it. If you can't, the next two 115# lines will try and replace the "cc -M". The real problem is that this 116# hack can't deal with anything that requires a search path, and doesn't 117# even try for anything using bracket (<>) syntax. 118# 119# egrep '^#include[ ]*".*"' /dev/null $* | 120# sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' | 121 122if [ X"${VPATH}" != X ] ; then 123 for arg in $* ; do 124 case "$arg" in 125 -*) 126 newargs="$newargs $arg" 127 ;; 128 *) 129 newargs="$newargs $VPATH/$arg" 130 ;; 131 esac 132 done 133else 134 newargs="$*"; 135fi 136 137MKDEPPROG="@MKDEPPROG@" 138if [ X"${MKDEPPROG}" != X ]; then 139 @SHELL@ -c "${MKDEPPROG} ${newargs}" 140else 141 @MKDEPCC@ @MKDEPCFLAGS@ ${newargs} | 142 sed " 143 s; \\./; ;g 144 s; \\\\; ;g 145 @LIBTOOL_MKDEP_SED@ 146 $SED" | 147 awk '$1 ~ /:$/ { 148 if (rec != "") 149 print rec; 150 if (NF == 1) 151 rec = $1; 152 else 153 rec = $1 " " $2; 154 for (i = 3; i <= NF; i++) { 155 if (length(rec $i) > 76) { 156 print rec " \\"; 157 rec = " " $i; 158 } else { 159 rec = rec " " $i; 160 } 161 } 162 next; 163 } 164 { 165 for (i = 1; i <= NF; i++) { 166 if (length(rec $i) > 76) { 167 print rec, "\\"; 168 rec = " " $i; 169 } else { 170 rec = rec " " $i; 171 } 172 } 173 } 174 END { 175 print rec 176 }' >> $TMP 177fi 178 179cat << _EOF_ >> $TMP 180 181# IF YOU PUT ANYTHING HERE IT WILL GO AWAY 182_EOF_ 183 184# copy to preserve permissions 185cp $TMP $MAKE 186rm -f ${MAKE}.bak $TMP 187exit 0 188