]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Backport r373119 from 11 to go along with RAII_VAR support.
authorDavid M. Lee <dlee@digium.com>
Tue, 29 Oct 2013 14:52:26 +0000 (14:52 +0000)
committerDavid M. Lee <dlee@digium.com>
Tue, 29 Oct 2013 14:52:26 +0000 (14:52 +0000)
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

Makefile
configure
configure.ac
makeopts.in

index 41f2761f6222512d1e61e59304db27fa97f7064c..69867c2024fde97bd5fa5c3517590fead818a603 100644 (file)
--- 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
index 708258ddcf7b012f187027dfae1fa252a93ed25e..7d864c7b563f8aab1f593017c08419a72dd3c5b0 100755 (executable)
--- 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
index 9a7672735f13f92f926255ea734400a13573f781..32526ccfe5ee78d164832d2d0987abc2450be1c2 100644 (file)
@@ -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 <sys/sysinfo.h>],
index 6418428cc26e07681e3494c1693d9815bb4c97e8..d1c1aa972d721ed60172c83acffa4e05f3804357 100644 (file)
@@ -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@