~etsf-io-developers/etsf-io/1.0

« back to all changes in this revision

Viewing changes to configure.ac

  • Committer: Damien Caliste
  • Date: 2011-11-25 13:02:10 UTC
  • Revision ID: damien.caliste@cea.fr-20111125130210-9zpv6c479dl4cjtn
Apply the patch of Yann on the build system.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
dnl Process this file with autoconf to produce a configure script.
2
2
 
3
 
AC_PREREQ(2.59)
 
3
AC_PREREQ(2.62)
4
4
 
5
5
dnl Init basic data for package
6
6
dnl define following variables :
9
9
dnl  - PACKAGE_VERSION, the version ;
10
10
dnl  - PACKAGE_STRING, the name + the version ;
11
11
dnl  - PACKAGE_BUGREPORT, the mail.
12
 
AC_INIT([ETSF - IO library], [1.0.3], [damien.caliste@cea.fr], [etsf_io])
 
12
AC_INIT([ETSF - IO library], [1.0.4], [https://bugs.launchpad.net/etsf-io], [etsf_io])
13
13
 
14
14
dnl All temporary building files are put in this directory.
15
15
dnl his must be called before AM_INIT_AUTOMAKE
16
 
AC_CONFIG_AUX_DIR(config)
 
16
AC_CONFIG_AUX_DIR([config])
17
17
AC_CONFIG_MACRO_DIR([config/m4])
18
18
 
19
19
dnl Init something, don't know exactly what...
20
 
AM_INIT_AUTOMAKE
 
20
AM_INIT_AUTOMAKE(1.10)
21
21
 
22
22
dnl Defining fortran language for tests.
23
 
AC_LANG(Fortran)
24
 
AC_FC_SRCEXT(f90)
 
23
AC_LANG([Fortran])
 
24
AC_FC_SRCEXT([f90])
25
25
 
26
26
dnl Set th default prefix to /opt (see the discussion
27
27
dnl on the nanoquanta mailing list of october 2006).
28
 
AC_PREFIX_DEFAULT(/opt)
 
28
AC_PREFIX_DEFAULT([/opt])
29
29
 
30
30
dnl If FC environement variable is not already set, it
31
31
dnl looks for a modern Fortran compiler, prefering newest
51
51
esac
52
52
AC_MSG_RESULT([$capitalize_module_ext])
53
53
 
54
 
dnl We custom the module naming scheme depending on the compiler
 
54
dnl We customize the module naming scheme depending on the compiler
55
55
dnl and the platform.
56
56
dnl Not done yet
57
57
AM_CONDITIONAL(CAPITALIZE, test "$capitalize_module" = "yes")
58
58
AC_SUBST(MODULE_EXT, $capitalize_module_ext)
59
59
 
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
 
 
68
60
dnl Look for ranlib and canonicalize it with the $host variable
69
61
AC_CHECK_TOOL(RANLIB, ranlib, :)
70
 
if test "$ranlib" = ":" ; then
 
62
if test "$RANLIB" = ":" ; then
71
63
  AC_MSG_ERROR(["No 'ranlib' program found."])
72
64
fi
73
65
dnl Look for ar and canonicalize it with the $host variable
74
66
AC_CHECK_TOOL(AR, ar, :)
75
 
if test "$ar" = ":" ; then
 
67
if test "$AR" = ":" ; then
76
68
  AC_MSG_ERROR(["No 'ar' program found."])
77
69
fi
78
70
 
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])
87
99
  fi
88
100
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."])
92
 
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"
101
 
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"
 
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")
 
112
fi
 
113
if test -z "$FFLAGS" ; then
 
114
  AC_SUBST(FFLAGS, "$ac_netcdf_fcflags")
 
115
fi
 
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"
107
123
AC_LINK_IFELSE([
108
124
program main
109
125
  use netcdf
110
126
  integer :: s, ncid
111
127
  s = nf90_open(path = "", mode = NF90_NOWRITE, ncid = ncid)
112
128
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")
124
130
AC_MSG_RESULT([$withnetcdf])
125
131
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."
128
133
  AC_MSG_ERROR(["No 'NetCDF' library found."])
129
134
fi
130
 
FCFLAGS=$FCFLAGS_SVG
131
 
LIBS="$LIBS_SVG"$withnetcdf
132
135
 
133
136
dnl Test if only the library must be built
134
137
ac_build_tutorials="no"