[Top][All Lists]

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

Re: if vs. ifdef in

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

Hi ljh,

"ljh" via Discussion list for automake <> writes:

> Hi community,
> I want to build debug or release with&nbsp;
> ```
> $ make # NDEBUG=1
> $ make NDEBUG=1
> ```
> Can I have to define and convey something like this to the output 
> Makefile:
> ```
> ifdef NDEBUG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # if vs. ifdef
> CFLAGS += -O3 # .cpp
> else
> CFLAGS += -g # .cpp
> LDFLAGS += -fsanitize=address
> endif
> ```
> But it seems I can only write `if` but not `ifdef` in
> So I had to enable ndebug option in 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 will then comment out one branch of the conditional.

Here's the documentation for both:

(automake)Conditionals, in HTML form at:
(make)Conditional Syntax, under ifdef, in HTML form at:

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]