19b50d902SRodney W. Grimes#!/bin/sh - 29b50d902SRodney W. Grimes# 39b50d902SRodney W. Grimes# Copyright (c) 1991, 1993 49b50d902SRodney W. Grimes# The Regents of the University of California. All rights reserved. 59b50d902SRodney W. Grimes# 69b50d902SRodney W. Grimes# Redistribution and use in source and binary forms, with or without 79b50d902SRodney W. Grimes# modification, are permitted provided that the following conditions 89b50d902SRodney W. Grimes# are met: 99b50d902SRodney W. Grimes# 1. Redistributions of source code must retain the above copyright 109b50d902SRodney W. Grimes# notice, this list of conditions and the following disclaimer. 119b50d902SRodney W. Grimes# 2. Redistributions in binary form must reproduce the above copyright 129b50d902SRodney W. Grimes# notice, this list of conditions and the following disclaimer in the 139b50d902SRodney W. Grimes# documentation and/or other materials provided with the distribution. 149b50d902SRodney W. Grimes# 3. All advertising materials mentioning features or use of this software 159b50d902SRodney W. Grimes# must display the following acknowledgement: 169b50d902SRodney W. Grimes# This product includes software developed by the University of 179b50d902SRodney W. Grimes# California, Berkeley and its contributors. 189b50d902SRodney W. Grimes# 4. Neither the name of the University nor the names of its contributors 199b50d902SRodney W. Grimes# may be used to endorse or promote products derived from this software 209b50d902SRodney W. Grimes# without specific prior written permission. 219b50d902SRodney W. Grimes# 229b50d902SRodney W. Grimes# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 239b50d902SRodney W. Grimes# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 249b50d902SRodney W. Grimes# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 259b50d902SRodney W. Grimes# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 269b50d902SRodney W. Grimes# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 279b50d902SRodney W. Grimes# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 289b50d902SRodney W. Grimes# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 299b50d902SRodney W. Grimes# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 309b50d902SRodney W. Grimes# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 319b50d902SRodney W. Grimes# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 329b50d902SRodney W. Grimes# SUCH DAMAGE. 339b50d902SRodney W. Grimes# 349b50d902SRodney W. Grimes# @(#)mkdep.gcc.sh 8.1 (Berkeley) 6/6/93 35905a01acSDavid E. O'Brien# $Id: mkdep.gcc.sh,v 1.14 1998/08/24 10:16:39 cracauer Exp $ 369b50d902SRodney W. Grimes 379b50d902SRodney W. GrimesD=.depend # default dependency file is .depend 389b50d902SRodney W. Grimesappend=0 39905a01acSDavid E. O'Briennosyshdrs=0 409b50d902SRodney W. Grimespflag= 419b50d902SRodney W. Grimes 429b50d902SRodney W. Grimeswhile : 439b50d902SRodney W. Grimes do case "$1" in 449b50d902SRodney W. Grimes # -a appends to the depend file 459b50d902SRodney W. Grimes -a) 469b50d902SRodney W. Grimes append=1 479b50d902SRodney W. Grimes shift ;; 489b50d902SRodney W. Grimes 499b50d902SRodney W. Grimes # -f allows you to select a makefile name 509b50d902SRodney W. Grimes -f) 519b50d902SRodney W. Grimes D=$2 529b50d902SRodney W. Grimes shift; shift ;; 539b50d902SRodney W. Grimes 54905a01acSDavid E. O'Brien # -n does not make dependencies on system headers 55905a01acSDavid E. O'Brien -n) 56905a01acSDavid E. O'Brien nosyshdrs=1 57905a01acSDavid E. O'Brien shift ;; 58905a01acSDavid E. O'Brien 599b50d902SRodney W. Grimes # the -p flag produces "program: program.c" style dependencies 609b50d902SRodney W. Grimes # so .o's don't get produced 619b50d902SRodney W. Grimes -p) 629b50d902SRodney W. Grimes pflag=p 639b50d902SRodney W. Grimes shift ;; 649b50d902SRodney W. Grimes *) 659b50d902SRodney W. Grimes break ;; 669b50d902SRodney W. Grimes esac 679b50d902SRodney W. Grimesdone 689b50d902SRodney W. Grimes 694c3dfdc3SWolfram Schneidercase $# in 0) 7030c218bfSBruce Evans echo 'usage: mkdep [-ap] [-f file] [flags] file ...' >&2 714c3dfdc3SWolfram Schneider exit 1;; 724c3dfdc3SWolfram Schneideresac 739b50d902SRodney W. Grimes 747f6f2e94SWolfram SchneiderTMP=_mkdep$$ 759a4902a9SMartin Cracauertrap 'rm -f $TMP ; trap 2 ; kill -2 $$' 1 2 3 13 15 764a90dcebSWolfram Schneidertrap 'rm -f $TMP' 0 779b50d902SRodney W. Grimes 78207a4c99SBruce Evans# For C sources, mkdep must use exactly the same cpp and predefined flags 79207a4c99SBruce Evans# as the compiler would. This is easily arranged by letting the compiler 80207a4c99SBruce Evans# pick the cpp. mkdep must be told the cpp to use for exceptional cases. 81207a4c99SBruce EvansMKDEP_CPP=${MKDEP_CPP-"cc -E"} 82207a4c99SBruce Evans 83905a01acSDavid E. O'Briencase $append in 84905a01acSDavid E. O'Brien 0) CC_MKDEP_OPT="-M";; 85905a01acSDavid E. O'Brien *) CC_MKDEP_OPT="-MM -w";; 86905a01acSDavid E. O'Brienesac 87905a01acSDavid E. O'Brien 884a90dcebSWolfram Schneiderecho "# $@" > $TMP # store arguments for debugging 894a90dcebSWolfram Schneider 90905a01acSDavid E. O'Brienif $MKDEP_CPP $CC_MKDEP_OPT "$@" >> $TMP; then : 919b50d902SRodney W. Grimeselse 9230c218bfSBruce Evans echo 'mkdep: compile failed' >&2 939b50d902SRodney W. Grimes exit 1 949b50d902SRodney W. Grimesfi 959b50d902SRodney W. Grimes 964c3dfdc3SWolfram Schneidercase x$pflag in 974c3dfdc3SWolfram Schneider x) case $append in 984c3dfdc3SWolfram Schneider 0) sed -e 's; \./; ;g' < $TMP > $D;; 994c3dfdc3SWolfram Schneider *) sed -e 's; \./; ;g' < $TMP >> $D;; 1004c3dfdc3SWolfram Schneider esac 1014c3dfdc3SWolfram Schneider ;; 1024c3dfdc3SWolfram Schneider *) case $append in 1034c3dfdc3SWolfram Schneider 0) sed -e 's;\.o:;:;' -e 's; \./; ;g' < $TMP > $D;; 1044c3dfdc3SWolfram Schneider *) sed -e 's;\.o:;:;' -e 's; \./; ;g' < $TMP >> $D;; 1054c3dfdc3SWolfram Schneider esac 1064c3dfdc3SWolfram Schneider ;; 1074c3dfdc3SWolfram Schneideresac 1084c3dfdc3SWolfram Schneider 1094a90dcebSWolfram Schneiderexit $? 110