[comp.unix.programmer] makedepend for C++?

tim@cs.columbia.edu (Timothy Jones) (11/26/90)

Does anyone know if there's a version of makedepend(1) for UNIX that knows how
to deal with C++?

Thanks,
Tim
--
Timothy Jones					 tim@cs.columbia.edu (internet)
Department of Computer Science		   ...!rutgers!columbia!cs!tim (usenet)
Columbia University					  tim%cs@cuvmb (bitnet)

davidm@uunet.UU.NET (David S. Masterson) (11/29/90)

>>>>> On 26 Nov 90 05:00:13 GMT, tim@cs.columbia.edu (Timothy Jones) said:

Timothy> Does anyone know if there's a version of makedepend(1) for UNIX that
Timothy> knows how to deal with C++?

Why won't the one that deals with C work (its just a search for #include in
both cases, isn't it)?
--
====================================================================
David Masterson					Consilium, Inc.
(415) 691-6311					640 Clyde Ct.
uunet!cimshop!davidm				Mtn. View, CA  94043
====================================================================
"If someone thinks they know what I said, then I didn't say it!"

marc@dumbcat.sf.ca.us (Marco S Hyman) (11/30/90)

In article <TIM.90Nov26000013@liberty.cs.columbia.edu> 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

tim@cs.columbia.edu (Timothy Jones) (12/01/90)

   Timothy> Does anyone know if there's a version of makedepend(1) for UNIX that
   Timothy> knows how to deal with C++?

   Why won't the one that deals with C work (its just a search for #include in
   both cases, isn't it)?

Specifically, I'm using g++, and the problem is that I get lots of
'unknown directive == "#elif defined..."' error messages, presumably
caused by included files within my source file.  Perhaps I just have an
old version of makedepend which doesn't understand "elif" for some
reason.

Running g++ -M does the trick, but I can't use it to parse other source
language files, like lex or yacc.  I guess I can use the regular
makedepend for that and combine the results of the two programs
(sigh)...

Tim