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: Jan Engelhardt
Subject: Re: if vs. ifdef in Makefile.am
Date: Wed, 1 Mar 2023 22:19:30 +0100 (CET)
User-agent: Alpine 2.25 (LSU 592 2021-09-18)

On Wednesday 2023-03-01 19:50, ljh via Discussion list for automake wrote:
>```
>$ make # NDEBUG=1
>$ make NDEBUG=1
>```
>
>Can I have automake.am to define and convey something like this to the output 
>Makefile:
>```
>ifdef NDEBUG             # if vs. ifdef
>CPPFLAGS += -DNDEBUG
>CFLAGS += -O3 # .cpp
>else
>CFLAGS += -g # .cpp
>LDFLAGS += -fsanitize=address
>endif
>```

ifdef is the wrong tool. Because when you issue e.g. `make NDEBUG=0`, it
does not do what a sensible person would want.
Also, CFLAGS and LDFLAGS belong to the user. Don't touch them.


You can utilize the same mechanism behind automake's `make V=1`:

NDEBUG = 0
my_CPPFLAGS_0 =
my_CPPFLAGS_1 = -NDEBUG
my_CFLAGS_0 = -O3
my_CFLAGS_1 =
AM_CPPFLAGS = ${my_CPPFLAGS_${NDEBUG}}
AM_CFLAGS = ${my_CFLAGS_${NDEBUG}}



reply via email to

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