Make dependencies and nested include files

gregg.g.wonderly gregg at cbnewsc.ATT.COM
Fri Oct 13 05:56:15 AEST 1989


>From article <10115 at encore.Encore.COM>, by corbin at maxzilla.Encore.COM:
> Does anyone have such a tool/script that would take a list of files
> and generate dependencies or any ideas on how to solve the problem?

An easy way to do this is to make use of "cc -E" to get the listing with
the filenames on the "# line" lines.  Through the use of the following
pipe line of commands, you can get the names of all of the files that a
file includes without having to do recursive greps.

	defs="all -Dthis and -Dthat required"
	ifiles="all -Idir1 -Idir2 required"
	file="input .c file"

	cc -E $defs $ifiles $file | \
		grep '^#' | \
		sed '/^#ident/d' | 
		sed "1,\$s/^[^\"]*\"//;s/\"\$//;/`basename $file`/d;/y.tab.c/d" | \
		sort -u

The output will be the absolute path names and relative path names of
ALL included files relative to the current directory and/or the -I
directory names (relative or absolute).  "cc -E" works on most UN*Xs,
if it doesn't on yours, you will need to find an alternative way.  This
has worked for me for quite some time...

-- 
-----
gregg.g.wonderly at att.com   (AT&T bell laboratories)



More information about the Comp.unix.questions mailing list