Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!xylogics!loverso From: loverso@Xylogics.COM (John Robert LoVerso) Newsgroups: comp.sys.encore Subject: Re: mkdep Message-ID: <9271@xenna.Xylogics.COM> Date: 11 Jun 90 23:04:56 GMT References: <9006082143.AA04309@cs.niu.edu> Reply-To: loverso@Xylogics.COM (John Robert LoVerso) Organization: Xylogics, Inc., Burlington MA Lines: 171 Here's a "mkdep" that uses "apply" to run the dependencies in parallel. Under UMAX4.2, you must have a copy of the 4.3BSD "cpp" around to get "cpp -M"; under UMAX4.3 you can just use "cc -M". Actually, under UMAX4.3, you should *really* not "make depend" at all, but "cc -MD". This is a clever hack which compiles the file *and* builds dependencies (into .d files). You then add the following line to the end of the link-command: cat *.d > .depends Unfortuneately, UMAX4.3 "make" has not picked up the post-tahoe feature of automatically reading a ".depends" file for dependencies. You have to explicitly use: make -f Makefile -f .depends The advantage to "-MD" is that you don't have to do two passes, and on a huge source tree (like for the Annex) this is a big win. John -- #!/bin/sh - # # Mods by John Robert LoVerso: # Added "-s" to suppress system (/usr/include) dependencies. # Modified 8/88 to work in parallel via apply. # Modified 6/90 to only output one dependency tag. # $Id: mkdep,v 2.3 90/06/11 19:01:35 loverso Rel $ # # Copyright (c) 1987 Regents of the University of California. # All rights reserved. # # Redistribution and use in source and binary forms are permitted # provided that the above copyright notice and this paragraph are # duplicated in all such forms and that any documentation, # advertising materials, and other materials related to such # distribution and use acknowledge that the software was developed # by the University of California, Berkeley. The name of the # University may not be used to endorse or promote products derived # from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # @(#)mkdep.sh 5.12 (Berkeley) 6/30/88 # #PATH=/bin:/usr/bin:/usr/ucb #export PATH MAKE=Makefile # default makefile name is "Makefile" MAKEDEP='for i do $cpp -M $i; done' cpp=cpp # for apply SHELL=/bin/sh; export SHELL # use `cc -M' or `cpp -M' #MAKEDEP='cc -M $OTHERARGS $*' MAKEDEP='for i do $cpp -M $OTHERARGS $i; done' OTHERARGS= while : do case "$1" in # -f allows you to select a makefile name -f) MAKE=$2 shift; shift ;; # the -p flag produces "program: program.c" style dependencies # so .o's don't get produced -p) SED='s;\.o;;' shift ;; # -s disregards system dependencies (i.e., /usr/include) -s) SYSSED='/\/usr\/include/d' shift ;; # set PARALLEL -#*) PARALLEL=`echo $1 | sed -e 's/-#//'` export PARALLEL shift ;; -*) OTHERARGS="$OTHERARGS $1" shift ;; *) break ;; esac done if [ $# = 0 ] ; then echo 'usage: mkdep [-sp] [-#n] [-f makefile] [flags] file ...' exit 1 fi if [ ! -w $MAKE ]; then echo "mkdep: no writeable file \"$MAKE\"" exit 1 fi # Use apply for parallelism if [ ${PARALLEL-1} -gt 1 ]; then MAKEDEP="apply '$cpp -M $OTHERARGS' \$*" # this should take less overhead, but might finish asymetrically #MAKEDEP="apply -h 'cc -M $OTHERARGS' \$*" fi TMP=/tmp/mkdep$$ trap 'rm -f $TMP ; exit 1' 1 2 3 13 15 cp $MAKE ${MAKE}.bak sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP cat << _EOF_ >> $TMP # DO NOT DELETE THIS LINE -- mkdep uses it. # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. _EOF_ # If your compiler doesn't have -M, add it. # If it doesn't, try the 4.3BSD or GNU cpp (with -M). # If you can't do that, the next two # lines will try and replace the "cc -M". The real problem is that this # hack can't deal with anything that requires a search path, and doesn't # even try for anything using bracket (<>) syntax. # # egrep '^#include[ ]*".*"' /dev/null $* | # sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' | eval $MAKEDEP | sed " s; \./; ;g :loop s;\.\./[^ /]*/\.\.;..;g t loop $SED $SYSSED" | sort -u | awk '{ if ($1 != prev) { if (rec != "") print rec; rec = $0; prev = $1; } else { # use `> 78', `print rec;' and `rec = $0;' for old-style if (length(rec $2) > 76) { print rec " \\"; rec = " " $2; } else rec = rec " " $2 } } END { print rec }' >> $TMP cat << _EOF_ >> $TMP # IF YOU PUT ANYTHING HERE IT WILL GO AWAY _EOF_ # copy to preserve permissions cp $TMP $MAKE rm -f ${MAKE}.bak $TMP exit 0