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 354a90dcebSWolfram Schneider# $Id$ 369b50d902SRodney W. Grimes 374c3dfdc3SWolfram SchneiderPATH=/bin:/usr/bin; export PATH 389b50d902SRodney W. Grimes 399b50d902SRodney W. GrimesD=.depend # default dependency file is .depend 409b50d902SRodney W. Grimesappend=0 419b50d902SRodney W. Grimespflag= 429b50d902SRodney W. Grimes 439b50d902SRodney W. Grimeswhile : 449b50d902SRodney W. Grimes do case "$1" in 459b50d902SRodney W. Grimes # -a appends to the depend file 469b50d902SRodney W. Grimes -a) 479b50d902SRodney W. Grimes append=1 489b50d902SRodney W. Grimes shift ;; 499b50d902SRodney W. Grimes 509b50d902SRodney W. Grimes # -f allows you to select a makefile name 519b50d902SRodney W. Grimes -f) 529b50d902SRodney W. Grimes D=$2 539b50d902SRodney W. Grimes shift; shift ;; 549b50d902SRodney W. Grimes 559b50d902SRodney W. Grimes # the -p flag produces "program: program.c" style dependencies 569b50d902SRodney W. Grimes # so .o's don't get produced 579b50d902SRodney W. Grimes -p) 589b50d902SRodney W. Grimes pflag=p 599b50d902SRodney W. Grimes shift ;; 609b50d902SRodney W. Grimes *) 619b50d902SRodney W. Grimes break ;; 629b50d902SRodney W. Grimes esac 639b50d902SRodney W. Grimesdone 649b50d902SRodney W. Grimes 654c3dfdc3SWolfram Schneidercase $# in 0) 669b50d902SRodney W. Grimes echo 'usage: mkdep [-p] [-f depend_file] [cc_flags] file ...' 674c3dfdc3SWolfram Schneider exit 1;; 684c3dfdc3SWolfram Schneideresac 699b50d902SRodney W. Grimes 709b50d902SRodney W. GrimesTMP=/tmp/mkdep$$ 719b50d902SRodney W. Grimestrap 'rm -f $TMP ; exit 1' 1 2 3 13 15 724a90dcebSWolfram Schneidertrap 'rm -f $TMP' 0 739b50d902SRodney W. Grimes 74207a4c99SBruce Evans# For C sources, mkdep must use exactly the same cpp and predefined flags 75207a4c99SBruce Evans# as the compiler would. This is easily arranged by letting the compiler 76207a4c99SBruce Evans# pick the cpp. mkdep must be told the cpp to use for exceptional cases. 77207a4c99SBruce EvansMKDEP_CPP=${MKDEP_CPP-"cc -E"} 78207a4c99SBruce Evans 794a90dcebSWolfram Schneiderecho "# $@" > $TMP # store arguments for debugging 804a90dcebSWolfram Schneider 814a90dcebSWolfram Schneiderif $MKDEP_CPP -M "$@" >> $TMP; then : 829b50d902SRodney W. Grimeselse 839b50d902SRodney W. Grimes echo 'mkdep: compile failed.' 849b50d902SRodney W. Grimes exit 1 859b50d902SRodney W. Grimesfi 869b50d902SRodney W. Grimes 874c3dfdc3SWolfram Schneidercase x$pflag in 884c3dfdc3SWolfram Schneider x) case $append in 894c3dfdc3SWolfram Schneider 0) sed -e 's; \./; ;g' < $TMP > $D;; 904c3dfdc3SWolfram Schneider *) sed -e 's; \./; ;g' < $TMP >> $D;; 914c3dfdc3SWolfram Schneider esac 924c3dfdc3SWolfram Schneider ;; 934c3dfdc3SWolfram Schneider *) case $append in 944c3dfdc3SWolfram Schneider 0) sed -e 's;\.o:;:;' -e 's; \./; ;g' < $TMP > $D;; 954c3dfdc3SWolfram Schneider *) sed -e 's;\.o:;:;' -e 's; \./; ;g' < $TMP >> $D;; 964c3dfdc3SWolfram Schneider esac 974c3dfdc3SWolfram Schneider ;; 984c3dfdc3SWolfram Schneideresac 994c3dfdc3SWolfram Schneider 1004a90dcebSWolfram Schneiderexit $? 101