🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #1272

Solution to makefile problem (was : Makefiles -- .c and .h)

#1272
From: Doug Lee
Date: Wed, 21 Nov 1990 04:16
49 lines
3181 bytes
In (several articles) (several people) have been writing:
[about the problem of maintaining dependency lists in makefiles in a portable
manner.]

I have written a PERL script which may help solve the problem of finding
file dependency relationships.  Given a list of C source files (one per line),
it generates a makefile-ready dependency list for each associated object file.
For instance, given the files a.c and b.c, it might produce

a.o:  a.c a.h global.h utils.h
b.o:  b.c b.h globals.h

From the comments (which may become a doc file for efficiency):

# This PERL script takes a list of C source files and generates a list of
# dependencies for each corresponding object file in a format suitable for
# inclusion in a makefile.  Files listed as dependencies are also scanned for
# dependencies of their own, and any files found in this way are also listed as
# dependencies of the object file.  File inclusions of virtually unlimited
# depth are handled properly, and no file will be listed as a dependency more
# than once, regardless of how often it is referenced.  (This also protects
# against infinite loops, although no warnings of these will be produced.)
# 
# By default, a standard header file (one referenced via "#include <...>') is
# not listed as a dependency and is not scanned for dependencies of its own.
# See the -s option below.
#
# At this writing, conditionals are not recognized; thus, if a file is included
# conditionally, it WILL be listed as a dependency in all cases.
#
# Usage:  mkdep [ -d ] [ -s[<include_dir>] ] [ list_file ... ]
#   -d  Debugging output.  Sends a progress report to stderr.
#   -s  Consider standard header files in addition to "local" headers.  This
#       will also cause standard header files referenced to be scanned for
#       dependencies.  Probably not necessary unless your system is extremely
#       dynamic.  The directory containing standard header files (/usr/include
#       by default) may be given as an argument.
#   list_file
#       Use one or more list files rather than stdin for the list of source
#       files to check.  If multiple filenames are given, the final list will
#       be the concatenation of the file contents in the order given.

Send me a request if interested.  I could probably post it (it's only 156
lines, including comments), but I'm not so sure after the recent commotion
over the issue of posting the error-handling library.  In any case, I'll place
it in the public domain.

Doug Lee  (dgl292@athenanet.com or uunet!pallas!dgl292)
(NOTE: that's "DGL" in lower case--there's no #1)
Technical Details
Message-ID: <441@pallas.athenanet.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!pallas!dgl292
References: <6268@minyos.xx.rmit.oz.au> <1990Nov16.171816.7173@ssd.kodak.com> <1990Nov18.204706.7044@athena.mit.edu> <10168:Nov2004:55:5290@kramden.acf.nyu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!pallas!dgl292
From: dgl292@pallas.athenanet.com (Doug Lee)
Newsgroups: comp.unix.programmer
Subject: Solution to makefile problem (was : Makefiles -- .c and .h)
Summary: A PERL solution
Message-ID: <441@pallas.athenanet.com>
Date: 21 Nov 90 04:16:17 GMT
References: <6268@minyos.xx.rmit.oz.au> <1990Nov16.171816.7173@ssd.kodak.com> <1990Nov18.204706.7044@athena.mit.edu> <10168:Nov2004:55:5290@kramden.acf.nyu.edu>
Reply-To: dgl292@athenanet.com (Doug Lee)
Lines: 49