1#!/bin/sh - 2# 3# Copyright (c) 1991 The Regents of the University of California. 4# All rights reserved. 5# 6# %sccs.include.redist.sh% 7# 8# @(#)mkdep.gcc.sh 5.5 (Berkeley) 12/01/92 9# 10 11PATH=/bin:/usr/bin:/usr/ucb 12export PATH 13 14D=.depend # default dependency file is .depend 15append=0 16RM_DOT_O= 17 18while : 19 do case "$1" in 20 # -a appends to the depend file 21 -a) 22 append=1 23 shift ;; 24 25 # -f allows you to select a makefile name 26 -f) 27 D=$2 28 shift; shift ;; 29 30 # the -p flag produces "program: program.c" style dependencies 31 # so .o's don't get produced 32 -p) 33 RM_DOT_O="-e 's;\.o :; :;'" 34 shift ;; 35 *) 36 break ;; 37 esac 38done 39 40if [ $# = 0 ] ; then 41 echo 'usage: mkdep [-p] [-f depend_file] [cc_flags] file ...' 42 exit 1 43fi 44 45TMP=/tmp/mkdep$$ 46 47trap 'rm -f $TMP ; exit 1' 1 2 3 13 15 48 49cpp -M $* | sed $RM_DOT_O -e 's; \./; ;g' > $TMP 50 51if [ $? != 0 ]; then 52 echo 'mkdep: compile failed.' 53 rm -f $TMP 54 exit 1 55fi 56 57if [ $append = 1 ]; then 58 cat $TMP >> $D 59 rm -f $TMP 60else 61 mv $TMP $D 62fi 63exit 0 64