From: David M. Lee Date: Tue, 29 Oct 2013 14:52:26 +0000 (+0000) Subject: Backport r373119 from 11 to go along with RAII_VAR support. X-Git-Tag: 1.8.26.0-rc1~36 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=480e8f43d3b090294c65157ba850a2b744650038;p=thirdparty%2Fasterisk.git Backport r373119 from 11 to go along with RAII_VAR support. In order to use nested functions on some versions of GCC (e.g. GCC on OS X), the -fnested-functions flag must be passed to the compiler. This patch adds detection logic to ./configure to add the flag if necessary. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@402192 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/Makefile b/Makefile index 41f2761f62..69867c2024 100644 --- a/Makefile +++ b/Makefile @@ -170,7 +170,7 @@ ifeq ($(findstring -Wall,$(_ASTCFLAGS) $(ASTCFLAGS)),) _ASTCFLAGS+=-Wall endif -_ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) +_ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(AST_NESTED_FUNCTIONS) $(DEBUG) ifeq ($(AST_DEVMODE),yes) _ASTCFLAGS+=-Werror diff --git a/configure b/configure index 708258ddcf..7d864c7b56 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac Revision: 400073 . +# From configure.ac Revision: 400767 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for asterisk trunk. # @@ -676,6 +676,7 @@ PBX_DLADDR PBX_IP_MTU_DISCOVER PBX_GLOB_BRACE PBX_GLOB_NOMAGIC +AST_NESTED_FUNCTIONS AST_NATIVE_ARCH AST_SHADOW_WARNINGS AST_NO_STRICT_OVERFLOW @@ -16737,6 +16738,32 @@ $as_echo "no" >&6; } fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fnested-functions" >&5 +$as_echo_n "checking for -fnested-functions... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +auto void foo(void); void foo(void) {} + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + AST_NESTED_FUNCTIONS= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: required" >&5 +$as_echo "required" >&6; } + AST_NESTED_FUNCTIONS=-fnested-functions + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysinfo" >&5 $as_echo_n "checking for sysinfo... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext diff --git a/configure.ac b/configure.ac index 9a7672735f..32526ccfe5 100644 --- a/configure.ac +++ b/configure.ac @@ -998,6 +998,18 @@ else fi AC_SUBST(AST_NATIVE_ARCH) +dnl Nested functions required for RAII implementation +AC_MSG_CHECKING(for -fnested-functions) +AC_COMPILE_IFELSE( + dnl Prototype needed due to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36774 + [AC_LANG_PROGRAM([], [auto void foo(void); void foo(void) {}])], + AC_MSG_RESULT(no) + [AST_NESTED_FUNCTIONS=], + AC_MSG_RESULT(required) + [AST_NESTED_FUNCTIONS=-fnested-functions] +) +AC_SUBST(AST_NESTED_FUNCTIONS) + AC_MSG_CHECKING(for sysinfo) AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include ], diff --git a/makeopts.in b/makeopts.in index 6418428cc2..d1c1aa972d 100644 --- a/makeopts.in +++ b/makeopts.in @@ -99,6 +99,7 @@ AST_CODE_COVERAGE=@AST_CODE_COVERAGE@ AST_DECLARATION_AFTER_STATEMENT=@AST_DECLARATION_AFTER_STATEMENT@ AST_NO_STRICT_OVERFLOW=@AST_NO_STRICT_OVERFLOW@ AST_SHADOW_WARNINGS=@AST_SHADOW_WARNINGS@ +AST_NESTED_FUNCTIONS=@AST_NESTED_FUNCTIONS@ AST_FORTIFY_SOURCE=@AST_FORTIFY_SOURCE@ ALSA_INCLUDE=@ALSA_INCLUDE@