Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!att!cbnewsc!gregg From: gregg@cbnewsc.ATT.COM (gregg.g.wonderly) Newsgroups: comp.unix.questions Subject: Re: Make dependencies and nested include files Message-ID: <3857@cbnewsc.ATT.COM> Date: 12 Oct 89 19:56:15 GMT References: <10115@encore.Encore.COM> Organization: AT&T Bell Laboratories Lines: 28 From article <10115@encore.Encore.COM>, by corbin@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@att.com (AT&T bell laboratories)