about summary refs log tree commit diff
path: root/configure.ac
diff options
context:
space:
mode:
authorNiklas Hambüchen <mail@nh2.me>2019-07-02T20·30+0200
committerNiklas Hambüchen <mail@nh2.me>2019-07-03T02·32+0200
commit717e821b99797845e1bef47d862f8cb0fb69cfc9 (patch)
treef7466b10447c98c248370f4ebb3791ad317c275e /configure.ac
parent20129bd83d57316cc0b69bec7abeec43011c56d5 (diff)
autoconf: Allow overriding CFLAGS/CXXFLAGS from outside.
As is normal for autoconf-based projects.

For example, it is a common use case to do

    ./configure CXXFLAGS=-O0

This did not work for nix until now, because the `CXXFLAGS=` declaration
would unconditionally erase what the user had specified.

The custom `OPTIMIZE` flag is removed, but the default `-O3` is retained;
autoconf would default to `-g -O2` by default otherwise as documented on:

https://www.gnu.org/software/autoconf/manual/autoconf-2.60/html_node/C-Compiler.html
https://www.gnu.org/software/autoconf/manual/autoconf-2.60/html_node/C_002b_002b-Compiler.html
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac6
1 files changed, 4 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 3a486fab8e71..571bb54d8a18 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,8 +50,10 @@ AC_DEFINE_UNQUOTED(SYSTEM, ["$system"], [platform identifier ('cpu-os')])
 test "$localstatedir" = '${prefix}/var' && localstatedir=/nix/var
 
 
-CFLAGS=
-CXXFLAGS=
+# Set default flags for nix (as per AC_PROG_CC/CXX docs),
+# while still allowing the user to override them from the command line.
+: ${CFLAGS="-O3"}
+: ${CXXFLAGS="-O3"}
 AC_PROG_CC
 AC_PROG_CXX
 AC_PROG_CPP