[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AC_OPENMP / AC_LANG_FUNC_LINK_TRY: unknown language: Fortran
From: |
Ralf Wildenhues |
Subject: |
Re: AC_OPENMP / AC_LANG_FUNC_LINK_TRY: unknown language: Fortran |
Date: |
Fri, 30 Oct 2009 19:22:48 +0100 |
User-agent: |
Mutt/1.5.20 (2009-08-09) |
> * Bart Oldeman wrote on Wed, Oct 28, 2009 at 02:06:26PM CET:
> > autoconf refuses this reduced script:
> >
> > AC_INIT
> > AC_LANG(Fortran)
> > AC_OPENMP
> >
> > using
> > configure.ac:3: error: AC_LANG_FUNC_LINK_TRY: unknown language: Fortran
> > ../../lib/autoconf/lang.m4:228: AC_LANG_FUNC_LINK_TRY is expanded from...
> > ../../lib/autoconf/c.m4:1879: _AC_LANG_OPENMP is expanded from...
OK to push these two patches, and add Bart to THANKS?
The OpenMP tests can probably be made stricter for non-C; maybe adding a
mixed language test later would be good, too (putting on my todo list).
I'm not all that fond of _AC_CC in the second patch, as it is in a
central location rather than grouped with each language (makes
third-party additions harder), so maybe it should derive from
per-language defines instead? Anyway, that patch is not so critical.
Thanks,
Ralf
Fix AC_OPENMP for Fortran (F77 and FC).
* lib/autoconf/fortran.m4 (AC_LANG_FUNC_LINK_TRY(Fortran): New.
* tests/c.at (AC_C_RESTRICT and C++, AC_OPENMP and C)
(AC_OPENMP and C++): New tests.
* tests/fortran.at (AC_OPENMP and Fortran 77)
(AC_OPENMP and Fortran): New tests.
* THANKS: Update.
Report by Bart Oldeman.
diff --git a/lib/autoconf/fortran.m4 b/lib/autoconf/fortran.m4
index 2548716..a7e5089 100644
--- a/lib/autoconf/fortran.m4
+++ b/lib/autoconf/fortran.m4
@@ -207,6 +207,11 @@ m4_define([AC_LANG_CALL(Fortran 77)],
[ call $2])])
+# AC_LANG_FUNC_LINK_TRY(Fortran 77)(FUNCTION)
+# -------------------------------------------
+m4_define([AC_LANG_FUNC_LINK_TRY(Fortran 77)],
+[AC_LANG_PROGRAM([],
+[ call $1])])
## ------------------------ ##
## 1b. Language selection. ##
diff --git a/tests/c.at b/tests/c.at
index 8235be2..78edf45 100644
--- a/tests/c.at
+++ b/tests/c.at
@@ -320,3 +320,100 @@ AT_CHECK([${MAKE-make} cpp-works || exit 77], [],
[ignore], [ignore])
AT_CHECK([${MAKE-make}], [], [ignore], [ignore])
AT_CLEANUP
+
+
+## ---------------- ##
+## AC_OPENMP and C. ##
+## ---------------- ##
+
+AT_SETUP([AC_OPENMP and C])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_CC
+AC_OPENMP
+if test "X$ac_cv_prog_c_openmp" = Xunsupported; then
+ AS_EXIT([77])
+fi
+CFLAGS="$CFLAGS $OPENMP_CFLAGS"
+CPPFLAGS="$CPPFLAGS $OPENMP_CFLAGS"
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
address@hidden@: address@hidden@
+ @CC@ @CFLAGS@ @LDFLAGS@ -o $@ address@hidden@
+
address@hidden@: foo.c
+ @CC@ @CPPFLAGS@ @CFLAGS@ -c foo.c
+]])
+
+AT_DATA([foo.c],
+[[#ifdef _OPENMP
+#include <omp.h>
+#endif
+#include <stdio.h>
+
+int main ()
+{
+#ifdef _OPENMP
+#pragma omp parallel
+ {
+ int id = omp_get_thread_num ();
+ printf ("hello omp world from %d\n", id);
+ }
+#endif
+ return 0;
+}
+]])
+
+: ${MAKE=make}
+AT_CHECK([autoreconf -vi], [], [ignore], [ignore])
+AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+
+AT_CLEANUP
+
+
+## ------------------ ##
+## AC_OPENMP anc C++. ##
+## ------------------ ##
+
+AT_SETUP([AC_OPENMP and C++])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_CXX
+AC_LANG([C++])
+AC_OPENMP
+if test "X$ac_cv_prog_cxx_openmp" = Xunsupported; then
+ AS_EXIT([77])
+fi
+CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"
+CPPFLAGS="$CPPFLAGS $OPENMP_CXXFLAGS"
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
address@hidden@: address@hidden@
+ @CXX@ @CXXFLAGS@ @LDFLAGS@ -o $@ address@hidden@
+
address@hidden@: foo.cpp
+ @CXX@ @CPPFLAGS@ @CXXFLAGS@ -c foo.cpp
+]])
+
+AT_DATA([foo.cpp],
+[[int main ()
+{
+ return 0;
+}
+]])
+
+: ${MAKE=make}
+AT_CHECK([autoreconf -vi], [], [ignore], [ignore])
+AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+
+AT_CLEANUP
diff --git a/tests/fortran.at b/tests/fortran.at
index ed58ee7..151b13f 100644
--- a/tests/fortran.at
+++ b/tests/fortran.at
@@ -73,3 +73,83 @@ if test "$ac_compiler_gnu" = yes; then
esac
fi
]])
+
+
+## ------------------------- ##
+## AC_OPENMP and Fortran 77. ##
+## ------------------------- ##
+
+AT_SETUP([AC_OPENMP and Fortran 77])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_F77
+AC_LANG([Fortran 77])
+AC_OPENMP
+if test "X$ac_cv_prog_f77_openmp" = Xunsupported; then
+ AS_EXIT([77])
+fi
+FFLAGS="$FFLAGS $OPENMP_FFLAGS"
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
address@hidden@: address@hidden@
+ @F77@ @FFLAGS@ @LDFLAGS@ -o $@ address@hidden@
+
address@hidden@: foo.f
+ @F77@ @FFLAGS@ -c foo.f
+]])
+
+AT_DATA([foo.f],
+[[ program main
+ end
+]])
+
+: ${MAKE=make}
+AT_CHECK([autoreconf -vi], [], [ignore], [ignore])
+AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+
+AT_CLEANUP
+
+
+## ---------------------- ##
+## AC_OPENMP and Fortran. ##
+## ---------------------- ##
+
+AT_SETUP([AC_OPENMP and Fortran])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_FC
+AC_LANG([Fortran])
+AC_OPENMP
+if test "X$ac_cv_prog_fc_openmp" = Xunsupported; then
+ AS_EXIT([77])
+fi
+FCFLAGS="$FCFLAGS $OPENMP_FCFLAGS"
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+]])
+
+AT_DATA([Makefile.in],
address@hidden@: address@hidden@
+ @FC@ @FCFLAGS@ @LDFLAGS@ -o $@ address@hidden@
+
address@hidden@: foo.f
+ @FC@ @FCFLAGS@ -c foo.f
+]])
+
+AT_DATA([foo.f],
+[[ program main
+ end
+]])
+
+: ${MAKE=make}
+AT_CHECK([autoreconf -vi], [], [ignore], [ignore])
+AT_CHECK([./configure $configure_options], [], [ignore], [ignore])
+AT_CHECK([$MAKE], [], [ignore], [ignore])
+
+AT_CLEANUP
Fix AC_OPENMP configure message for non-C compilers.
* lib/autoconf/lang.m4 (_AC_CC): New macro.
* lib/autoconf/c.m4 (AC_OPENMP): Use it instead of $CC.
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index 8df6bf9..09d5f8e 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -1971,7 +1971,7 @@ AC_DEFUN([AC_OPENMP],
AC_ARG_ENABLE([openmp],
[AS_HELP_STRING([--disable-openmp], [do not use OpenMP])])
if test "$enable_openmp" != no; then
- AC_CACHE_CHECK([for $CC option to support OpenMP],
+ AC_CACHE_CHECK([for $]_AC_CC[ option to support OpenMP],
[ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp],
[AC_LINK_IFELSE([_AC_LANG_OPENMP],
[ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp='none needed'],
diff --git a/lib/autoconf/lang.m4 b/lib/autoconf/lang.m4
index c05612b..5c746c5 100644
--- a/lib/autoconf/lang.m4
+++ b/lib/autoconf/lang.m4
@@ -290,6 +290,17 @@ AC_DEFUN([AC_LANG_INT_SAVE],
## -------------------------------------------- ##
+# _AC_CC
+# ------
+# The variable name of the compiler.
+m4_define([_AC_CC],
+[AC_LANG_CASE([C], [CC],
+ [C++], [CXX],
+ [Fortran 77], [F77],
+ [Fortran], [FC],
+ [Erlang], [ERLC])])
+
+
# AC_LANG_COMPILER
# ----------------
# Find a compiler for the current LANG. Be sure to be run before
- Re: AC_OPENMP / AC_LANG_FUNC_LINK_TRY: unknown language: Fortran,
Ralf Wildenhues <=