build: set default flags before AC_PROG_CXX

Change-Id: Idaa6532471d24ebd01613d01843fc3e0758d0025
Reviewed-by: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
This commit is contained in:
Adrien Béraud
2018-08-16 16:57:22 -04:00
committed by Andreas Traczyk
parent 30ce9cccc0
commit 3f90a3b26a

View File

@ -21,6 +21,16 @@ AC_CONFIG_HEADERS([config.h])
# Silent build by default. Use make V=1 to increase verbosity
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
dnl debug mode is default-disabled
AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Build in debug mode, adds stricter warnings, disables optimization]))
AS_IF([test "x$enable_debug" = "xyes"], [
CFLAGS="${CFLAGS} -g -fno-omit-frame-pointer -Wall -Wextra -Wnon-virtual-dtor -Wno-unknown-pragmas -Wformat=2 -O0"
CXXFLAGS="${CXXFLAGS} -g -fno-omit-frame-pointer -Wall -Wextra -Wnon-virtual-dtor -Wno-unknown-pragmas -Wformat=2 -O0"
], [
CFLAGS="${CFLAGS} -DNDEBUG=1 -O3"
CXXFLAGS="${CXXFLAGS} -DNDEBUG=1 -O3"
])
dnl Check for programs
AC_PROG_CC
AC_PROG_CXX
@ -633,18 +643,6 @@ AC_DEFUN([BB_ENABLE_DOXYGEN],
# Actually perform the doxygen check
BB_ENABLE_DOXYGEN
dnl debug mode is default-disabled
AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Build in debug mode, adds stricter warnings, disables optimization]))
AS_IF([test "x$enable_debug" = "xyes"],
[CXXFLAGS="${CXXFLAGS} -g -fno-omit-frame-pointer -Wall -Wextra -Wnon-virtual-dtor -Wno-unknown-pragmas -Wformat=2 -O0"],
[CXXFLAGS="${CXXFLAGS} -DNDEBUG=1 -O3"])
dnl What Makefiles to generate
#TODO: split this list across where the relevant check is performed
AC_CONFIG_FILES([Makefile \
bin/Makefile \
src/Makefile \