2013-12-30  Magnus Granberg <zorry@gentoo.org>

	* gcc/configure.ac		Add --enable-esp and define ENABLE_ESP.
	Check if we support crtbeginP and define ENABLE_CRTBEGINP.
	* gcc/configure	Regenerated


--- a/gcc/configure.ac	2011-11-18 11:52:32.000000000 +0100
+++ b/gcc/configure.ac	2012-10-02 17:39:15.649526241 +0200
@@ -5130,6 +5237,55 @@ if test x"${LINKER_HASH_STYLE}" != x; th
                                          [The linker hash style])
 fi
 
+# --------------
+# Esp checks
+# --------------
+
+# Check whether --enable-esp was given and target have the support.
+AC_ARG_ENABLE([esp],
+[AS_HELP_STRING([--enable-esp],
+               [Enable Stack protector and Position independent executable as
+                default if we have suppot for it when compiling
+                and link with -z now as default.
+                Linux targets supported i*86, x86_64, x32,
+                powerpc, powerpc64, ia64, arm and mips.])],
+  enable_esp=$enableval,
+  enable_esp=no)
+if test $enable_esp = yes ; then
+  AC_MSG_CHECKING(if $target support esp)
+  case "$target" in
+    i?86*-*-linux* | x86_64-*-linux* | powerpc*-*-linux* | mips-*-linux* | arm*-*-linux* | ia64-*-linux*)
+      enable_esp=yes
+      AC_DEFINE(ENABLE_ESP, 1,
+        [Define if your target support esp and you have enable it.])
+      ;;
+    *)
+      enable_esp=no
+      ;;
+  esac
+AC_MSG_RESULT($enable_esp)
+fi
+AC_SUBST([enable_esp])
+if test $enable_esp = yes ; then
+  AC_MSG_CHECKING(checking for crtbeginP.o support)
+    if test x$enable_esp = xyes ; then
+      case "$target" in
+        ia64*-*-linux*)
+          enable_crtbeginP=no ;;
+        *-*-linux*)
+          if test x$gcc_cv_ld_pie = xyes && test x$lt_cv_prog_compiler_static_works = xyes; then
+            enable_crtbeginP=yes
+            AC_DEFINE(ENABLE_CRTBEGINP, 1,
+              [Define if your compiler will support crtbeginP.])
+          fi
+          ;;
+        *) enable_crtbeginP=no ;;
+      esac
+    fi
+  AC_MSG_RESULT($enable_crtbeginP)
+fi
+AC_SUBST([enable_crtbeginP])
+
 # Configure the subdirectories
 # AC_CONFIG_SUBDIRS($subdirs)
 
--- a/gcc/configure	2013-02-01 21:26:24.000000000 +0100
+++ b/gcc/configure	2013-02-12 01:59:20.000000000 +0100
@@ -600,6 +600,8 @@
 ac_subst_vars='LTLIBOBJS
 LIBOBJS
 PICFLAG
+enable_crtbeginP
+enable_esp
 enable_host_shared
 enable_plugin
 pluginlibs
@@ -920,6 +922,7 @@
 enable_plugin
 enable_libquadmath_support
 with_linker_hash_style
+enable_esp
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1633,6 +1636,11 @@
   --enable-plugin         enable plugin support
   --disable-libquadmath-support
                           disable libquadmath support for Fortran
+  --enable-esp            Enable Stack protector and Position independent
+                          executable as default if we have suppot for it when
+                          compiling and link with -z now as default.
+                          Linux targets supported i*86, x86_64, x32,
+                          powerpc, powerpc64, ia64, arm and mips.
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -27419,6 +27427,59 @@
 
 fi
 
+# --------------
+# Esp checks
+# --------------
+
+# Check whether --enable-esp was given and target have the support.
+# Check whether --enable-esp was given.
+if test "${enable_esp+set}" = set; then :
+  enableval=$enable_esp; enable_esp=$enableval
+else
+  enable_esp=no
+fi
+
+if test $enable_esp = yes ; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $target support esp" >&5
+$as_echo_n "checking if $target support esp... " >&6; }
+  case "$target" in
+    i?86*-*-linux* | x86_64-*-linux* | powerpc*-*-linux* | mips*-*-linux* | arm*-*-linux* | ia64-*-linux*)
+      enable_esp=yes
+
+$as_echo "#define ENABLE_ESP 1" >>confdefs.h
+
+      ;;
+    *)
+      enable_esp=no
+      ;;
+  esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_esp" >&5
+$as_echo "$enable_esp" >&6; }
+fi
+
+if test $enable_esp = yes ; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking checking for crtbeginP.o support" >&5
+$as_echo_n "checking checking for crtbeginP.o support... " >&6; }
+    if test x$enable_esp = xyes ; then
+      case "$target" in
+        ia64*-*-linux*)
+          enable_crtbeginP=no ;;
+        *-*-linux*)
+          if test x$gcc_cv_ld_pie = xyes && test x$lt_cv_prog_compiler_static_works = xyes; then
+            enable_crtbeginP=yes
+
+$as_echo "#define ENABLE_CRTBEGINP 1" >>confdefs.h
+
+          fi
+          ;;
+        *) enable_crtbeginP=no ;;
+      esac
+    fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_crtbeginP" >&5
+$as_echo "$enable_crtbeginP" >&6; }
+fi
+
+
 # Configure the subdirectories
 # AC_CONFIG_SUBDIRS($subdirs)