]> andersk Git - openssh.git/blobdiff - configure.ac
- (tim) [regress/sftp-cmds.sh] s/cd/lcd/ in lls test. Reported by
[openssh.git] / configure.ac
index b2b764f2ea35c0cc5cabe9065d1eac51f47e1758..68cac01ae569d39318bc61aec6652325df53d175 100644 (file)
@@ -90,6 +90,13 @@ AC_C_INLINE
 
 AC_CHECK_DECL(LLONG_MAX, have_llong_max=1, , [#include <limits.h>])
 
+use_stack_protector=1
+AC_ARG_WITH(stackprotect,
+    [  --without-stackprotect Don't use compiler's stack protection], [
+    if test "x$withval" = "xno"; then
+       use_stack_protector=0
+    fi ])
+
 if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
        CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wuninitialized"
        GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'`
@@ -105,18 +112,43 @@ if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
                *) ;;
        esac
 
-       AC_MSG_CHECKING(if $CC understands -fstack-protector-all)
-       saved_CFLAGS="$CFLAGS"
-       saved_LDFLAGS="$LDFLAGS"
-       CFLAGS="$CFLAGS -fstack-protector-all"
-       LDFLAGS="$LDFLAGS -fstack-protector-all"
-       AC_TRY_LINK([], [ int main(void){return 0;} ],
-           [ AC_MSG_RESULT(yes) ],
-           [ AC_MSG_RESULT(no)
-             CFLAGS="$saved_CFLAGS"
-             LDFLAGS="$saved_LDFLAGS"
-            ]
-       )
+       # -fstack-protector-all doesn't always work for some GCC versions
+       # and/or platforms, so we test if we can.  If it's not supported
+       # on a give platform gcc will emit a warning so we use -Werror.
+       if test "x$use_stack_protector" = "x1"; then
+           for t in -fstack-protector-all -fstack-protector; do
+               AC_MSG_CHECKING(if $CC supports $t)
+               saved_CFLAGS="$CFLAGS"
+               saved_LDFLAGS="$LDFLAGS"
+               CFLAGS="$CFLAGS $t -Werror"
+               LDFLAGS="$LDFLAGS $t -Werror"
+               AC_LINK_IFELSE(
+                       [AC_LANG_SOURCE([
+#include <stdlib.h>
+int main(void){return 0;}
+                        ])],
+                   [ AC_MSG_RESULT(yes)
+                     CFLAGS="$saved_CFLAGS $t"
+                     LDFLAGS="$saved_LDFLAGS $t"
+                     AC_MSG_CHECKING(if $t works)
+                     AC_RUN_IFELSE(
+                       [AC_LANG_SOURCE([
+#include <stdlib.h>
+int main(void){exit(0);}
+                       ])],
+                       [ AC_MSG_RESULT(yes)
+                         break ],
+                       [ AC_MSG_RESULT(no) ],
+                       [ AC_MSG_WARN([cross compiling: cannot test])
+                         break ]
+                     )
+                   ],
+                   [ AC_MSG_RESULT(no) ]
+               )
+               CFLAGS="$saved_CFLAGS"
+               LDFLAGS="$saved_LDFLAGS"
+           done
+       fi
 
        if test -z "$have_llong_max"; then
                # retry LLONG_MAX with -std=gnu99, needed on some Linuxes
This page took 0.035244 seconds and 4 git commands to generate.