I'm porting a home-baked makefile
setup into the autotools suite. I've run into a problem for which I haven't yet found a suitable answer. It may be that I'm just not using the correct terms in my searches. Being a complete neophyte to autotools, I probably just don't know enough of the jargon.
The problem: our build process has a dependency for a header file which is generated from a csv file. (I don't know why. It is what it is.) In our old system, we did something like this:
.PHONY: all
all : header.csv.h $(objects)
header.csv.h:
python prebuild.py
# remainder for building objects and the file lib.a
Finding this link to extend default rules, I've added this to my Makefile.am
noninst_LIBRARIES = libstuff.a
# .. Additional CXXFLAGS and CPPFLAGS, and listing the sources
all-local: header.csv.h
header.csv.h:
python prebuild.py
The remade Makefile
s still didn't work. Inspection of the generated Makefile
for this part of the library showed this:
# lots of stuff preceeding
all: all-am
all-am: Makefile $(LIBRARIES) all-local
all-local: header.csv.h
# the rest as above
Right there in all-am:
is the problem. The $(LIBRARIES)
dependencies are listed first and are therefore being built first. Some further reading on the extending link above shows this is to be expected: no way to guaranteeing the order. It's simple enough to "fix": move all-local
to precede $(LIBRARIES)
. However, this only fixes it once. I must guarantee this is always built first.
Can I add things to the configure
script to be executed during the configuration process? What's the right way to handle something like this?