Skip to content

Commit 23ed795

Browse files
committed
Apply the patch of Yann on the build system.
1 parent 3b888ad commit 23ed795

File tree

5 files changed

+68
-59
lines changed

5 files changed

+68
-59
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Fri Nov 25 2011 Yann Pouillon <[email protected]> 1.0.4
2+
- Upgrade configure.ac to correct different badly written autoconf tests.
3+
- Modify NetCDF detection for enhanced results.
4+
15
* Mon Mar 29 2010 Damien Caliste <[email protected]> 1.0.3
26
- Correct configure.ac and Makefile.am for aclocal to always run with its
37
config/m4 inclusion.

Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ ACLOCAL_AMFLAGS = -I config/m4
88

99
man1_MANS = doc/etsf_io.1
1010

11+
EXTRA_DIST = $(man1_MANS)
12+
1113
SUBDIRS = \
1214
src/low_level \
1315
src/group_level \

configure.ac

Lines changed: 60 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dnl Process this file with autoconf to produce a configure script.
22

3-
AC_PREREQ(2.59)
3+
AC_PREREQ(2.62)
44

55
dnl Init basic data for package
66
dnl define following variables :
@@ -9,23 +9,23 @@ dnl - PACKAGE_TARNAME, the name used for the tarball ;
99
dnl - PACKAGE_VERSION, the version ;
1010
dnl - PACKAGE_STRING, the name + the version ;
1111
dnl - 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

1414
dnl All temporary building files are put in this directory.
1515
dnl his must be called before AM_INIT_AUTOMAKE
16-
AC_CONFIG_AUX_DIR(config)
16+
AC_CONFIG_AUX_DIR([config])
1717
AC_CONFIG_MACRO_DIR([config/m4])
1818

1919
dnl Init something, don't know exactly what...
20-
AM_INIT_AUTOMAKE
20+
AM_INIT_AUTOMAKE(1.10)
2121

2222
dnl Defining fortran language for tests.
23-
AC_LANG(Fortran)
24-
AC_FC_SRCEXT(f90)
23+
AC_LANG([Fortran])
24+
AC_FC_SRCEXT([f90])
2525

2626
dnl Set th default prefix to /opt (see the discussion
2727
dnl on the nanoquanta mailing list of october 2006).
28-
AC_PREFIX_DEFAULT(/opt)
28+
AC_PREFIX_DEFAULT([/opt])
2929

3030
dnl If FC environement variable is not already set, it
3131
dnl looks for a modern Fortran compiler, prefering newest
@@ -51,84 +51,87 @@ case "$fc_type" in
5151
esac
5252
AC_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
5555
dnl and the platform.
5656
dnl Not done yet
5757
AM_CONDITIONAL(CAPITALIZE, test "$capitalize_module" = "yes")
5858
AC_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-
6860
dnl Look for ranlib and canonicalize it with the $host variable
6961
AC_CHECK_TOOL(RANLIB, ranlib, :)
70-
if test "$ranlib" = ":" ; then
62+
if test "$RANLIB" = ":" ; then
7163
AC_MSG_ERROR(["No 'ranlib' program found."])
7264
fi
7365
dnl Look for ar and canonicalize it with the $host variable
7466
AC_CHECK_TOOL(AR, ar, :)
75-
if test "$ar" = ":" ; then
67+
if test "$AR" = ":" ; then
7668
AC_MSG_ERROR(["No 'ar' program found."])
7769
fi
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
88100
fi
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")
92112
fi
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")
101115
fi
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"
107123
AC_LINK_IFELSE([
108124
program main
109125
use netcdf
110126
integer :: s, ncid
111127
s = nf90_open(path = "", mode = NF90_NOWRITE, ncid = ncid)
112128
end 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")
124130
AC_MSG_RESULT([$withnetcdf])
125131
if 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."])
129134
fi
130-
FCFLAGS=$FCFLAGS_SVG
131-
LIBS="$LIBS_SVG"$withnetcdf
132135

133136
dnl Test if only the library must be built
134137
ac_build_tutorials="no"

src/low_level/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ else
1212
module_DATA = etsf_io_low_level.@MODULE_EXT@
1313
endif
1414

15-
AM_FCFLAGS = -I@NETCDF_CFLAGS@ -I$(srcdir)
15+
AM_FCFLAGS = @NETCDF_INCLUDES@ -I$(srcdir)
1616

1717
libetsf_io_low_level_a_SOURCES = etsf_io_low_level.f90
1818

src/tutorials/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
vpath %.a $(top_builddir)/src/group_level \
22
$(top_builddir)/src/utils
33

4-
AM_FCFLAGS = -I@NETCDF_CFLAGS@ -I$(top_builddir)/src/low_level -I$(top_builddir)/src/group_level -I$(top_builddir)/src/utils
4+
AM_FCFLAGS = @NETCDF_INCLUDES@ -I$(top_builddir)/src/low_level -I$(top_builddir)/src/group_level -I$(top_builddir)/src/utils
55

66
EXTRA_DIST = MPI_output_of_a_density.f90 README.f90
77

0 commit comments

Comments
 (0)