Changeset 120


Ignore:
Timestamp:
Sep 5, 2007, 10:36:38 PM (17 years ago)
Author:
rainer
Message:

Fix for ticket #76 (compile error with -f-stack-protector).

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/aclocal.m4

    r68 r120  
    10651065dnl Useful macros for autoconf to check for ssp-patched gcc
    10661066dnl 1.0 - September 2003 - Tiago Sousa <mirage@kaotik.org>
     1067dnl 1.1 - August 2006 - Ted Percival <ted@midg3t.net>
     1068dnl     * Stricter language checking (C or C++)
     1069dnl     * Adds GCC_STACK_PROTECT_LIB to add -lssp to LDFLAGS as necessary
     1070dnl     * Caches all results
     1071dnl     * Uses macros to ensure correct ouput in quiet/silent mode
     1072dnl 1.2 - April 2007 - Ted Percival <ted@midg3t.net>
     1073dnl     * Added GCC_STACK_PROTECTOR macro for simpler (one-line) invocation
     1074dnl     * GCC_STACK_PROTECT_LIB now adds -lssp to LIBS rather than LDFLAGS
    10671075dnl
    10681076dnl About ssp:
     
    10711079dnl
    10721080dnl Usage:
    1073 dnl After calling the correct AC_LANG_*, use the corresponding macro:
     1081dnl Most people will simply call GCC_STACK_PROTECTOR.
     1082dnl If you only use one of C or C++, you can save time by only calling the
     1083dnl macro appropriate for that language. In that case you should also call
     1084dnl GCC_STACK_PROTECT_LIB first.
     1085dnl
     1086dnl GCC_STACK_PROTECTOR
     1087dnl Tries to turn on stack protection for C and C++ by calling the following
     1088dnl three macros with the right languages.
    10741089dnl
    10751090dnl GCC_STACK_PROTECT_CC
     
    10771092dnl CFLAGS and defines ENABLE_SSP_CC
    10781093dnl
     1094dnl GCC_STACK_PROTECT_CXX
     1095dnl checks -fstack-protector with the C++ compiler, if it exists then updates
     1096dnl CXXFLAGS and defines ENABLE_SSP_CXX
     1097dnl
     1098dnl GCC_STACK_PROTECT_LIB
     1099dnl adds -lssp to LIBS if it is available
     1100dnl ssp is usually provided as part of libc, but was previously a separate lib
     1101dnl It does not hurt to add -lssp even if libc provides SSP - in that case
     1102dnl libssp will simply be ignored.
     1103dnl
     1104
     1105AC_DEFUN([GCC_STACK_PROTECT_LIB],[
     1106  AC_CACHE_CHECK([whether libssp exists], ssp_cv_lib,
     1107    [ssp_old_libs="$LIBS"
     1108     LIBS="$LIBS -lssp"
     1109     AC_TRY_LINK(,, ssp_cv_lib=yes, ssp_cv_lib=no)
     1110     LIBS="$ssp_old_libs"
     1111    ])
     1112  if test $ssp_cv_lib = yes; then
     1113    LIBS="$LIBS -lssp"
     1114  fi
     1115])
     1116
    10791117AC_DEFUN([GCC_STACK_PROTECT_CC],[
    1080   ssp_cc=yes
    1081   if test "X$GCC" = "Xyes"; then
    1082     AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
    1083     ssp_old_cflags="$CFLAGS"
    1084     CFLAGS="$CFLAGS -fstack-protector"
    1085     AC_TRY_LINK(,,, ssp_cc=no)
    1086     # echo $ssp_cc
    1087     if test "X$ssp_cc" = "Xno"; then
    1088       CFLAGS="$ssp_old_cflags"
    1089       AC_MSG_RESULT(no)
    1090     else
    1091       AC_MSG_RESULT(yes)
     1118  AC_LANG_ASSERT(C)
     1119  if test "X$CC" != "X"; then
     1120    AC_CACHE_CHECK([whether ${CC} accepts -fstack-protector],
     1121      ssp_cv_cc,
     1122      [ssp_old_cflags="$CFLAGS"
     1123       CFLAGS="$CFLAGS -fstack-protector"
     1124       AC_TRY_COMPILE(,, ssp_cv_cc=yes, ssp_cv_cc=no)
     1125       CFLAGS="$ssp_old_cflags"
     1126      ])
     1127    if test $ssp_cv_cc = yes; then
     1128      CFLAGS="$CFLAGS -fstack-protector"
    10921129      AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
    10931130    fi
    10941131  fi
    10951132])
     1133
     1134AC_DEFUN([GCC_STACK_PROTECT_CXX],[
     1135  AC_LANG_ASSERT(C++)
     1136  if test "X$CXX" != "X"; then
     1137    AC_CACHE_CHECK([whether ${CXX} accepts -fstack-protector],
     1138      ssp_cv_cxx,
     1139      [ssp_old_cxxflags="$CXXFLAGS"
     1140       CXXFLAGS="$CXXFLAGS -fstack-protector"
     1141       AC_TRY_COMPILE(,, ssp_cv_cxx=yes, ssp_cv_cxx=no)
     1142       CXXFLAGS="$ssp_old_cxxflags"
     1143      ])
     1144    if test $ssp_cv_cxx = yes; then
     1145      CXXFLAGS="$CXXFLAGS -fstack-protector"
     1146      AC_DEFINE([ENABLE_SSP_CXX], 1, [Define if SSP C++ support is enabled.])
     1147    fi
     1148  fi
     1149])
     1150
     1151AC_DEFUN([GCC_STACK_PROTECTOR],[
     1152  GCC_STACK_PROTECT_LIB
     1153
     1154  AC_LANG_PUSH([C])
     1155  GCC_STACK_PROTECT_CC
     1156  AC_LANG_POP([C])
     1157
     1158  AC_LANG_PUSH([C++])
     1159  GCC_STACK_PROTECT_CXX
     1160  AC_LANG_POP([C++])
     1161])
     1162
     1163
    10961164
    10971165AC_DEFUN([SAMHAIN_POSIX],[
  • trunk/configure.ac

    r118 r120  
    3434AC_SUBST(BUILD_CC)
    3535
     36GCC_STACK_PROTECT_LIB
    3637GCC_STACK_PROTECT_CC
    37 
    3838
    3939AC_HEADER_STDC
Note: See TracChangeset for help on using the changeset viewer.