I'm trying to make a small change to an automake build.

The system to modify uses configure.ac and Makefile.am inputs. For a single object file within one subdirectory I have to invoke a script before compiling, to patch config info into the build.

I don't see the right location to allow such pre-processing ahead of compiling this specific C file. What I've tried is to insert an additional target into

all: all-am

But this seems not to be the way to go and in addition I wasn't able to figure how to overload this generated line.


You should be able to add in a special target for the object file in question in your Makefile.am. Something like:

file.o: file.c
    $(CC) $(CFLAGS)  -c file.c
    modification.sh file.o

This should cause modification.sh to be run on the object file whenever it gets built.

| improve this answer | |
  • Thanks I will try that. What I found in between were the automake targets BUILD_SOURCES all-local This way I can inject similar things. – Wolfgang Rostek Nov 29 '11 at 16:36
  • 1
    This is probably the right way, but not that if your modification script fails, it will leave an unpatched but seemingly up to date file.o lying around. It might be better to chain the commands like file.c -> file.o.tmp -> file.o. – Peter Eisentraut Dec 2 '11 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.