ax_c_check_flag.m4 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. ##### http://autoconf-archive.cryp.to/ax_c_check_flag.html
  2. #
  3. # SYNOPSIS
  4. #
  5. # AX_C_CHECK_FLAG(FLAG-TO-CHECK,[PROLOGUE],[BODY],[ACTION-IF-SUCCESS],[ACTION-IF-FAILURE])
  6. #
  7. # DESCRIPTION
  8. #
  9. # This macro tests if the C compiler supports the flag FLAG-TO-CHECK.
  10. # If successfull execute ACTION-IF-SUCCESS otherwise
  11. # ACTION-IF-FAILURE. PROLOGUE and BODY are optional and should be
  12. # used as in AC_LANG_PROGRAM macro.
  13. #
  14. # This code is inspired from KDE_CHECK_COMPILER_FLAG macro. Thanks to
  15. # Bogdan Drozdowski <bogdandr@op.pl> for testing and bug fixes.
  16. #
  17. # LAST MODIFICATION
  18. #
  19. # 2007-11-26
  20. #
  21. # COPYLEFT
  22. #
  23. # Copyright (c) 2007 Francesco Salvestrini <salvestrini@users.sourceforge.net>
  24. #
  25. # This program is free software; you can redistribute it and/or
  26. # modify it under the terms of the GNU General Public License as
  27. # published by the Free Software Foundation; either version 2 of the
  28. # License, or (at your option) any later version.
  29. #
  30. # This program is distributed in the hope that it will be useful, but
  31. # WITHOUT ANY WARRANTY; without even the implied warranty of
  32. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  33. # General Public License for more details.
  34. #
  35. # You should have received a copy of the GNU General Public License
  36. # along with this program; if not, write to the Free Software
  37. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  38. # 02111-1307, USA.
  39. #
  40. # As a special exception, the respective Autoconf Macro's copyright
  41. # owner gives unlimited permission to copy, distribute and modify the
  42. # configure scripts that are the output of Autoconf when processing
  43. # the Macro. You need not follow the terms of the GNU General Public
  44. # License when using or distributing such scripts, even though
  45. # portions of the text of the Macro appear in them. The GNU General
  46. # Public License (GPL) does govern all other use of the material that
  47. # constitutes the Autoconf Macro.
  48. #
  49. # This special exception to the GPL applies to versions of the
  50. # Autoconf Macro released by the Autoconf Macro Archive. When you
  51. # make and distribute a modified version of the Autoconf Macro, you
  52. # may extend this special exception to the GPL to apply to your
  53. # modified version as well.
  54. AC_DEFUN([AX_C_CHECK_FLAG],[
  55. AC_PREREQ([2.61])
  56. AC_REQUIRE([AC_PROG_CC])
  57. AC_REQUIRE([AC_PROG_SED])
  58. flag=`echo "$1" | $SED 'y% .=/+-(){}<>:*,%_______________%'`
  59. AC_CACHE_CHECK([whether the C compiler accepts the $1 flag],
  60. [ax_cv_c_check_flag_$flag],[
  61. AC_LANG_PUSH([C])
  62. save_CFLAGS="$CFLAGS"
  63. CFLAGS="$CFLAGS $1"
  64. AC_COMPILE_IFELSE([
  65. AC_LANG_PROGRAM([$2],[$3])
  66. ],[
  67. eval "ax_cv_c_check_flag_$flag=yes"
  68. ],[
  69. eval "ax_cv_c_check_flag_$flag=no"
  70. ])
  71. CFLAGS="$save_CFLAGS"
  72. AC_LANG_POP
  73. ])
  74. AS_IF([eval "test \"`echo '$ax_cv_c_check_flag_'$flag`\" = yes"],[
  75. :
  76. $4
  77. ],[
  78. :
  79. $5
  80. ])
  81. ])