[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: if vs. ifdef in Makefile.am
From: |
Bogdan |
Subject: |
Re: if vs. ifdef in Makefile.am |
Date: |
Thu, 2 Mar 2023 16:14:37 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 |
ljh via Discussion list for automake <automake@gnu.org>, Wed Mar 01
2023 19:50:56 GMT+0100 (Central European Standard Time)
Hi community,
I want to build debug or release with
```
$ 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
```
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.
Thanks
Hi.
Just adding my 2 cents...
I hope I won't be saying something silly or obvious here, but maybe
you can pass the actual flags on the command line as a new variable
and include it *unconditionally* in the Makefile.am (expanding to
empty if not defined).
Sure, that's more troublesome, but at least you can have this
working even now, I guess.
# Makefile.am:
AM_CPPFLAGS = ... $(MY_CPPFLAGS) ...
AM_CFLAGS = ... $(MY_CFLAGS) ...
AM_LDFLAGS = ... $(MY_LDFLAGS) ...
A single 'autoreconf'/'automake' invocation later and you can do:
# release build:
make MY_CFLAGS=-g MY_LDFLAGS=-fsanitize=address
# debug build:
make MY_CFLAGS=-O3 MY_CPPFLAGS=-DNDEBUG
Probably Nick's suggestion (a new option to ./configure or the
AC_HEADER_ASSERT macro) would be the most future-proof, but it
requires running ./configure each time you wish to change the build
type (which maybe is not a bad idea, it depends).
--
Regards - Bogdan ('bogdro') D. (GNU/Linux & FreeDOS)
X86 assembly (DOS, GNU/Linux): http://bogdro.evai.pl/index-en.php
Soft(EN): http://bogdro.evai.pl/soft http://bogdro.evai.pl/soft4asm
www.Xiph.org www.TorProject.org www.LibreOffice.org www.GnuPG.org
Re: if vs. ifdef in Makefile.am, Arsen Arsenović, 2023/03/01
Re: if vs. ifdef in Makefile.am,
Bogdan <=
- Re: if vs. ifdef in Makefile.am, ljh, 2023/03/02
- Re: if vs. ifdef in Makefile.am, Jacob Bachmeyer, 2023/03/02
- Re: if vs. ifdef in Makefile.am, ljh, 2023/03/03
- Re: if vs. ifdef in Makefile.am, Jan Engelhardt, 2023/03/03
- Re: if vs. ifdef in Makefile.am, ljh, 2023/03/03
- Re: if vs. ifdef in Makefile.am, Jan Engelhardt, 2023/03/03
- Re: if vs. ifdef in Makefile.am, ljh, 2023/03/03
- Re: if vs. ifdef in Makefile.am, Jan Engelhardt, 2023/03/03