www.delorie.com/gnu/docs/automake/automake_70.html   search  
 
Buy GNU books!


automake

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Recording dependencies manually

Usually people are happy enough with BUILT_SOURCES because they never run targets such as make foo before make all, as in the previous example. However if this matters to you, you can avoid BUILT_SOURCES and record such dependencies explicitly in the `Makefile.am'.

 
bin_PROGRAMS = foo
foo_SOURCES = foo.c
foo.$(OBJEXT): bindir.h
CLEANFILES = bindir.h
bindir.h: Makefile
        echo '#define bindir "$(bindir)"' >$@

You don't have to list all the dependencies of foo.o explicitly, only those which might need to be built. If a dependency already exists, it will not hinder the first compilation and will be recorded by the normal dependency tracking code. (Note that after this first compilation the dependency tracking code will also have recorded the dependency between foo.o and bindir.h; so our explicit dependency is really useful to the first build only.)

Adding explicit dependencies like this can be a bit dangerous if you are not careful enough. This is due to the way Automake tries not to overwrite your rules (it assumes you know better than it). foo.$(OBJEXT): bindir.h supersedes any rule Automake may want to output to build foo.$(OBJEXT). It happens to work in this case because Automake doesn't have to output any foo.$(OBJEXT): target: it relies on a suffix rule instead (i.e., .c.$(OBJEXT):). Always check the generated `Makefile.in' if you do this.


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003