Reputation: 3218
I am trying to compile a fortran code with gnu-autotools
. The openmp specific lines in configure.ac
is:
AC_PROG_FC([gfortran])
AC_OPENMP
FCFLAGS="$OPENMP_FCFLAGS -fcheck=all"
If I compile with this, I am not getting omp
related compiler options, as described in the AC_OPENMP macro in autoconf manual.
If I explicitly place -fopenmp
in place of $OPENMP_FFLAGS
, only then its working.
Any help please?
Upvotes: 1
Views: 294
Reputation: 3180
Autoconf typically likes testing everything for C language by default and that's why you're only getting $OPENMP_CFLAGS
as a result for the AC_OPENMP
command. However, Autoconf also provides mechanisms to change the programming language (and therefore the compiler also) by using the AC_LANG
command (please, take a look at Autoconf / Language Choice webpage for further details and also some alternatives).
The following code has been tested using the command autoconf 2.69 and using the command: autoreconf -fiv
(also using an empty Makefile.am file).
AC_INIT([omp-fortran-sample], [1.0])
AC_PROG_CC
AC_PROG_FC([gfortran])
dnl Checks for OpenMP flag for C language, stores it in $OPENMP_CFLAGS
AC_LANG(C)
AC_OPENMP
dnl Checks for OpenMP flag for Fortran language, stores it in $OPENMP_FCFLAGS
AC_LANG(Fortran)
AC_OPENMP
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
The resulting execution of the configure shows two tests for OpenMP as seen here:
checking for gcc option to support OpenMP... -fopenmp
checking for gfortran option to support OpenMP... -fopenmp
And Makefile now includes both OPENMP_CFLAGS
and OPENMP_FCFLAGS
definitions, among the rest, as shown below:
...
MKDIR_P = /bin/mkdir -p
OBJEXT = o
OPENMP_CFLAGS = -fopenmp
OPENMP_FCFLAGS = -fopenmp
PACKAGE = omp-fortran-sample
...
Upvotes: 1