Diff between f44d3e08e9a1a6cb9570c163fd23a5dcee644c12 and d3e40e82afba8bbc24df8c23272fbf8a68e6ed67

Changed Files

File Additions Deletions Status
acinclude.m4 +15 -1 modified

Full Patch

diff --git a/acinclude.m4 b/acinclude.m4
index 9f2dc30..1681178 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -65,7 +65,6 @@ AC_DEFUN([COMPILER_FLAGS], [
 		with_cflags="$with_cflags -DG_DISABLE_DEPRECATED"
 		with_cflags="$with_cflags -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_28"
 		with_cflags="$with_cflags -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32"
-		with_cflags="$with_cflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3"
 	fi
 	AC_SUBST([WARNING_CFLAGS], $with_cflags)
 ])
@@ -136,6 +135,21 @@ AC_DEFUN([MISC_FLAGS], [
 		misc_cflags="$misc_cflags --coverage"
 		misc_ldflags="$misc_ldflags --coverage"
 	fi
+	if (test "$USE_MAINTAINER_MODE" = "yes"); then
+		AC_CACHE_CHECK([whether ${CC-cc} accepts -D_FORTIFY_SOURCE=3],
+						ac_cv_prog_cc_fortify_source_3, [
+			echo '#include <errno.h>' > fortify.c
+			if test -z "`${CC-cc} ${CFLAGS} ${misc_cflags} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -c fortify.c  2>&1`"; then
+				ac_cv_prog_cc_fortify_source_3=yes
+			else
+				ac_cv_prog_cc_fortify_source_3=no
+			fi
+			rm -f fortify.c fortify.o
+		])
+		if test "${ac_cv_prog_cc_fortify_source_3}" = "yes"; then
+			misc_cflags="$misc_cflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3"
+		fi
+	fi
 	misc_cflags="$misc_cflags -ffunction-sections -fdata-sections"
 	misc_ldflags="$misc_ldflags -Wl,--gc-sections"
 	AC_SUBST([MISC_CFLAGS], $misc_cflags)