11dnl Process this file with autoconf to produce a configure script.
22
3- AC_PREREQ ( 2.59 )
3+ AC_PREREQ ( 2.62 )
44
55dnl Init basic data for package
66dnl define following variables :
@@ -9,23 +9,23 @@ dnl - PACKAGE_TARNAME, the name used for the tarball ;
99dnl - PACKAGE_VERSION, the version ;
1010dnl - PACKAGE_STRING, the name + the version ;
1111dnl - PACKAGE_BUGREPORT, the mail.
12- AC_INIT ( [ ETSF - IO library] ,
[ 1.0.3 ] ,
[ [email protected] ] ,
[ etsf_io] ) 12+ AC_INIT ( [ ETSF - IO library] , [ 1.0.4 ] , [ https://bugs.launchpad.net/etsf-io ] , [ etsf_io] )
1313
1414dnl All temporary building files are put in this directory.
1515dnl his must be called before AM_INIT_AUTOMAKE
16- AC_CONFIG_AUX_DIR ( config )
16+ AC_CONFIG_AUX_DIR ( [ config] )
1717AC_CONFIG_MACRO_DIR ( [ config/m4] )
1818
1919dnl Init something, don't know exactly what...
20- AM_INIT_AUTOMAKE
20+ AM_INIT_AUTOMAKE ( 1.10 )
2121
2222dnl Defining fortran language for tests.
23- AC_LANG ( Fortran )
24- AC_FC_SRCEXT ( f90 )
23+ AC_LANG ( [ Fortran] )
24+ AC_FC_SRCEXT ( [ f90] )
2525
2626dnl Set th default prefix to /opt (see the discussion
2727dnl on the nanoquanta mailing list of october 2006).
28- AC_PREFIX_DEFAULT ( / opt )
28+ AC_PREFIX_DEFAULT ( [ /opt] )
2929
3030dnl If FC environement variable is not already set, it
3131dnl looks for a modern Fortran compiler, prefering newest
@@ -51,84 +51,87 @@ case "$fc_type" in
5151esac
5252AC_MSG_RESULT ( [ $capitalize_module_ext] )
5353
54- dnl We custom the module naming scheme depending on the compiler
54+ dnl We customize the module naming scheme depending on the compiler
5555dnl and the platform.
5656dnl Not done yet
5757AM_CONDITIONAL(CAPITALIZE, test "$capitalize_module" = "yes")
5858AC_SUBST ( MODULE_EXT , $capitalize_module_ext )
5959
60- dnl Set the FCFLAGS and FFLAGS variable
61- if test -z "$FFLAGS" ; then
62- AC_SUBST ( FFLAGS , "-O2" )
63- fi
64- if test -z "$FCFLAGS" ; then
65- AC_SUBST ( FCFLAGS , "-O2" )
66- fi
67-
6860dnl Look for ranlib and canonicalize it with the $host variable
6961AC_CHECK_TOOL ( RANLIB , ranlib , : )
70- if test "$ranlib " = ":" ; then
62+ if test "$RANLIB " = ":" ; then
7163 AC_MSG_ERROR ( [ "No 'ranlib' program found."] )
7264fi
7365dnl Look for ar and canonicalize it with the $host variable
7466AC_CHECK_TOOL ( AR , ar , : )
75- if test "$ar " = ":" ; then
67+ if test "$AR " = ":" ; then
7668 AC_MSG_ERROR ( [ "No 'ar' program found."] )
7769fi
7870
79- dnl Get the NetCDF module
80- AC_ARG_WITH ( netcdf-module-path , AS_HELP_STRING ( [ --with-netcdf-module-path] , [ Give the path of the NetCDF Fortran90 module (default = /usr/include).] ) ,
81- ac_netcdf_mod=$withval , ac_netcdf_mod=/usr/include )
82- AC_CHECK_FILE ( ${ac_netcdf_mod}/netcdf.mod , withnetcdf=yes , withnetcdf=no )
83- if test "$withnetcdf" = "no" ; then
84- AC_CHECK_FILE ( ${ac_netcdf_mod}/NETCDF.mod , withnetcdf=yes , withnetcdf=no )
85- if test "$withnetcdf" = "no" ; then
86- AC_CHECK_FILE ( ${ac_netcdf_mod}/NETCDF.MOD , withnetcdf=yes , withnetcdf=no )
71+ dnl NetCDF options
72+ AC_ARG_WITH ( [ netcdf-incs] ,
73+ AS_HELP_STRING ( [ --with-netcdf-incs] ,
74+ [ Include flags for the NetCDF Fortran90 modules (default = /usr/include).] ) ,
75+ [ ac_netcdf_incs="$withval"] ,
76+ [ ac_netcdf_incs="-I/usr/include"] )
77+ AC_ARG_WITH ( [ netcdf-libs] ,
78+ AS_HELP_STRING ( [ --with-netcdf-libs] ,
79+ [ NetCDF link flags.] ) ,
80+ [ ac_netcdf_libs="$withval"] ,
81+ [ ac_netcdf_libs=""] )
82+ AC_ARG_WITH ( [ netcdf-prefix] ,
83+ AS_HELP_STRING ( [ --with-netcdf-prefix] ,
84+ [ Prefix directory where to look for NetCDF components.] ) ,
85+ [ ac_netcdf_prefix="$withval"] ,
86+ [ ac_netcdf_prefix=""] )
87+
88+ dnl Look for NetCDF parameters
89+ if test "$ac_netcdf_prefix" != ""; then
90+ AC_MSG_CHECKING ( [ for nc-config (will override configure options)] )
91+ nc_config_bin="$ac_netcdf_prefix/bin/nc-config"
92+ if test -x "$nc_config_bin"; then
93+ AC_MSG_RESULT ( [ yes] )
94+ ac_netcdf_incs="-I`$nc_config_bin --includedir`"
95+ ac_netcdf_libs=`$nc_config_bin --flibs`
96+ ac_netcdf_fcflags=`$nc_config_bin --fflags`
97+ else
98+ AC_MSG_RESULT ( [ no] )
8799 fi
88100fi
89- if test "$withnetcdf" = "no" ; then
90- echo "Action: install NetCDF and set its path with --with-netcdf-module-path."
91- AC_MSG_ERROR ( [ "No 'NetCDF' module found."] )
101+ AC_MSG_CHECKING ( [ for NetCDF includes] )
102+ AC_MSG_RESULT ( [ $ac_netcdf_incs] )
103+ AC_MSG_CHECKING ( [ for NetCDF libraries] )
104+ AC_MSG_RESULT ( [ $ac_netcdf_libs] )
105+ AC_MSG_CHECKING ( [ for NetCDF Fortran flags] )
106+ AC_MSG_RESULT ( [ $ac_netcdf_fcflags] )
107+ AC_SUBST ( NETCDF_INCLUDES , $ac_netcdf_incs )
108+
109+ dnl Set the FCFLAGS and FFLAGS variables
110+ if test -z "$FCFLAGS" ; then
111+ AC_SUBST ( FCFLAGS , "$ac_netcdf_fcflags" )
92112fi
93- AC_SUBST ( NETCDF_CFLAGS , "$ac_netcdf_mod" )
94-
95- dnl Get the NetCDF library
96- ac_netcdf_dir=/usr/lib
97- AC_ARG_WITH ( netcdf-ldflags , AS_HELP_STRING ( [ --with-netcdf-ldflags] , [ Give the flags required to link with the NetCDF library (default is -L/usr/lib).] ) ,
98- ac_netcdf_dir=$withval , ac_netcdf_dir= )
99- if test -n "$ac_netcdf_dir" ; then
100- LDFLAGS="$LDFLAGS $ac_netcdf_dir"
113+ if test -z "$FFLAGS" ; then
114+ AC_SUBST ( FFLAGS , "$ac_netcdf_fcflags" )
101115fi
102- AC_MSG_CHECKING ( [ for netcdf library] )
103- FCFLAGS_SVG=$FCFLAGS
104- FCFLAGS="$FCFLAGS -I$ac_netcdf_mod"
105- LIBS_SVG=$LIBS
106- LIBS="$LIBS_SVG -lnetcdf"
116+
117+ dnl Check whether NetCDF is working
118+ AC_MSG_CHECKING ( [ for NetCDF] )
119+ FCFLAGS_SVG="$FCFLAGS"
120+ LIBS_SVG="$LIBS"
121+ FCFLAGS="$FCFLAGS $ac_netcdf_incs"
122+ LIBS="$ac_netcdf_libs $LIBS"
107123AC_LINK_IFELSE ( [
108124program main
109125 use netcdf
110126 integer :: s, ncid
111127 s = nf90_open(path = "", mode = NF90_NOWRITE, ncid = ncid)
112128end program main
113- ] , withnetcdf="-lnetcdf" , withnetcdf=no )
114- if test "$withnetcdf" = "no" ; then
115- LIBS="$LIBS_SVG -lnetcdff -lnetcdf"
116- AC_LINK_IFELSE ( [
117- program main
118- use netcdf
119- integer :: s, ncid
120- s = nf90_open(path = "", mode = NF90_NOWRITE, ncid = ncid)
121- end program main
122- ] , withnetcdf="-lnetcdff - lnetcdf" , withnetcdf=no )
123- fi
129+ ] , withnetcdf="yes" , withnetcdf="no" )
124130AC_MSG_RESULT ( [ $withnetcdf] )
125131if test "$withnetcdf" = "no" ; then
126- echo "LDFLAGS was '$LDFLAGS'"
127- echo "Action: install NetCDF and set the library link path with --with-netcdf-ldflags."
132+ echo "Action: install NetCDF and set its parameters through --with-netcdf-incs and --with-netcdf-libs."
128133 AC_MSG_ERROR ( [ "No 'NetCDF' library found."] )
129134fi
130- FCFLAGS=$FCFLAGS_SVG
131- LIBS="$LIBS_SVG"$withnetcdf
132135
133136dnl Test if only the library must be built
134137ac_build_tutorials="no"
0 commit comments