automake
[Top][All Lists]
Advanced

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

Re: AM_CFLAGS and %reldir%


From: Mathieu Lirzin
Subject: Re: AM_CFLAGS and %reldir%
Date: Sun, 14 May 2017 14:35:15 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Hello,

Thomas Martitz <address@hidden> writes:

> when transitioning a project to non-recursive Automake, using
> %reldir%, you lose the ability to define per-directory
> AM_{CPP,C,CXX,LD}FLAGS.
>
> With recursive Automake, you can simply set AM_CFLAGS in each
> Makefile.am. Attempting the same in a non-recursive setup would modify
> the single, global AM_CFLAGS, which may not be desirable.
>
> The only solution seems to be to heavily expand the fragments:
>
> AM_CFLAGS = -g
>
> bin_PROGRAMS = foo bar baz
>
> becomes
>
> bin_PROGRAMS += %D%/foo %D%/bar %D%/baz
>
> %C_foo_CFLAGS = -g
>
> %C_bar_CFLAGS = -g
>
> %C_baz_CFLAGS = -g
>
> (repeat for AM_CPPFLAGS, AM_CXXFLAGS, AM_LDFLAGS).
>
> This gets unwieldy in cases of many programs and libraries. As a side
> effect, Automake will emit explicit rules, making the Makefile even
> larger, though that's not much of a problem I think and is probably
> not avoidable.
>
> Is there any other solution available? I have tried to define
> directory-level AM_CFLAGS, like
>
> AM_%C%_CFLAGS = -g
>
> (applying to all targets that start with %C% after expanding) but they
> are not used.
>
>
> If there are no other solutions, would the above idea considered if
> someone posted a patch?

I think I understand what you mean, however the issue has nothing to do
with %reldir% which is just a convenience for not typing the current
directory of the makefile fragment.

The issue is that you can have only one default AM_*FLAGS per Makefile
and when using a non-recursive Makefile (even with included fragments)
everything is put in a unique Makefile.  When you have a lot of programs
(for example in a test suite), having to define foo_*FLAGS for each
program can indeed be cumbersome.

I like the idea of allowing per directory default flags, I don't see any
issue with such feature.

Regarding the syntax, what about dropping the "AM" in front of
AM_directory_*FLAGS like what is done for per programs _*FLAGS?  IIUC,
it will be impossible to have conflicts between program and directory
flags variables.

Thanks.

-- 
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37



reply via email to

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