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