1*36038Sbostic#!/bin/sh - 2*36038Sbostic# 3*36038Sbostic# Copyright (c) 1988 The Regents of the University of California. 4*36038Sbostic# All rights reserved. 5*36038Sbostic# 6*36038Sbostic# Redistribution and use in source and binary forms are permitted 7*36038Sbostic# provided that the above copyright notice and this paragraph are 8*36038Sbostic# duplicated in all such forms and that any documentation, 9*36038Sbostic# advertising materials, and other materials related to such 10*36038Sbostic# distribution and use acknowledge that the software was developed 11*36038Sbostic# by the University of California, Berkeley. The name of the 12*36038Sbostic# University may not be used to endorse or promote products derived 13*36038Sbostic# from this software without specific prior written permission. 14*36038Sbostic# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 15*36038Sbostic# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 16*36038Sbostic# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17*36038Sbostic# 18*36038Sbostic# @(#)mkdep.old.compiler 5.1 (Berkeley) 10/22/88 19*36038Sbostic# 20*36038Sbostic 21*36038Sbostic# This is a version of mkdep that works pretty well 22*36038Sbostic# with compilers that don't have -M. 23*36038Sbostic 24*36038SbosticPATH=/bin:/usr/bin:/usr/ucb:/lib:/usr/lib 25*36038Sbostic 26*36038SbosticINCL= 27*36038SbosticD=.depend 28*36038Sbosticwhile : 29*36038Sbostic do case "$1" in 30*36038Sbostic # -f allows you to select a makefile name 31*36038Sbostic -f) 32*36038Sbostic D=$2 33*36038Sbostic shift; shift ;; 34*36038Sbostic # the -p flag produces "program: program.c" style dependencies 35*36038Sbostic # so .o's don't get produced 36*36038Sbostic -p) 37*36038Sbostic SED='s;\.o;;' 38*36038Sbostic shift ;; 39*36038Sbostic *) 40*36038Sbostic break ;; 41*36038Sbostic esac 42*36038Sbosticdone 43*36038Sbostic 44*36038Sbosticif [ $# = 0 ] ; then 45*36038Sbostic echo 'usage: mkdep [-f depend_file] [cc_flags] file ...' 46*36038Sbostic exit 1 47*36038Sbosticfi 48*36038Sbostic 49*36038SbosticTMP=/tmp/mkdep$$ 50*36038Sbostictrap 'rm -f $TMP ; exit 1' 1 2 3 13 15 51*36038Sbostic 52*36038Sbosticfor i do 53*36038Sbostic case "$i" in 54*36038Sbostic -c|-M) 55*36038Sbostic ;; 56*36038Sbostic -I*) 57*36038Sbostic INCL="$INCL $i";; 58*36038Sbostic -D*|-O|-U*) 59*36038Sbostic FLAGS="$FLAGS $i";; 60*36038Sbostic *) 61*36038Sbostic # assume source file 62*36038Sbostic # put '$dep' in front of dependencies 63*36038Sbostic dep=`echo "$i" | sed -e 's,/,\\\\/,g' -e 's/\.c$/.o/'` 64*36038Sbostic 65*36038Sbostic # Find includes, remove leading numerics, remove ./, 66*36038Sbostic # remove double quotes, and remove trailing numerics. 67*36038Sbostic # Sort that, discarding duplicates, and add '$dep'. 68*36038Sbostic cpp $INCL $FLAGS "$i" | sed -e ' 69*36038Sbostic /^#/!d 70*36038Sbostic s/# [0-9]* // 71*36038Sbostic s,"./,", 72*36038Sbostic s/"\(.*\)"/\1/ 73*36038Sbostic s/ [ 0-9]*$//' | 74*36038Sbostic sort -u | sed -e "s/^/$dep: /";; 75*36038Sbostic esac 76*36038Sbosticdone | 77*36038Sbosticsed " 78*36038Sbostic s; \./; ;g 79*36038Sbostic /\.c:$/d 80*36038Sbostic $SED" | 81*36038Sbosticawk '{ 82*36038Sbostic if ($1 != prev) { 83*36038Sbostic if (rec != "") 84*36038Sbostic print rec; 85*36038Sbostic rec = $0; 86*36038Sbostic prev = $1; 87*36038Sbostic } 88*36038Sbostic else { 89*36038Sbostic if (length(rec $2) > 78) { 90*36038Sbostic print rec; 91*36038Sbostic rec = $0; 92*36038Sbostic } 93*36038Sbostic else 94*36038Sbostic rec = rec " " $2 95*36038Sbostic } 96*36038Sbostic} 97*36038SbosticEND { 98*36038Sbostic print rec 99*36038Sbostic}' > $TMP 100*36038Sbostic 101*36038Sbosticmv $TMP $D 102*36038Sbosticexit 0 103