1*47965Sbostic#!/bin/sh - 2*47965Sbostic# 3*47965Sbostic# Copyright (c) 1987 Regents of the University of California. 4*47965Sbostic# All rights reserved. 5*47965Sbostic# 6*47965Sbostic# Redistribution and use in source and binary forms are permitted 7*47965Sbostic# provided that the above copyright notice and this paragraph are 8*47965Sbostic# duplicated in all such forms and that any documentation, 9*47965Sbostic# advertising materials, and other materials related to such 10*47965Sbostic# distribution and use acknowledge that the software was developed 11*47965Sbostic# by the University of California, Berkeley. The name of the 12*47965Sbostic# University may not be used to endorse or promote products derived 13*47965Sbostic# from this software without specific prior written permission. 14*47965Sbostic# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 15*47965Sbostic# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 16*47965Sbostic# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17*47965Sbostic# 18*47965Sbostic# @(#)mkdep.sh 5.18 (Berkeley) 3/5/89 19*47965Sbostic# 20*47965SbosticPATH=/bin:/usr/bin:/usr/ucb 21*47965Sbosticexport PATH 22*47965Sbostic 23*47965SbosticD=.depend # default dependency file is .depend 24*47965Sbosticappend=0 25*47965Sbostic 26*47965Sbosticwhile : 27*47965Sbostic do case "$1" in 28*47965Sbostic # -a appends to the depend file 29*47965Sbostic -a) 30*47965Sbostic append=1 31*47965Sbostic shift ;; 32*47965Sbostic 33*47965Sbostic # -f allows you to select a makefile name 34*47965Sbostic -f) 35*47965Sbostic D=$2 36*47965Sbostic shift; shift ;; 37*47965Sbostic 38*47965Sbostic # the -p flag produces "program: program.c" style dependencies 39*47965Sbostic # so .o's don't get produced 40*47965Sbostic -p) 41*47965Sbostic SED='s;\.o;;' 42*47965Sbostic shift ;; 43*47965Sbostic -*) 44*47965Sbostic shift ;; 45*47965Sbostic *) 46*47965Sbostic break ;; 47*47965Sbostic esac 48*47965Sbosticdone 49*47965Sbostic 50*47965Sbosticif [ $# = 0 ] ; then 51*47965Sbostic echo 'usage: mkdep [-p] [-f depend_file] [cc_flags] file ...' 52*47965Sbostic exit 1 53*47965Sbosticfi 54*47965Sbostic 55*47965SbosticTMP=/tmp/mkdep$$ 56*47965Sbostic 57*47965Sbostictrap 'rm -f $TMP ; exit 1' 1 2 3 13 15 58*47965Sbostic 59*47965Sbosticcpp -M $* > $TMP 60*47965Sbostic 61*47965Sbosticif [ $? != 0 ]; then 62*47965Sbostic echo 'mkdep: compile failed.' 63*47965Sbostic rm -f $TMP 64*47965Sbostic exit 1 65*47965Sbosticfi 66*47965Sbostic 67*47965Sbosticif [ $append = 1 ]; then 68*47965Sbostic cat $TMP >> $D 69*47965Sbostic rm -f $TMP 70*47965Sbosticelse 71*47965Sbostic mv $TMP $D 72*47965Sbosticfi 73*47965Sbosticexit 0 74