Skip to content
Snippets Groups Projects
fortran_overwrite.m4 2.7 KiB
Newer Older
  • Learn to ignore specific revisions
  • # overwrite an internal function of autoconf
    #
    # The function below caused configure to abort if no fortran was available.
    # Changed it to just report a warning that we cannot compile
    # fortran programms.
    
    # __AC_FC_NAME_MANGLING
    # ---------------------
    # Test for the name mangling scheme used by the Fortran compiler.
    #
    # Sets ac_cv_{f77,fc}_mangling. The value contains three fields, separated
    # by commas:
    #
    # lower case / upper case:
    #    case translation of the Fortran symbols
    # underscore / no underscore:
    #    whether the compiler appends "_" to symbol names
    # extra underscore / no extra underscore:
    #    whether the compiler appends an extra "_" to symbol names already
    #    containing at least one underscore
    #
    AC_DEFUN([__AC_FC_NAME_MANGLING],
    [_AC_FORTRAN_ASSERT()dnl
    AC_CACHE_CHECK([for Fortran name-mangling scheme],
                   ac_cv_[]_AC_LANG_ABBREV[]_mangling,
    
    Martin Nolte's avatar
    Martin Nolte committed
    [AC_COMPILE_IFELSE([AC_LANG_SOURCE(
    
    [      subroutine foobar()
          return
          end
          subroutine foo_bar()
          return
    
    Martin Nolte's avatar
    Martin Nolte committed
          end])],
    
    [mv conftest.$ac_objext cfortran_test.$ac_objext
    
      ac_save_LIBS=$LIBS
      LIBS="cfortran_test.$ac_objext $LIBS $[]_AC_LANG_PREFIX[]LIBS"
    
      AC_LANG_PUSH(C)dnl
      ac_success=no
      for ac_foobar in foobar FOOBAR; do
        for ac_underscore in "" "_"; do
          ac_func="$ac_foobar$ac_underscore"
          AC_LINK_IFELSE([AC_LANG_CALL([], [$ac_func])],
    		     [ac_success=yes; break 2])
        done
      done
      AC_LANG_POP(C)dnl
    
      if test "$ac_success" = "yes"; then
         case $ac_foobar in
    	foobar)
    	   ac_case=lower
    	   ac_foo_bar=foo_bar
    	   ;;
    	FOOBAR)
    	   ac_case=upper
    	   ac_foo_bar=FOO_BAR
    	   ;;
         esac
    
         AC_LANG_PUSH(C)dnl
         ac_success_extra=no
         for ac_extra in "" "_"; do
    	ac_func="$ac_foo_bar$ac_underscore$ac_extra"
    	AC_LINK_IFELSE([AC_LANG_CALL([], [$ac_func])],
    		       [ac_success_extra=yes; break])
         done
         AC_LANG_POP(C)dnl
    
         if test "$ac_success_extra" = "yes"; then
    	ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_case case"
            if test -z "$ac_underscore"; then
               ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, no underscore"
    	else
               ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, underscore"
            fi
            if test -z "$ac_extra"; then
               ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, no extra underscore"
    	else
               ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, extra underscore"
            fi
          else
    	ac_cv_[]_AC_LANG_ABBREV[]_mangling="unknown"
          fi
      else
         ac_cv_[]_AC_LANG_ABBREV[]_mangling="unknown"
      fi
    
      LIBS=$ac_save_LIBS
      rm -f cfortran_test* conftest*],
      [AC_MSG_WARN([cannot compile a simple Fortran program])])
    ])
    ])# __AC_FC_NAME_MANGLING