fort4.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #! /bin/sh
  2. # Copyright (C) 2006-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Test mixing Fortran 77 and Fortran (FC).
  17. # For now, require the GNU compilers (to avoid some Libtool/Autoconf
  18. # issues).
  19. required='g77 gfortran'
  20. . test-init.sh
  21. mkdir sub
  22. cat >hello.f <<'END'
  23. program hello
  24. call foo
  25. call bar
  26. stop
  27. end
  28. END
  29. cat >bye.f90 <<'END'
  30. program goodbye
  31. call baz
  32. stop
  33. end
  34. END
  35. cat >foo.f90 <<'END'
  36. subroutine foo
  37. return
  38. end
  39. END
  40. sed s,foo,bar, foo.f90 > sub/bar.f90
  41. sed s,foo,baz, foo.f90 > sub/baz.f
  42. cat >>configure.ac <<'END'
  43. AC_PROG_F77
  44. AC_PROG_FC
  45. AC_FC_SRCEXT([f90], [],
  46. [AC_MSG_FAILURE([$FC compiler cannot create executables], 77)])
  47. AC_FC_LIBRARY_LDFLAGS
  48. AC_OUTPUT
  49. END
  50. cat >Makefile.am <<'END'
  51. bin_PROGRAMS = hello goodbye
  52. hello_SOURCES = hello.f foo.f90 sub/bar.f90
  53. goodbye_SOURCES = bye.f90 sub/baz.f
  54. goodbye_FCFLAGS =
  55. LDADD = $(FCLIBS)
  56. END
  57. $ACLOCAL
  58. $AUTOMAKE -a -Wno-unsupported
  59. # The Fortran 77 linker should be preferred:
  60. grep '.\$(FCLINK)' Makefile.in && exit 1
  61. $AUTOCONF
  62. # ./configure may exit with status 77 if no compiler is found,
  63. # or if the compiler cannot compile Fortran 90 files).
  64. ./configure
  65. $MAKE
  66. subobjs=$(echo sub/*.o sub/*.obj)
  67. test "$subobjs" = 'sub/*.o sub/*.obj'
  68. $MAKE distcheck
  69. $MAKE distclean
  70. echo 'AUTOMAKE_OPTIONS = subdir-objects' >> Makefile.am
  71. $AUTOMAKE
  72. ./configure
  73. $MAKE
  74. test ! -e bar.o
  75. test ! -e bar.obj
  76. test ! -e baz.o
  77. test ! -e baz.obj
  78. test ! -e goodbye-baz.o
  79. test ! -e goodbye-baz.obj
  80. $MAKE distcheck
  81. :