Fog Creek Software
Discussion Board




dependancy checking in large linux projects

How does one check for source dependancies in large projects? Do they just edit make by hand, or are their automatic tools on Linux?

anon
Tuesday, April 22, 2003

http://gnu.org/automake/automake
http://gnu.org/software/autoconf

Mike Swieton
Tuesday, April 22, 2003

I use makedepends, although there are other ways.  Anyway, here is a section of makefile:

SRC = myfile1.c mfile2.c myfile3.c ...

###
# makedepends related symbols
# -Y            Don't search standard library paths
# -f            output dependencies to this file
# -s            use this token string
###
DEPFILE    = .depends
DEPTOKEN    = '\# MAKEDEPENDS'
DEPFLAGS    = -Y -f $(DEPFILE) -s $(DEPTOKEN) -p $(OUTDIR)/

deps:
        rm -f $(DEPFILE)
        make $(DEPFILE)

$(DEPFILE): $(SRC)
        @echo $(DEPTOKEN) > $(DEPFILE)
        makedepend $(DEPFLAGS) -- $(CFLAGS) -- $(SRC) >&/dev/null

-include $(DEPFILE)

For cross compilation, searching the standard include paths are not what you want.  Even if you're not cross-compiling, the standard search paths do not include things you often change (/usr/include).  So I prefer to always leave the out.

sinclude or -include means optionally include this file, which is the $(DEPENDS) file.  If it hasn't been generated, then the make goes ahead and makes it.

There is a basic flaw in this setup - if you change your #include lists in header files, the depends lists won't get updated, unless you add the headers to the dependencies of $(DEPENDS).

Hope you find this amusing.

Nat Ersoz
Tuesday, April 22, 2003

http://make.paulandlesley.org/autodep.html

More than you wanted to know...

Robert
Tuesday, April 22, 2003

Very nice link.  Thanks.

Nat Ersoz
Tuesday, April 22, 2003

I highly recommend systems that write one single Makefile for your entire project (rather than one Makefile per directory). Make runs much, much faster in this mode because it doesn't have to spawn sub-processes. On my moderate-size project it takes way less than a second to 'make' when nothing has changed. I wrote a little Python script that collects the dependencies and build rules and spits out a single Makefile for everything.

Dan Maas
Wednesday, April 23, 2003

*  Recent Topics

*  Fog Creek Home