[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Expandable dependencies variables
From: |
Miguel Guedes |
Subject: |
Re: Expandable dependencies variables |
Date: |
Sat, 10 Nov 2012 11:27:40 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121028 Thunderbird/16.0.2 |
On 09/11/12 23:24, Paul Smith wrote:
> Or, finally, you can go old-school and use auto-generated included
> makefiles, which will work with virtually every version of GNU make out
> there:
>
> BINARIES := foo bar
>
> foo_OBJECTS := foo_obj_1 foo_obj_2
> bar_OBJECTS := bar_obj_1 bar_obj_2
>
> -include generated.mk
> generated.mk: Makefile
> @($(foreach B,$(BINARIES),echo $B: $($B_OBJECTS);):) > $@
>
Thank you for your input, Paul!
After weighing the pros and cons I've come to the conclusion that it's
best to use GNU Autoconf/Automake after all.
There's one thing I would simply love to accomplish with Automake
though: 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 then 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 do you 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.