Discussion:
OPENMP_FLAGS in autoconf not working
Rudra Banerjee
2016-06-23 11:54:01 UTC
Permalink
I am trying to compile a fortran code with gnu-autotools. The openmp
specific lines in configure.ac is:

AC_OPENMP
AC_PROG_FC([gfortran])
FCFLAGS="$OPENMP_FFLAGS -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?
Nick Bowler
2016-06-23 14:24:40 UTC
Permalink
Hello,
Post by Rudra Banerjee
I am trying to compile a fortran code with gnu-autotools. The openmp
AC_OPENMP
AC_PROG_FC([gfortran])
FCFLAGS="$OPENMP_FFLAGS -fcheck=all"
The tests performed by AC_OPENMP (and the variables set) depend on
the current language. You have not posted a complete, compilable
configure.ac, but unless you've done something else to switch the
language, the default language is C.

It's also strange to test for openmp before testing the compiler --
this will probably not do what you intended. Also, you are testing
for modern Fortran (AC_PROG_FC) yet OPENMP_FFLAGS is for Fortan 77,
which is probably not what you wanted.

Try this:

AC_INIT([test], [0])

AC_LANG([Fortran])
AC_PROG_FC
AC_OPENMP

printf 'OPENMP_FCFLAGS = %s\n' "$OPENMP_FCFLAGS"

AC_OUTPUT

Cheers,
Nick
Rudra Banerjee
2016-06-23 14:51:45 UTC
Permalink
Hi,
Thanks a lot for your reply. But this (AC_LANG) is making make to
crash.
Copying your configure.ac, I am getting:

$./configure 
checking for gfortran... gfortran
checking whether the Fortran compiler works... yes
checking for Fortran compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU Fortran compiler... yes
checking whether gfortran accepts -g... yes
checking for gfortran option to support OpenMP... -fopenmp
OPENMP_FCFLAGS = -fopenmp
configure: creating ./config.status

$make
Makefile:15: *** missing separator.  Stop.
Post by Nick Bowler
Hello,
Post by Rudra Banerjee
I am trying to compile a fortran code with gnu-autotools. The openmp
AC_OPENMP
AC_PROG_FC([gfortran])
FCFLAGS="$OPENMP_FFLAGS -fcheck=all"
The tests performed by AC_OPENMP (and the variables set) depend on
the current language.  You have not posted a complete, compilable
configure.ac, but unless you've done something else to switch the
language, the default language is C.
It's also strange to test for openmp before testing the compiler --
this will probably not do what you intended.  Also, you are testing
for modern Fortran (AC_PROG_FC) yet OPENMP_FFLAGS is for Fortan 77,
which is probably not what you wanted.
  AC_INIT([test], [0])
  AC_LANG([Fortran])
  AC_PROG_FC
  AC_OPENMP
  printf 'OPENMP_FCFLAGS = %s\n' "$OPENMP_FCFLAGS"
  AC_OUTPUT
Cheers,
  Nick
Rudra Banerjee
2016-06-23 15:06:03 UTC
Permalink
Hi Nick,
Taking all your comments into account, my current configure.ac is:
#!/bin/bash 

AC_INIT([src], [0.4],[],
[kmc],[])

AC_LANG([Fortran])

AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([1.9.6 dist-bzip2 subdir-objects foreign])

#AC_SEARCH_LIBS([dsyev_], [lapack], ,AC_MSG_ERROR([No LAPACK library]))
AC_PROG_FC([ifort gfortran])
AC_OPENMP
printf 'OPENMP_FCFLAGS = %s\n' "$OPENMP_FCFLAGS"
FCFLAGS="$OPENMP_FCFLAGS -fcheck=all"
if test $FC == "ifort"; then
  FCFLAGS="$OPENMP_FCFLAGS -check all"
fi
AC_CHECK_PROG([DEPF90_CHECK],[makedepf90],[yes],[no])
AM_CONDITIONAL([FOUND_MAKEDEPF90], [test "x$DEPF90_CHECK" = xyes])
AC_CONFIG_FILES([
 Makefile
 ])
AC_OUTPUT

Here also, `AC_LANG` is crashing the make:

./configure 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for ifort... ifort
checking whether the Fortran compiler works... yes
checking for Fortran compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU Fortran compiler... no
checking whether ifort accepts -g... yes
checking for ifort option to support OpenMP... -fopenmp
OPENMP_FCFLAGS = -fopenmp
checking for makedepf90... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: config.h is unchanged


