Xref: utzoo comp.sources.wanted:2797 comp.lang.c:5690 Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!spar!hunt From: hunt@spar.SPAR.SLB.COM (Neil Hunt) Newsgroups: comp.sources.wanted,comp.lang.c Subject: Re: Desperately Seeking Makefile Maker Message-ID: <581@spar.SPAR.SLB.COM> Date: 18 Dec 87 18:24:41 GMT References: <1034@cpocd2.UUCP> <538@silver.bacs.indiana.edu> Reply-To: hunt@spar.UUCP (Neil Hunt) Organization: SPAR - Schlumberger Palo Alto Research Lines: 61 In article <1034@cpocd2.UUCP> nate@cpocd2.UUCP (Nathan Hess) writes: > Is there a program available that creates makefiles, preferrably > written in C? Here is a makefile maker which I have been using for a year or so. It is based upon a version from Steve Rubin at Schlumberger, which may be based upon something else... Enjoy - Neil/. #! /bin/csh # # Script to make makefile entries for C source files. # Neil Hunt, Schlumberger Palo Alto Research 1986. # Ideas from Steve Rubin at Schlumberger. # # note: source files must spell /^#include/ with no spaces, and nested # includes are not supported. are assumed stable, and # are not included in the dependency listing. # # example% depend file1.c file2.c >> Makefile # # egrep searches for include lines in source files; /dev/null is included # to force the filename to be printed even for a single source file. # # sed edits the lines to a form 'file.c: file.o include.h' # # awk assembles the lines into makefile format: # prev holds the previous file.c arg # doit holds a line of the form ' cc -c ${CFLAGS} file.c' # rec is a record initialised when a new 'file.c' is found, # and built up over the next few lines until its length would be > 75 # egrep '^#include.*".*"' /dev/null $* | \ sed -e 's/\(.*\).c:[^"]*"\([^"]*\)".*/\1.o: \1.c \2/' | \ awk ' \ { \ if ($1 != prev) \ { \ if (rec != "") \ { \ print rec; \ print doit; \ print ""; \ } \ rec = $0; \ prev = $1; \ doit = " cc -c ${CFLAGS} " $2; \ } \ else \ { \ if (length(rec $3) > 75) \ { \ print rec " \\"; \ rec = " " $3; \ } \ else rec = rec " " $3 \ } \ } \ END { print rec; print doit; print ""; } '