You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.8 KiB

  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. AC_DEFUN([GGL_CHECK_STACK_PROTECTOR], [
  20. ggl_check_stack_protector_save_CXXFLAGS="$CXXFLAGS"
  21. ggl_check_stack_protector_save_CFLAGS="$CFLAGS"
  22. AC_MSG_CHECKING([if -fstack-protector and -fstack-protector-all are supported.])
  23. CXXFLAGS="$CXXFLAGS -fstack-protector"
  24. CFLAGS="$CFLAGS -fstack-protector"
  25. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  26. int main() {
  27. return 0;
  28. }
  29. ])],
  30. [ggl_check_stack_protector_ok=yes],
  31. [ggl_check_stack_protector_ok=no])
  32. CXXFLAGS="$ggl_check_stack_protector_save_CXXFLAGS -fstack-protector-all"
  33. CFLAGS="$ggl_check_stack_protector_save_CFLAGS -fstack-protector-all"
  34. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  35. int main() {
  36. return 0;
  37. }
  38. ])],
  39. [ggl_check_stack_protector_all_ok=yes],
  40. [ggl_check_stack_protector_all_ok=no])
  41. if test "x$ggl_check_stack_protector_ok" = "xyes" -a \
  42. "x$ggl_check_stack_protector_all_ok" = "xyes"; then
  43. AC_MSG_RESULT([yes])
  44. ifelse([$1], , :, [$1])
  45. else
  46. AC_MSG_RESULT([no])
  47. ifelse([$2], , :, [$2])
  48. fi
  49. CXXFLAGS="$ggl_check_stack_protector_save_CXXFLAGS"
  50. CFLAGS="$ggl_check_stack_protector_save_CFLAGS"
  51. ]) # GGL_CHECK_STACK_PROTECTOR