$make
Makefile:752: *** missing separator.  Stop.


if I just comment out AC_LANG line, then, as you said, OPENMP_FCFLAGS
doesnot have a value:

checking whether we are using the GNU Fortran compiler... no
checking whether ifort accepts -g... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... none
checking for gcc option to support OpenMP... -fopenmp
OPENMP_FCFLAGS = 
checking for makedepf90... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands

But the make is running:
make
make  all-am
...
make[1]: Leaving directory '/home/rudra/Devel/kmc/NEW'

The difference between the configure.ac is the AC_LANG is commented;
Nothing else has been changed in this two.
Please comment.
Post by Nick Bowler
Hello,
The tests performed by AC_OPENMP (and the variables set) depend on
the current language.  You have not posted a complete, compilable
configure.ac, but unless you've done something else to switch the
language, the default language is C.
It's also strange to test for openmp before testing the compiler --
this will probably not do what you intended.  Also, you are testing
for modern Fortran (AC_PROG_FC) yet OPENMP_FFLAGS is for Fortan 77,
which is probably not what you wanted.
  AC_INIT([test], [0])
  AC_LANG([Fortran])
  AC_PROG_FC
  AC_OPENMP
  printf 'OPENMP_FCFLAGS = %s\n' "$OPENMP_FCFLAGS"
  AC_OUTPUT
Cheers,
  Nick
Zack Weinberg
2016-06-23 16:54:29 UTC
Permalink
$make
Makefile:752: *** missing separator. Stop.
Please send us the **unedited** output of

$ sed -ne '745,760p' Makefile

(with a Makefile that produces the "missing separator" error message)

zw
Rudra Banerjee
2016-06-23 18:17:09 UTC
Permalink
Hi,
The output is:
mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall
\
uninstall-am uninstall-binPROGRAMS

.PRECIOUS: Makefile

depend depend.mk:
makedepf90 $(kmc_SOURCES) >depend.mk
@am__include@ @***@depend.mk@am__quote@
#$(warning Create the dependencies Manually or try installing
makedepf90)
#$(error  like ./src/main.o:./src/main.f90)

# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

The problematic line is:

depend depend.mk:
makedepf90 $(kmc_SOURCES) >depend.mk
@am__include@ @***@depend.mk@am__quote@

This is sourced from my Makefile.am:

bin_PROGRAMS = kmc
kmc_SOURCES = src/main.f90 src/constants.f90 src/genlat.f90
src/util.f90 src/neighbourlist.f90
if FOUND_MAKEDEPF90
depend depend.mk:
makedepf90 $(kmc_SOURCES) >depend.mk
@am__include@ @***@depend.mk@am__quote@
else
$(warning Create the dependencies Manually or try installing
makedepf90)
$(error  like ./src/main.o:./src/main.f90)
endif
kmc_LDADD = 
EXTRA_DIST=depend.mk autogen.sh Makefile kmc.in 
CLEANFILES =*.mod  *.log

but if I make @am_include tab intended, then I get error for depend.mk:

make depend
makedepf90 src/main.f90 src/constants.f90 src/genlat.f90 src/util.f90
src/neighbourlist.f90 >depend.mk
make: am__include@: Command not found
Makefile:751: recipe for target 'depend' failed

Regards, 
Rudra
Post by Zack Weinberg
 
Post by Rudra Banerjee
$make
Makefile:752: *** missing separator.  Stop.
Please send us the **unedited** output of
$ sed -ne '745,760p' Makefile
(with a Makefile that produces the "missing separator" error message)
zw
Rudra Banerjee
2016-06-23 18:31:02 UTC
Permalink
Sorry that I have pressed send button too early.
If I comment the AC_LANG in configure.ac, the corresponding line in
Makefile is:

depend depend.mk:
makedepf90 $(kmc_SOURCES) >depend.mk
include depend.mk

what i want.

Regards,
Rudra
Post by Zack Weinberg
Post by Rudra Banerjee
$make
Makefile:752: *** missing separator.  Stop.
Please send us the **unedited** output of
$ sed -ne '745,760p' Makefile
(with a Makefile that produces the "missing separator" error message)
zw
Loading...