Xref: utzoo comp.lang.c++:10618 comp.unix.programmer:596 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!noose.ecn.purdue.edu!sparkyfs.erg.sri.com!hercules!fernwood!dumbcat!marc From: marc@dumbcat.sf.ca.us (Marco S Hyman) Newsgroups: comp.lang.c++,comp.unix.programmer Subject: Re: makedepend for C++? Message-ID: <258@dumbcat.sf.ca.us> Date: 30 Nov 90 05:43:49 GMT References: Followup-To: comp.lang.c++ Organization: MH Software, Hayward, Ca. Lines: 55 In article tim@cs.columbia.edu writes: Does anyone know if there's a version of makedepend(1) for UNIX that knows how to deal with C++? Don't know if this is close to makedepend(1) (it's not on any machine that I use) but this script works fine for me. #! /bin/sh # @(#) $Id: mkdep,v 1.4 90/05/09 20:19:19 marc Exp $ # # Make C++ dependencies. This script depends upon the -H option built # into cpp in System V unix. Note: some CC shell scripts do not process # -H properly, i.e. they do not pass it to cpp. If this happens you will # see an error message from patch or munch. If this happens edit your CC # script to pass -H to cpp. # # BSD users can try the -M option to cpp and then modify the script to parse # -M output. The Sun cpp will process the -H option and the script might # work as is. CC=${CC-CC} # use CC unless ${CC} set in environment # process all files on the command line. Abort if no files passed if [ "$1" = "" ]; then exit 1 fi for file do ${CC} -E -H $file 2>&1 >/dev/null | grep '^\./' | sed "s;^\./;$file: ;" done | sort | uniq | sed 's/\(.*\)\.cc: \(.*\)/\1.o: \2/' | awk ' { if ($1 != prev) { print rec; rec = $0; prev = $1 } else { if (length(rec $2) > 72) { print rec; rec = $0 } else { rec = rec " " $2 } } } END { print rec } ' // marc -- // marc@dumbcat.sf.ca.us // {ames,decwrl,sun}!pacbell!dumbcat!marc