|
From: | Eric Blake |
Subject: | Re: Conditionally set CXXFLAGS based on directory via 1 configure.ac? |
Date: | Wed, 27 Jul 2011 17:01:07 -0600 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.11 |
On 07/27/2011 04:13 PM, Xochitl Lunde wrote:
Is there a nice way to conditionally add -fno-exceptions to CXXFLAGS for the "Source Dir" from configure.ac or elsewhere? I am sure I can go to each library under "Source Dir" and put -fno-exceptions in AM_CXXFLAGS, but is there a correct way to do it in configure.ac?
The nicest way to to this is to not change CXXFLAGS, but to instead AC_SUBST two different variables for the difference in which compiler options you want (you _did_ test that $CXX supports -fno-exceptions before blindly adding it to CXXFLAGS, right? Not all the world is g++). Then, in the appropriate Makefile.am files, modify AM_CXXFLAGS to include the appropriate substituted variables.
See how coreutils does things: in the top level configure.ac, it does an AC_SUBST of WERROR_CFLAGS, WARN_CFLAGS, and GNULIB_WARN_CFLAGS - three distinct subsets of flags that were all tested on whether they were supported by the current compiler, and where WERROR_CFLAGS is conditional on whether you requested configure --enable-gcc-warnings. Then, src/Makefile.am sets AM_CFLAGS to $(WARN_CFLAGS) $(WERROR_CFLAGS), while lib/Makefile.am uses the less-strict AM_CFLAGS += $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS).
-- Eric Blake address@hidden +1-801-349-2682 Libvirt virtualization library http://libvirt.org
[Prev in Thread] | Current Thread | [Next in Thread] |