1# 2# Copyright 2007 Google Inc. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16# GGL_CHECK_STACK_PROTECTOR([ACTION-IF-OK], [ACTION-IF-NOT-OK]) 17# Check if c compiler supports -fstack-protector and -fstack-protector-all 18# options. 19 20AC_DEFUN([GGL_CHECK_STACK_PROTECTOR], [ 21ggl_check_stack_protector_save_CXXFLAGS="$CXXFLAGS" 22ggl_check_stack_protector_save_CFLAGS="$CFLAGS" 23 24AC_MSG_CHECKING([if -fstack-protector and -fstack-protector-all are supported.]) 25 26CXXFLAGS="$CXXFLAGS -fstack-protector" 27CFLAGS="$CFLAGS -fstack-protector" 28AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 29int main() { 30 return 0; 31} 32])], 33[ggl_check_stack_protector_ok=yes], 34[ggl_check_stack_protector_ok=no]) 35 36CXXFLAGS="$ggl_check_stack_protector_save_CXXFLAGS -fstack-protector-all" 37CFLAGS="$ggl_check_stack_protector_save_CFLAGS -fstack-protector-all" 38AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 39int main() { 40 return 0; 41} 42])], 43[ggl_check_stack_protector_all_ok=yes], 44[ggl_check_stack_protector_all_ok=no]) 45 46if test "x$ggl_check_stack_protector_ok" = "xyes" -a \ 47 "x$ggl_check_stack_protector_all_ok" = "xyes"; then 48 AC_MSG_RESULT([yes]) 49 ifelse([$1], , :, [$1]) 50else 51 AC_MSG_RESULT([no]) 52 ifelse([$2], , :, [$2]) 53fi 54 55CXXFLAGS="$ggl_check_stack_protector_save_CXXFLAGS" 56CFLAGS="$ggl_check_stack_protector_save_CFLAGS" 57 58]) # GGL_CHECK_STACK_PROTECTOR 59