From fcd428d0b05f84ee1dbc4910a011d75bf6d02171 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 31 Oct 2010 03:27:29 +0100 Subject: build: Unify and fix AC_ARG_ENABLE usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current code was executing code in the action arguments, instead of just setting boolean flags and processing them afterwards. This poses several problems, it implies jugling code around in case the the default changes, it might also duplicate code, and it might leave the ACTION-IF-NOT-GIVEN argument empty which could turn into an empty “then fi” shell block which is a syntax error on POSIX shell. Leaving the ACTION-IF-GIVEN argument empty is fine as it's always used by autoconf to set $enableval to the specific enable variable, and setting that variable from $enableval is redundant and might be wrong depending on the order they are set, which could empty it. Reported-by: Michael Schmidt --- m4/dpkg-compiler.m4 | 11 +++++++---- m4/dpkg-funcs.m4 | 13 +++++++------ m4/dpkg-linker.m4 | 13 ++++++++----- 3 files changed, 22 insertions(+), 15 deletions(-) (limited to 'm4') diff --git a/m4/dpkg-compiler.m4 b/m4/dpkg-compiler.m4 index e885af4bf..3a3860175 100644 --- a/m4/dpkg-compiler.m4 +++ b/m4/dpkg-compiler.m4 @@ -8,7 +8,7 @@ AC_DEFUN([DPKG_COMPILER_WARNINGS], [AC_ARG_ENABLE(compiler-warnings, AS_HELP_STRING([--disable-compiler-warnings], [Disable additional compiler warnings]), - [enable_compiler_warnings=$enableval], + [], [enable_compiler_warnings=yes]) WFLAGS="-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers \ @@ -35,9 +35,12 @@ AC_DEFUN([DPKG_COMPILER_OPTIMISATIONS], [AC_ARG_ENABLE(compiler-optimisations, AS_HELP_STRING([--disable-compiler-optimisations], [Disable compiler optimisations]), -[if test "x$enable_compiler_optimisations" = "xno"; then - [CFLAGS=$(echo "$CFLAGS" | sed -e "s/ -O[[1-9]]*\b/ -O0/g")] -fi])dnl + [], + [enable_compiler_optimisations=yes]) + + AS_IF([test "x$enable_compiler_optimisations" = "xno"], [ + CFLAGS=$(echo "$CFLAGS" | sed -e "s/ -O[[1-9]]*\b/ -O0/g") + ]) ]) # DPKG_TRY_C99([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) diff --git a/m4/dpkg-funcs.m4 b/m4/dpkg-funcs.m4 index d37498677..45c0e3c05 100644 --- a/m4/dpkg-funcs.m4 +++ b/m4/dpkg-funcs.m4 @@ -76,12 +76,13 @@ AC_DEFUN([DPKG_MMAP], AC_ARG_ENABLE([mmap], AS_HELP_STRING([--enable-mmap], [enable usage of unrealiable mmap if available]), - [ - AC_CHECK_FUNCS([mmap]) - AC_DEFINE(USE_MMAP, 1, [Use unreliable mmap support]) - ], - [] - ) + [], + [enable_mmap=no]) + + AS_IF([test "x$enable_mmap" = "xyes"], [ + AC_CHECK_FUNCS([mmap]) + AC_DEFINE(USE_MMAP, 1, [Use unreliable mmap support]) + ]) ]) # DPKG_FUNC_ASYNC_SYNC diff --git a/m4/dpkg-linker.m4 b/m4/dpkg-linker.m4 index bff4d2260..2fdaae5b0 100644 --- a/m4/dpkg-linker.m4 +++ b/m4/dpkg-linker.m4 @@ -7,9 +7,12 @@ AC_DEFUN([DPKG_LINKER_OPTIMISATIONS], [AC_ARG_ENABLE(linker-optimisations, AS_HELP_STRING([--disable-linker-optimisations], [Disable linker optimisations]), -[if test "x$enable_linker_optimisations" = "xno"; then - [LDFLAGS=$(echo "$LDFLAGS" | sed -e "s/ -Wl,-O[[0-9]]*\b//g")] -else - [LDFLAGS="$LDFLAGS -Wl,-O1"] -fi], [LDFLAGS="$LDFLAGS -Wl,-O1"])dnl + [], + [enable_linker_optimisations=yes]) + + AS_IF([test "x$enable_linker_optimisations" = "xno"], [ + LDFLAGS=$(echo "$LDFLAGS" | sed -e "s/ -Wl,-O[[0-9]]*\b//g") + ], [ + LDFLAGS="$LDFLAGS -Wl,-O1" + ]) ]) -- cgit v1.2.3