1# compiler.m4 - autoconf macros for compiler settings 2# 3# Copyright © 2005 Scott James Remnant <scott@netsplit.com>. 4# 5# Permission is hereby granted, free of charge, to any person obtaining 6# a copy of this software and associated documentation files (the 7# "Software"), to deal in the Software without restriction, including 8# without limitation the rights to use, copy, modify, merge, publish, 9# distribute, sublicense, and/or sell copies of the Software, and to 10# permit persons to whom the Software is furnished to do so, subject to 11# the following conditions: 12# 13# The above copyright notice and this permission notice shall be 14# included in all copies or substantial portions of the Software. 15# 16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 20# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 21# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 24 25# COMPILER_WARNINGS 26# ---------------------- 27# Add configure option to enable additional compiler warnings and treat 28# them as errors. 29AC_DEFUN([COMPILER_WARNINGS], 30[AC_ARG_ENABLE(compiler-warnings, 31 AS_HELP_STRING([--enable-compiler-warnings], 32 [Enable additional compiler warnings]), 33[if test "x$enable_compiler_warnings" = "xyes"; then 34 if test "x$GCC" = "xyes"; then 35 CFLAGS="-Wall -Werror $CFLAGS" 36 fi 37 if test "x$GXX" = "xyes"; then 38 CXXFLAGS="-Wall -Werror $CXXFLAGS" 39 fi 40fi])dnl 41])# COMPILER_WARNINGS 42 43# COMPILER_OPTIMISATIONS 44# --------------------------- 45# Add configure option to disable optimisations. 46AC_DEFUN([COMPILER_OPTIMISATIONS], 47[AC_ARG_ENABLE(compiler-optimisations, 48 AS_HELP_STRING([--disable-compiler-optimisations], 49 [Disable compiler optimisations]), 50[if test "x$enable_compiler_optimisations" = "xno"; then 51 [CFLAGS=`echo "$CFLAGS" | sed -e "s/ -O[1-9]*\b/ -O0/g"`] 52fi])dnl 53])# COMPILER_OPTIMISATIONS 54 55# COMPILER_COVERAGE 56# ---------------------- 57# Add configure option to enable coverage data. 58AC_DEFUN([COMPILER_COVERAGE], 59[AC_ARG_ENABLE(compiler-coverage, 60 AS_HELP_STRING([--enable-compiler-coverage], 61 [Enable generation of coverage data]), 62[if test "x$enable_compiler_coverage" = "xyes"; then 63 if test "x$GCC" = "xyes"; then 64 CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage" 65 fi 66fi])dnl 67])# COMPILER_COVERAGE 68