automake
[Top][All Lists]
Advanced

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

Re: Extending automake rules


From: Stefano Lattarini
Subject: Re: Extending automake rules
Date: Sun, 11 Nov 2012 10:19:25 +0100

HI Miguel.

On 11/10/2012 12:46 PM, Miguel Guedes wrote:
> 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.
> 
Unfortunately, it is basically impossible to accomplish what you
want with the current Automake.  That is, most rules can only be
overridden, not extended (and those which can, can be only in a
limited, unflexible way).  You might manage to hack something
together by (ab)using Automake internals, but then of course
you'll have no guarantee such an hack will continue to work with
future Automake release.

Lack of extensibility is one of the main drawbacks of Automake,
and improving the situation consistently would require a lot of
work I fear, so I don't see anything happening in that area
anytime soon.

Sorry,
  Stefano



reply via email to

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