1135446Strhodes#!/bin/sh - 2135446Strhodes 3193149Sdougb## 4193149Sdougb## Modified to handle -vpath <path> option by Michael Graff, ISC. 5193149Sdougb## The purpose of this is to allow this script to run outside of the 6193149Sdougb## source directory, for instance when running configure with 7193149Sdougb## ../bind9-mainline/configure 8193149Sdougb## and still have "make depend" work. 9193149Sdougb## 10193149Sdougb 11135446Strhodes## ++Copyright++ 1987 12135446Strhodes## - 13135446Strhodes## Copyright (c) 1987 Regents of the University of California. 14135446Strhodes## All rights reserved. 15135446Strhodes## 16135446Strhodes## Redistribution and use in source and binary forms, with or without 17135446Strhodes## modification, are permitted provided that the following conditions 18135446Strhodes## are met: 19135446Strhodes## 1. Redistributions of source code must retain the above copyright 20135446Strhodes## notice, this list of conditions and the following disclaimer. 21135446Strhodes## 2. Redistributions in binary form must reproduce the above copyright 22135446Strhodes## notice, this list of conditions and the following disclaimer in the 23135446Strhodes## documentation and/or other materials provided with the distribution. 24262706Serwin## 3. Neither the name of the University nor the names of its contributors 25135446Strhodes## may be used to endorse or promote products derived from this software 26135446Strhodes## without specific prior written permission. 27135446Strhodes## THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28135446Strhodes## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29135446Strhodes## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30135446Strhodes## ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31135446Strhodes## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32135446Strhodes## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33135446Strhodes## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34135446Strhodes## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35135446Strhodes## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36135446Strhodes## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37135446Strhodes## SUCH DAMAGE. 38135446Strhodes## - 39135446Strhodes## Portions Copyright (c) 1993 by Digital Equipment Corporation. 40135446Strhodes## 41135446Strhodes## Permission to use, copy, modify, and distribute this software for any 42135446Strhodes## purpose with or without fee is hereby granted, provided that the above 43135446Strhodes## copyright notice and this permission notice appear in all copies, and that 44135446Strhodes## the name of Digital Equipment Corporation not be used in advertising or 45135446Strhodes## publicity pertaining to distribution of the document or software without 46135446Strhodes## specific, written prior permission. 47135446Strhodes## 48135446Strhodes## THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL 49135446Strhodes## WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES 50135446Strhodes## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT 51135446Strhodes## CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 52135446Strhodes## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 53135446Strhodes## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 54135446Strhodes## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 55135446Strhodes## SOFTWARE. 56135446Strhodes## - 57135446Strhodes## --Copyright-- 58135446Strhodes 59135446Strhodes# 60135446Strhodes# @(#)mkdep.sh 5.12 (Berkeley) 6/30/88 61135446Strhodes# 62135446Strhodes 63135446StrhodesMAKE=Makefile # default makefile name is "Makefile" 64135446Strhodes 65135446Strhodeswhile : 66135446Strhodes do case "$1" in 67193149Sdougb # -vpath allows one to select a virtual path for .c files 68193149Sdougb -vpath) 69193149Sdougb VPATH=$2; 70193149Sdougb shift; shift ;; 71135446Strhodes # -f allows you to select a makefile name 72135446Strhodes -f) 73135446Strhodes MAKE=$2 74135446Strhodes shift; shift ;; 75135446Strhodes 76135446Strhodes # the -p flag produces "program: program.c" style dependencies 77135446Strhodes # so .o's don't get produced 78135446Strhodes -p) 79135446Strhodes SED='s;\.o;;' 80135446Strhodes shift ;; 81135446Strhodes *) 82135446Strhodes break ;; 83135446Strhodes esac 84135446Strhodesdone 85135446Strhodes 86135446Strhodesif [ $# = 0 ] ; then 87193149Sdougb echo 'usage: mkdep [-vpath path] [-p] [-f makefile] [flags] file ...' 88135446Strhodes exit 1 89135446Strhodesfi 90135446Strhodes 91135446Strhodesif [ ! -w $MAKE ]; then 92135446Strhodes echo "mkdep: no writeable file \"$MAKE\"" 93135446Strhodes exit 1 94135446Strhodesfi 95135446Strhodes 96135446StrhodesTMP=mkdep$$ 97135446Strhodes 98135446Strhodestrap 'rm -f $TMP ; exit 1' 1 2 3 13 15 99135446Strhodes 100135446Strhodescp $MAKE ${MAKE}.bak 101135446Strhodes 102135446Strhodessed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP 103135446Strhodes 104135446Strhodescat << _EOF_ >> $TMP 105135446Strhodes# DO NOT DELETE THIS LINE -- mkdep uses it. 106135446Strhodes# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. 107135446Strhodes 108135446Strhodes_EOF_ 109135446Strhodes 110135446Strhodes# If your compiler doesn't have -M, add it. If you can't, the next two 111135446Strhodes# lines will try and replace the "cc -M". The real problem is that this 112135446Strhodes# hack can't deal with anything that requires a search path, and doesn't 113135446Strhodes# even try for anything using bracket (<>) syntax. 114135446Strhodes# 115135446Strhodes# egrep '^#include[ ]*".*"' /dev/null $* | 116135446Strhodes# sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' | 117135446Strhodes 118193149Sdougbif [ X"${VPATH}" != X ] ; then 119193149Sdougb for arg in $* ; do 120193149Sdougb case "$arg" in 121193149Sdougb -*) 122193149Sdougb newargs="$newargs $arg" 123193149Sdougb ;; 124193149Sdougb *) 125193149Sdougb newargs="$newargs $VPATH/$arg" 126193149Sdougb ;; 127193149Sdougb esac 128193149Sdougb done 129193149Sdougbelse 130193149Sdougb newargs="$*"; 131193149Sdougbfi 132193149Sdougb 133135446StrhodesMKDEPPROG="@MKDEPPROG@" 134135446Strhodesif [ X"${MKDEPPROG}" != X ]; then 135193149Sdougb @SHELL@ -c "${MKDEPPROG} ${newargs}" 136135446Strhodeselse 137193149Sdougb @MKDEPCC@ @MKDEPCFLAGS@ ${newargs} | 138135446Strhodes sed " 139234010Sdougb s; \\./; ;g 140234010Sdougb s; \\\\; ;g 141135446Strhodes @LIBTOOL_MKDEP_SED@ 142135446Strhodes $SED" | 143234010Sdougb awk '$1 ~ /:$/ { 144135446Strhodes if (rec != "") 145234010Sdougb print rec; 146234010Sdougb if (NF == 1) 147234010Sdougb rec = $1; 148234010Sdougb else 149234010Sdougb rec = $1 " " $2; 150234010Sdougb for (i = 3; i <= NF; i++) { 151234010Sdougb if (length(rec $i) > 76) { 152234010Sdougb print rec " \\"; 153234010Sdougb rec = " " $i; 154234010Sdougb } else { 155234010Sdougb rec = rec " " $i; 156234010Sdougb } 157234010Sdougb } 158234010Sdougb next; 159135446Strhodes } 160234010Sdougb { 161234010Sdougb for (i = 1; i <= NF; i++) { 162234010Sdougb if (length(rec $i) > 76) { 163234010Sdougb print rec, "\\"; 164234010Sdougb rec = " " $i; 165234010Sdougb } else { 166234010Sdougb rec = rec " " $i; 167234010Sdougb } 168135446Strhodes } 169135446Strhodes } 170135446Strhodes END { 171135446Strhodes print rec 172135446Strhodes }' >> $TMP 173135446Strhodesfi 174135446Strhodes 175135446Strhodescat << _EOF_ >> $TMP 176135446Strhodes 177135446Strhodes# IF YOU PUT ANYTHING HERE IT WILL GO AWAY 178135446Strhodes_EOF_ 179135446Strhodes 180135446Strhodes# copy to preserve permissions 181135446Strhodescp $TMP $MAKE 182135446Strhodesrm -f ${MAKE}.bak $TMP 183135446Strhodesexit 0 184