Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|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
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 posting your answer, you agree to the privacy policy and terms of service.

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