Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!ucsd!ucbvax!CS.NIU.EDU!rickert From: rickert@CS.NIU.EDU (Neil Rickert) Newsgroups: comp.sys.encore Subject: mkdep Message-ID: <9006082143.AA04309@cs.niu.edu> Date: 8 Jun 90 21:43:13 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 169 Its really great to have an 'mkdep' with Umax 4.3 To test it, I 'cd'ed to a source directory and entered 'make depend' Sure enough, it compiled all of my source code, and removed all of the dependencies from Makefile. We really shouldn't need to do it this way, but here's a 'mkdep' that seems to work: (I used to use this with Umax 4.2). #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'mkdep' <<'END_OF_FILE' X#!/bin/sh - X# X# Copyright (c) 1988 The Regents of the University of California. X# All rights reserved. X# X# Redistribution and use in source and binary forms are permitted X# provided that the above copyright notice and this paragraph are X# duplicated in all such forms and that any documentation, X# advertising materials, and other materials related to such X# distribution and use acknowledge that the software was developed X# by the University of California, Berkeley. The name of the X# University may not be used to endorse or promote products derived X# from this software without specific prior written permission. X# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR X# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED X# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. X# X# @(#)mkdep.sh.old.compiler 5.2 (Berkeley) 10/24/88 X# X X# This is a version of mkdep that works pretty well X# with compilers that don't have -M. X X# Modified by Neil Rickert, Feb 1990, so X# that it seems to work on Umax 4.2, and supports the X# make [-f Makefile.name] depend X# format in recent Makefiles. X# X PATH=/bin:/usr/bin:/usr/ucb:/lib:/usr/lib X MAKE=Makefile # default makefile name is "Makefile" X INCL= X while : X do case "$1" in X # -f allows you to select a makefile name X -f) X MAKE=$2 X shift; shift ;; X X # the -p flag produces "program: program.c" style dependencies X # so .o's don't get produced X -p) X SED='s;\.o;;' X shift ;; X *) X break ;; X esac done X if [ $# = 0 ] ; then X echo 'usage: mkdep [-f depend_file] [cc_flags] file ...' X exit 1 fi X if [ ! -w $MAKE ]; then X echo "mkdep: no writeable file \"$MAKE\"" X exit 1 fi X TMP=/tmp/mkdep$$ trap 'rm -f $TMP ; exit 1' 1 2 3 13 15 X cp $MAKE ${MAKE}.bak X sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP X cat << _EOF_ >> $TMP X# DO NOT DELETE THIS LINE -- mkdep uses it. X# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. X X_EOF_ X for i do X case "$i" in X -c|-M) X ;; X -I*) X INCL="$INCL $i";; X -D*|-O|-U*) X FLAGS="$FLAGS $i";; X *) X # assume source file X # put '$dep' in front of dependencies X dep=`echo "$i" | sed -e 's,/,\\\\/,g' -e 's/\.c$/.o/'` X X # Find includes, remove leading numerics, remove ./, X # remove double quotes, and remove trailing numerics. X # Sort that, discarding duplicates, and add '$dep'. X cc -E $INCL $FLAGS "$i" | sed -e ' X /^#/!d X s/# [0-9]* // X s,"./,", X s/"\(.*\)"/\1/ X s/ [ 0-9]*$//' | X sort -u | sed -e "s/^/$dep: /";; X esac done | sed " X s; \./; ;g X /\.c:$/d X $SED" | awk '{ X if ($1 != prev) { X if (rec != "") X print rec; X rec = $0; X prev = $1; X } X else { X if (length(rec $2) > 78) { X print rec; X rec = $0; X } X else X rec = rec " " $2 X } X} XEND { X print rec X}' >> $TMP X cat << _EOF_ >> $TMP X X# IF YOU PUT ANYTHING HERE IT WILL GO AWAY X_EOF_ X X# copy to preserve permissions cp $TMP $MAKE rm -f ${MAKE}.bak $TMP exit 0 END_OF_FILE if test 2902 -ne `wc -c <'mkdep'`; then echo shar: \"'mkdep'\" unpacked with wrong size! fi chmod +x 'mkdep' # end of 'mkdep' fi echo shar: End of shell archive. exit 0