147965Sbostic#!/bin/sh - 247965Sbostic# 3*62117Sbostic# Copyright (c) 1991, 1993 4*62117Sbostic# The Regents of the University of California. All rights reserved. 547965Sbostic# 647966Sbostic# %sccs.include.redist.sh% 747965Sbostic# 8*62117Sbostic# @(#)mkdep.gcc.sh 8.1 (Berkeley) 06/06/93 947965Sbostic# 1047966Sbostic 1147965SbosticPATH=/bin:/usr/bin:/usr/ucb 1247965Sbosticexport PATH 1347965Sbostic 1447965SbosticD=.depend # default dependency file is .depend 1547965Sbosticappend=0 1657707Sbosticpflag= 1747965Sbostic 1847965Sbosticwhile : 1947965Sbostic do case "$1" in 2047965Sbostic # -a appends to the depend file 2147965Sbostic -a) 2247965Sbostic append=1 2347965Sbostic shift ;; 2447965Sbostic 2547965Sbostic # -f allows you to select a makefile name 2647965Sbostic -f) 2747965Sbostic D=$2 2847965Sbostic shift; shift ;; 2947965Sbostic 3047965Sbostic # the -p flag produces "program: program.c" style dependencies 3147965Sbostic # so .o's don't get produced 3247965Sbostic -p) 3357707Sbostic pflag=p 3447965Sbostic shift ;; 3547965Sbostic *) 3647965Sbostic break ;; 3747965Sbostic esac 3847965Sbosticdone 3947965Sbostic 4047965Sbosticif [ $# = 0 ] ; then 4147965Sbostic echo 'usage: mkdep [-p] [-f depend_file] [cc_flags] file ...' 4247965Sbostic exit 1 4347965Sbosticfi 4447965Sbostic 4547965SbosticTMP=/tmp/mkdep$$ 4647965Sbostic 4747965Sbostictrap 'rm -f $TMP ; exit 1' 1 2 3 13 15 4847965Sbostic 4957707Sbosticif [ x$pflag = x ]; then 5057707Sbostic cpp -M $* | sed -e 's; \./; ;g' > $TMP 5157707Sbosticelse 5257707Sbostic cpp -M $* | sed -e 's;\.o :; :;' -e 's; \./; ;g' > $TMP 5357707Sbosticfi 5447965Sbostic 5547965Sbosticif [ $? != 0 ]; then 5647965Sbostic echo 'mkdep: compile failed.' 5747965Sbostic rm -f $TMP 5847965Sbostic exit 1 5947965Sbosticfi 6047965Sbostic 6147965Sbosticif [ $append = 1 ]; then 6247965Sbostic cat $TMP >> $D 6347965Sbostic rm -f $TMP 6447965Sbosticelse 6547965Sbostic mv $TMP $D 6647965Sbosticfi 6747965Sbosticexit 0 68