* aclocal.m4 (grub_CHECK_STACK_PROTECTOR): New definition.
* configure.ac: Use it for testing the HOST and TARGET compilers.
+2007-02-03 Thomas Schwinge <tschwinge@gnu.org>
+
+ * aclocal.m4 (grub_CHECK_STACK_PROTECTOR): New definition.
+ * configure.ac: Use it for testing the HOST and TARGET compilers.
+
2006-12-13 Thomas Schwinge <tschwinge@gnu.org>
* Makefile.in (enable_grub_emu): New variable.
[Catch gcc bug])
fi
])
+\f
+dnl Check if the C compiler supports `-fstack-protector'.
+AC_DEFUN(grub_CHECK_STACK_PROTECTOR,[
+[# Smashing stack protector.
+ssp_possible=yes]
+AC_MSG_CHECKING([whether `$CC' accepts `-fstack-protector'])
+# Is this a reliable test case?
+AC_LANG_CONFTEST([[void foo (void) { volatile char a[8]; a[3]; }]])
+[# `$CC -c -o ...' might not be portable. But, oh, well... Is calling
+# `ac_compile' like this correct, after all?
+if eval "$ac_compile -S -fstack-protector -o conftest.s" 2> /dev/null; then]
+ AC_MSG_RESULT([yes])
+ [# Should we clear up other files as well, having called `AC_LANG_CONFTEST'?
+ rm -f conftest.s
+else
+ ssp_possible=no]
+ AC_MSG_RESULT([no])
+[fi]
+])
# Check for functions.
AC_CHECK_FUNCS(posix_memalign memalign)
+#
+# Compiler features.
+#
+
+# Smashing stack protector.
+grub_CHECK_STACK_PROTECTOR
+[# Need that, because some distributions ship compilers that include
+# `-fstack-protector' in the default specs.
+if [ x"$ssp_possible" = xyes ]; then
+ CFLAGS=$CFLAGS\ -fno-stack-protector
+fi]
+
+
#
# Check for target programs.
#
TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
fi
+#
+# Compiler features.
+#
+
+# Smashing stack protector.
+grub_CHECK_STACK_PROTECTOR
+[# Need that, because some distributions ship compilers that include
+# `-fstack-protector' in the default specs.
+if [ x"$ssp_possible" = xyes ]; then
+ TARGET_CFLAGS=$TARGET_CFLAGS\ -fno-stack-protector
+fi]
+
AC_SUBST(TARGET_CFLAGS)
AC_SUBST(TARGET_CPPFLAGS)
AC_SUBST(TARGET_LDFLAGS)