source: trunk/m4/netcdf.m4 @ 7807

Revision 7807, 1.9 KB checked in by xavier, 3 years ago (diff)

My turn with the exquisite corpse:

  • Removed all the preprocessor macro definitions from the abinit

compiler detection routine. Otherwise we may end up with compiler
dependent code, which is a very bad idea.

  • Distributions follow the FHS and put the etsf_io modules directly in

include/, so now both variants are checked.

  • The include flags are printed together with the library flags.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1AC_DEFUN([ACX_NETCDF], [
2acx_netcdf_ok=no
3
4dnl Check if the library was given in the command line
5AC_ARG_WITH(netcdf-prefix, [AS_HELP_STRING([--with-netcdf-prefix=DIR], [Directory where netcdf was installed.])])
6case $with_netcdf_prefix in
7  no ) acx_netcdf_ok=disabled ;;
8  "") if test x$FCFLAGS_NETCDF == x; then
9    FCFLAGS_NETCDF="-I/usr/include"
10  fi;;
11  *) LIBS_NETCDF="-L$with_netcdf_prefix/lib"; FCFLAGS_NETCDF="$ax_cv_f90_modflag$with_netcdf_prefix/include" ;;
12esac
13
14AC_ARG_WITH(netcdf-include, [AS_HELP_STRING([--with-netcdf-include=DIR], [Directory where netcdf Fortran headers were installed.])])
15case $with_netcdf_include in
16  "") ;;
17  *)  FCFLAGS_NETCDF="$ax_cv_f90_modflag$with_netcdf_include" ;;
18esac
19
20dnl Backup LIBS and FCFLAGS
21acx_netcdf_save_LIBS="$LIBS"
22acx_netcdf_save_FCFLAGS="$FCFLAGS"
23
24dnl The tests
25AC_MSG_CHECKING([for netcdf])
26if test "$acx_netcdf_ok" != disabled; then
27  netcdf_fcflags="$FCFLAGS_NETCDF"
28  FCFLAGS="$netcdf_fcflags $acx_netcdf_save_FCFLAGS"
29  for netcdf_libsl in "" -lnetcdf "-lnetcdff -lnetcdf"; do
30    netcdf_libs="$LIBS_NETCDF $netcdf_libsl"
31    LIBS="$netcdf_libs $acx_netcdf_save_LIBS"
32    AC_LINK_IFELSE(AC_LANG_PROGRAM([],[
33      use netcdf
34      integer :: ncid
35      integer :: status
36      status = nf90_close(ncid)
37    ]), [acx_netcdf_ok=yes; FCFLAGS_NETCDF="$netcdf_fcflags"; LIBS_NETCDF="$netcdf_libs"], [])
38    if test $acx_netcdf_ok == yes; then
39      LIBS_NETCDF=$netcdf_libs
40      break
41    fi
42  done
43fi
44AC_MSG_RESULT([$acx_netcdf_ok ($FCFLAGS_NETCDF $LIBS_NETCDF)])
45
46dnl Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
47if test x"$acx_netcdf_ok" = xyes; then
48  AC_DEFINE(HAVE_NETCDF,1,[Defined if you have NETCDF library.])
49  $1
50else
51  AC_MSG_WARN([Could not find NetCDF library.
52              *** Will compile without NetCDF and ETSF I/O support])
53  FCFLAGS_NETCDF=""
54  LIBS_NETCDF=""
55  $2
56fi
57
58AC_SUBST(FCFLAGS_NETCDF)
59AC_SUBST(LIBS_NETCDF)
60FCFLAGS="$acx_netcdf_save_FCFLAGS"
61LIBS="$acx_netcdf_save_LIBS"
62])dnl ACX_NETCDF
Note: See TracBrowser for help on using the repository browser.