11590Srgrimes#!/bin/sh - 21590Srgrimes# 31590Srgrimes# Copyright (c) 1991, 1993 41590Srgrimes# The Regents of the University of California. All rights reserved. 51590Srgrimes# 61590Srgrimes# Redistribution and use in source and binary forms, with or without 71590Srgrimes# modification, are permitted provided that the following conditions 81590Srgrimes# are met: 91590Srgrimes# 1. Redistributions of source code must retain the above copyright 101590Srgrimes# notice, this list of conditions and the following disclaimer. 111590Srgrimes# 2. Redistributions in binary form must reproduce the above copyright 121590Srgrimes# notice, this list of conditions and the following disclaimer in the 131590Srgrimes# documentation and/or other materials provided with the distribution. 141590Srgrimes# 4. Neither the name of the University nor the names of its contributors 151590Srgrimes# may be used to endorse or promote products derived from this software 161590Srgrimes# without specific prior written permission. 171590Srgrimes# 181590Srgrimes# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 191590Srgrimes# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 201590Srgrimes# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 211590Srgrimes# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 221590Srgrimes# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 231590Srgrimes# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 241590Srgrimes# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 251590Srgrimes# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 261590Srgrimes# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 271590Srgrimes# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 281590Srgrimes# SUCH DAMAGE. 291590Srgrimes# 301590Srgrimes# @(#)mkdep.gcc.sh 8.1 (Berkeley) 6/6/93 3150477Speter# $FreeBSD: releng/10.3/usr.bin/mkdep/mkdep.gcc.sh 216370 2010-12-11 08:32:16Z joel $ 321590Srgrimes 331590SrgrimesD=.depend # default dependency file is .depend 341590Srgrimesappend=0 351590Srgrimespflag= 361590Srgrimes 371590Srgrimeswhile : 381590Srgrimes do case "$1" in 391590Srgrimes # -a appends to the depend file 401590Srgrimes -a) 411590Srgrimes append=1 421590Srgrimes shift ;; 431590Srgrimes 441590Srgrimes # -f allows you to select a makefile name 451590Srgrimes -f) 461590Srgrimes D=$2 471590Srgrimes shift; shift ;; 481590Srgrimes 491590Srgrimes # the -p flag produces "program: program.c" style dependencies 501590Srgrimes # so .o's don't get produced 511590Srgrimes -p) 521590Srgrimes pflag=p 531590Srgrimes shift ;; 541590Srgrimes *) 551590Srgrimes break ;; 561590Srgrimes esac 571590Srgrimesdone 581590Srgrimes 5915060Swoschcase $# in 0) 6022641Sbde echo 'usage: mkdep [-ap] [-f file] [flags] file ...' >&2 6115060Swosch exit 1;; 6215060Swoschesac 631590Srgrimes 6422024SwoschTMP=_mkdep$$ 6538520Scracauertrap 'rm -f $TMP ; trap 2 ; kill -2 $$' 1 2 3 13 15 6619208Swoschtrap 'rm -f $TMP' 0 671590Srgrimes 682406Sbde# For C sources, mkdep must use exactly the same cpp and predefined flags 692406Sbde# as the compiler would. This is easily arranged by letting the compiler 702406Sbde# pick the cpp. mkdep must be told the cpp to use for exceptional cases. 7139123SobrienCC=${CC-"cc"} 7239123SobrienMKDEP_CPP=${MKDEP_CPP-"${CC} -E"} 7339123SobrienMKDEP_CPP_OPTS=${MKDEP_CPP_OPTS-"-M"}; 742406Sbde 7519208Swoschecho "# $@" > $TMP # store arguments for debugging 7619208Swosch 7739123Sobrienif $MKDEP_CPP $MKDEP_CPP_OPTS "$@" >> $TMP; then : 781590Srgrimeselse 7922641Sbde echo 'mkdep: compile failed' >&2 801590Srgrimes exit 1 811590Srgrimesfi 821590Srgrimes 8315060Swoschcase x$pflag in 8415060Swosch x) case $append in 8515060Swosch 0) sed -e 's; \./; ;g' < $TMP > $D;; 8615060Swosch *) sed -e 's; \./; ;g' < $TMP >> $D;; 8715060Swosch esac 8815060Swosch ;; 8915060Swosch *) case $append in 9015060Swosch 0) sed -e 's;\.o:;:;' -e 's; \./; ;g' < $TMP > $D;; 9115060Swosch *) sed -e 's;\.o:;:;' -e 's; \./; ;g' < $TMP >> $D;; 9215060Swosch esac 9315060Swosch ;; 9415060Swoschesac 9515060Swosch 9619208Swoschexit $? 97