[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: non-recursive make: is there a performance gain?
From: |
Stefano Lattarini |
Subject: |
Re: non-recursive make: is there a performance gain? |
Date: |
Sat, 08 Sep 2012 22:30:35 +0200 |
On 09/08/2012 09:02 PM, Jim Meyering wrote:
> Jim Meyering wrote:
>> Jim Meyering wrote:
>> ...
>>> On the subject of converting to non-recursive make in lib/,
>>> I have at least one problem so far: how can I select different
>>> CFLAGS depending on the directory containing the file I'm compiling?
>>>
>>> As you know, we currently have three different sets of warnings:
>>> - strict, for src/
>>> - less strict, for lib/
>>> - even less strict, for gnulib-tests/
>>>
>>> I could certainly do that with GNU make by defining
>>>
>>> src_CFLAGS = ...
>>> lib_CFLAGS = ...
>>> gnulib-tests_CFLAGS = ...
>>>
>>> and then including $($(@D)_CFLAGS) in the generic compilation rule.
>>>
>>> Hmm... maybe override that default rule in cfg.mk, where only GNU make
>>> will see it. Hah! So the act of writing this question has provided me
>>> with the solution: add these lines to cfg.mk:
>>>
>>> COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
>>> $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $($(@D)_CFLAGS)
>>>
>>> src_CFLAGS = -WBOGUS
>>>
>>> That -WBOGUS is just to test, and I confirm that it does what I expect.
>>
>> Better than that, simply append to $(COMPILE).
>> Here's what I'm considering, now:
>>
>> diff --git a/cfg.mk b/cfg.mk
>> index 489f946..039c6ff 100644
>> --- a/cfg.mk
>> +++ b/cfg.mk
>> @@ -558,3 +558,11 @@ exclude_file_name_regexp--sc_prohibit_test_backticks = \
>> # Exempt test.c, since it's nominally shared, and relatively static.
>> exclude_file_name_regexp--sc_prohibit_operator_at_end_of_line = \
>> ^src/(ptx|test|head)\.c$$
>> +
>> +# Augment GNU make's compilation command to include our per-directory
>> +# CFLAGS options:
>> +COMPILE += $($(@D)_CFLAGS)
>> +
>> +src_CFLAGS = $(WARN_CFLAGS)
>> +lib_CFLAGS = $(GNULIB_WARN_CFLAGS)
>> +gnulib-tests_CFLAGS = $(GNULIB_TEST_WARN_CFLAGS)
>
> We could even add per-basename and per-full-file-name options:
>
> COMPILE += $($(@D)_CFLAGS) $($(@F)_CFLAGS) $($(@)_CFLAGS)
>
Or even (untested!):
AM_CFLAGS += $($(@D)_CFLAGS) $($(@F)_CFLAGS) $($(@)_CFLAGS)
which wouldn't abuse Automake internals ;-)
> something I've wanted for a long time.
> Of course, this works only with GNU make, so it's fine for
> warnings and optimization-related things.
>
Regards,
Stefano