automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Extending automake rules


From: Miguel Guedes
Subject: Extending automake rules
Date: Sat, 10 Nov 2012 11:46:44 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121028 Thunderbird/16.0.2

There's one thing I would simply love to accomplish with Automake: the ability to extend rules without overriding them. For instance, how would one print a custom message in a specific format (i.e. color) each time a source file is compiled and a binary linked?

For instance, in a traditional Makefile I would simply add the following rule:

%.o: %.c
    @echo -e "[C] `basename $<`
    @$(CC) $(CFLAGS) -c $< -o $@

$(bin): $(bin_OBJECTS)
    @echo "\033[1;32m[L] `basename address@hidden"
    @LINK_LOG="/tmp/`basename address@hidden"; \
        [ -f $$LINK_LOG ] && rm $$LINK_LOG; \
        $(CXX) $(CXX_FLAGS) -o $@ $(EXE_OBJECTS) \
            $(LIBRARIES) 2>$$LINK_LOG ; \
        EXIT_CODE=$$?; \
        if [ ! $$? -eq 0 ]; then \
            cat "$$LINK_LOG"; \
            exit $$EXIT_CODE; \
        fi;

The above would result in something like:

[C] foo.c
[C] bar.c
[L] bin        # in yellow

But how does one setup a Makefile.am such that compilation and linking rules are extended in Makefile.in and the generated Makefile.am still contains the normally generated compile/link rules logic - so dependencies, compilation and linking logic is kept and *not* overriden. I've had a look at the Automake hooks but they seem to be executed after the main rule.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]