automake
[Top][All Lists]
Advanced

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

Re: if vs. ifdef in Makefile.am


From: Arsen Arsenović
Subject: Re: if vs. ifdef in Makefile.am
Date: Wed, 01 Mar 2023 22:09:41 +0100

Hi ljh,

"ljh" via Discussion list for automake <automake@gnu.org> writes:

> Hi community,
>
>
> I want to build debug or release with&nbsp;
>
>
> ```
> $ make # NDEBUG=1
> $ make NDEBUG=1
> ```
>
>
> Can I have automake.am to define and convey something like this to the output 
> Makefile:
>
>
> ```
> ifdef NDEBUG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # if vs. ifdef
> CPPFLAGS += -DNDEBUG
> CFLAGS += -O3 # .cpp
> else
> CFLAGS += -g # .cpp
> LDFLAGS += -fsanitize=address
> endif
> ```
>
>
> But it seems I can only write `if` but not `ifdef` in Makefile.am.
>
>
> So I had to enable ndebug option in configure.ac. That's a lot more work.

The distinction between if and ifdef is who handles it.  ifdef is
handled at the GNU make level, while if is handled at configure time by
automake.  The configure script that preprocesses an automake generated
Makefile.in will then comment out one branch of the conditional.

Here's the documentation for both:

(automake)Conditionals, in HTML form at:
https://www.gnu.org/software/automake/manual/html_node/Conditionals.html
(make)Conditional Syntax, under ifdef, in HTML form at:
https://www.gnu.org/software/make/manual/html_node/Conditional-Syntax.html

Since, IIUC, you'd like to control NDEBUG based on configure-time flags,
I suspect you're looking for the first link.

Hope that helps, have a lovely night.
-- 
Arsen Arsenović

Attachment: signature.asc
Description: PGP signature


reply via email to

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