Collection of DPF-based plugins for packaging
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.

103 lines
3.9KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_f77_cmain_fflags.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_F77_CMAIN_FFLAGS([ACTION-IF-SUCCEED], [ACTION-IF-FAIL])
  8. #
  9. # DESCRIPTION
  10. #
  11. # This macro figures out if extra Fortran compiler flags are required in
  12. # order to use the Fortran linker to link programs where the main()
  13. # function is defined via C (or other language). On some systems, notably
  14. # the Alpha with Compaq compilers, the Fortran libraries have their own
  15. # main() function which must be disabled.
  16. #
  17. # Runs ACTION-IF-SUCCEED if successful, and ACTION-IF-FAIL if not. Defines
  18. # the output variable F77_CMAIN_FFLAGS to any discovered flags. (If
  19. # ACTION-IF-FAIL is not specified, defaults to halting with an error.)
  20. #
  21. # This macro is especially useful in conjunction with automake, since by
  22. # default automake uses $F77 to link programs mixing C and Fortran,
  23. # leading to a link error on some systems. In this case, you should set
  24. # the FFLAGS for that program to include F77_CMAIN_FFLAGS.
  25. #
  26. # LICENSE
  27. #
  28. # Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
  29. #
  30. # This program is free software: you can redistribute it and/or modify it
  31. # under the terms of the GNU General Public License as published by the
  32. # Free Software Foundation, either version 3 of the License, or (at your
  33. # option) any later version.
  34. #
  35. # This program is distributed in the hope that it will be useful, but
  36. # WITHOUT ANY WARRANTY; without even the implied warranty of
  37. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  38. # Public License for more details.
  39. #
  40. # You should have received a copy of the GNU General Public License along
  41. # with this program. If not, see <https://www.gnu.org/licenses/>.
  42. #
  43. # As a special exception, the respective Autoconf Macro's copyright owner
  44. # gives unlimited permission to copy, distribute and modify the configure
  45. # scripts that are the output of Autoconf when processing the Macro. You
  46. # need not follow the terms of the GNU General Public License when using
  47. # or distributing such scripts, even though portions of the text of the
  48. # Macro appear in them. The GNU General Public License (GPL) does govern
  49. # all other use of the material that constitutes the Autoconf Macro.
  50. #
  51. # This special exception to the GPL applies to versions of the Autoconf
  52. # Macro released by the Autoconf Archive. When you make and distribute a
  53. # modified version of the Autoconf Macro, you may extend this special
  54. # exception to the GPL to apply to your modified version as well.
  55. #serial 6
  56. AU_ALIAS([ACX_F77_CMAIN_FFLAGS], [AX_F77_CMAIN_FFLAGS])
  57. AC_DEFUN([AX_F77_CMAIN_FFLAGS],
  58. [AC_CACHE_CHECK([for f77 flags to use C main function], ax_cv_f77_cmain_fflags,
  59. [ax_cv_f77_cmain_fflags="unknown"
  60. AC_LANG_PUSH(C)
  61. AC_COMPILE_IFELSE([[int main(void) { return 0; }]],
  62. [mv conftest.$ac_objext conftest_cmain.$ac_objext],
  63. [ax_cv_f77_cmain_fflags=error])
  64. AC_LANG_POP(C)
  65. if test "x$ax_cv_f77_cmain_fflags" != xerror; then
  66. AC_LANG_PUSH(Fortran 77)
  67. ax_save_LIBS=$LIBS
  68. LIBS="conftest_cmain.$ac_objext $LIBS"
  69. ax_save_FFLAGS=$FFLAGS
  70. for ax_flag in none -nofor_main; do
  71. case $ax_flag in
  72. none) FFLAGS=$ax_save_FFLAGS ;;
  73. *) FFLAGS="$ax_save_FFLAGS $ax_flag" ;;
  74. esac
  75. AC_LINK_IFELSE([
  76. subroutine foobar()
  77. return
  78. end
  79. ], [ax_cv_f77_cmain_fflags=$ax_flag; break]);
  80. done
  81. FFLAGS=$ax_save_FFLAGS
  82. LIBS=$ax_save_LIBS
  83. AC_LANG_POP(Fortran 77)
  84. fi])
  85. case $ax_cv_f77_cmain_fflags in
  86. error|unknown)
  87. F77_CMAIN_FFLAGS=""
  88. ifelse([$2],,[AC_MSG_ERROR([cannot link C main with Fortran])],[$2])
  89. ;;
  90. *)
  91. if test "x$ax_cv_f77_cmain_fflags" = xnone; then
  92. F77_CMAIN_FFLAGS=""
  93. else
  94. F77_CMAIN_FFLAGS="$ax_cv_f77_cmain_fflags"
  95. fi
  96. $1
  97. ;;
  98. esac
  99. AC_SUBST(F77_CMAIN_FFLAGS)
  100. ])