Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

1 Answer 1

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
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
add comment

Your Answer

 
discard

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.