ax_check_linker_flags.m4 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_check_linker_flags.m4
  2. # ===========================================================================
  3. # http://www.gnu.org/software/autoconf-archive/ax_check_linker_flags.html
  4. # ===========================================================================
  5. #
  6. # SYNOPSIS
  7. #
  8. # AX_CHECK_LINKER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE])
  9. #
  10. # DESCRIPTION
  11. #
  12. # Check whether the given linker FLAGS work with the current language's
  13. # linker, or whether they give an error.
  14. #
  15. # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
  16. # success/failure.
  17. #
  18. # NOTE: Based on AX_CHECK_COMPILER_FLAGS.
  19. #
  20. # LICENSE
  21. #
  22. # Copyright (c) 2009 Mike Frysinger <vapier@gentoo.org>
  23. # Copyright (c) 2009 Steven G. Johnson <stevenj@alum.mit.edu>
  24. # Copyright (c) 2009 Matteo Frigo
  25. #
  26. # This program is free software: you can redistribute it and/or modify it
  27. # under the terms of the GNU General Public License as published by the
  28. # Free Software Foundation, either version 3 of the License, or (at your
  29. # option) any later version.
  30. #
  31. # This program is distributed in the hope that it will be useful, but
  32. # WITHOUT ANY WARRANTY; without even the implied warranty of
  33. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  34. # Public License for more details.
  35. #
  36. # You should have received a copy of the GNU General Public License along
  37. # with this program. If not, see <http://www.gnu.org/licenses/>.
  38. #
  39. # As a special exception, the respective Autoconf Macro's copyright owner
  40. # gives unlimited permission to copy, distribute and modify the configure
  41. # scripts that are the output of Autoconf when processing the Macro. You
  42. # need not follow the terms of the GNU General Public License when using
  43. # or distributing such scripts, even though portions of the text of the
  44. # Macro appear in them. The GNU General Public License (GPL) does govern
  45. # all other use of the material that constitutes the Autoconf Macro.
  46. #
  47. # This special exception to the GPL applies to versions of the Autoconf
  48. # Macro released by the Autoconf Archive. When you make and distribute a
  49. # modified version of the Autoconf Macro, you may extend this special
  50. # exception to the GPL to apply to your modified version as well.
  51. #serial 6
  52. AC_DEFUN([AX_CHECK_LINKER_FLAGS],
  53. [AC_MSG_CHECKING([whether the linker accepts $1])
  54. dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
  55. AS_LITERAL_IF([$1],
  56. [AC_CACHE_VAL(AS_TR_SH(ax_cv_linker_flags_[$1]), [
  57. ax_save_FLAGS=$LDFLAGS
  58. LDFLAGS="$1"
  59. AC_LINK_IFELSE([AC_LANG_PROGRAM()],
  60. AS_TR_SH(ax_cv_linker_flags_[$1])=yes,
  61. AS_TR_SH(ax_cv_linker_flags_[$1])=no)
  62. LDFLAGS=$ax_save_FLAGS])],
  63. [ax_save_FLAGS=$LDFLAGS
  64. LDFLAGS="$1"
  65. AC_LINK_IFELSE([AC_LANG_PROGRAM()],
  66. eval AS_TR_SH(ax_cv_linker_flags_[$1])=yes,
  67. eval AS_TR_SH(ax_cv_linker_flags_[$1])=no)
  68. LDFLAGS=$ax_save_FLAGS])
  69. eval ax_check_linker_flags=$AS_TR_SH(ax_cv_linker_flags_[$1])
  70. AC_MSG_RESULT($ax_check_linker_flags)
  71. if test "x$ax_check_linker_flags" = xyes; then
  72. m4_default([$2], :)
  73. else
  74. m4_default([$3], :)
  75. fi
  76. ])dnl AX_CHECK_LINKER_FLAGS