configure.ac 13.9 KB
Newer Older
1
#  Process this file with autoconf to produce a configure script.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
2

Uwe Schulzweida's avatar
Uwe Schulzweida committed
3
AC_INIT([cdi], [1.6.2], [http://code.zmaw.de/projects/cdi])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
4

Uwe Schulzweida's avatar
Uwe Schulzweida committed
5
6
echo "configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}"

Uwe Schulzweida's avatar
Uwe Schulzweida committed
7
CONFIG_ABORT=yes
8
9
10
11
12
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_MACRO_DIR([m4])
AC_CANONICAL_HOST
AC_CANONICAL_BUILD

Uwe Schulzweida's avatar
Uwe Schulzweida committed
13
14

AM_INIT_AUTOMAKE
15
AC_CONFIG_HEADERS([src/config.h])
16
17
18
19
20
AM_MAINTAINER_MODE([disable])

# Set up libtool.
AC_MSG_NOTICE([setting up libtool])
LT_INIT([pic-only])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
21

22
23
# Check building environment
AC_CHECK_TOOL([CC],[gcc],[:])
24
AC_PROG_CC_C99
25
AC_PROG_FC
26
27
28
29
30
AS_IF([test -n "$FC" && test "X$FC" != "Xno"],
  [AC_FC_SRCEXT([f90])
   AC_LANG_PUSH([Fortran])
   AC_PROG_FPP
   AC_LANG_POP([Fortran])])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
31
AC_PROG_F77
32
AC_PROG_CXX
33
34
AC_CHECK_PROG(SED,sed,sed,false)
AC_CHECK_PROG(GREP,grep,grep,false)
35
36
37
38
39
40
41
42
43
44
AC_PROG_INSTALL
AC_CHECK_TOOL([AR],[ar],[:])
AC_CHECK_TOOL([CPP],[cpp],[:])
AC_CHECK_TOOL([LD],[ld],[:])
AC_CHECK_TOOL([NM],[nm],[:])
AC_CHECK_TOOL([AS],[as],[:])
AC_CHECK_TOOL([DLLTOOL],[dlltool],[:])
AC_CHECK_TOOL([OBJDUMP],[objdump],[:])
AC_CHECK_TOOL([STRIP],[strip],[:])
AC_CHECK_TOOL([RANLIB],[ranlib],[:])
45
46
47
# -----------------------------------------------------------------------
# Check endianess of system
AC_C_BIGENDIAN
48
49
#  ----------------------------------------------------------------------
# Check large file support on 32 bit systems
Uwe Schulzweida's avatar
Uwe Schulzweida committed
50
AC_SYS_LARGEFILE
51
52
#  ----------------------------------------------------------------------
# Checks for library functions.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
53
AC_FUNC_MMAP
54
55
#  ----------------------------------------------------------------------
# Checks for library malloc.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
56
AC_CHECK_LIB(malloc, malloc)
57
#  ----------------------------------------------------------------------
58
59
# Checks for structures.
AC_CHECK_MEMBERS([struct stat.st_blksize])
60
#  ----------------------------------------------------------------------
Uwe Schulzweida's avatar
Uwe Schulzweida committed
61
62
# Checks for header files
AC_CHECK_HEADERS(malloc.h)
63
#  ----------------------------------------------------------------------
Uwe Schulzweida's avatar
Uwe Schulzweida committed
64
# Checks for the availability of functions
65
66
AC_CHECK_FUNCS([mallinfo])
AC_CHECK_FUNCS([getline])
67
#  ----------------------------------------------------------------------
68
# Checks for the availability of ANSI-C99 functions
69
70
AC_CHECK_DECLS([isnan],,,[AC_INCLUDES_DEFAULT
@%:@include <math.h>])
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

# Check compiler version
case "$CC" in
  pgcc*)  COMP_VERSION=`$CC -V | head -2 | tail -n 1`;;
  *gcc*)  COMP_VERSION=`$CC --version | head -n 1`;;
  g++*)   COMP_VERSION=`$CC --version | head -n 1`;;
  clang*) COMP_VERSION=`$CC --version | head -n 1`;;
  sxc*)   COMP_VERSION=`$CC -V 2>&1   | tail -n 1`;;
  xlc*)   COMP_VERSION=`$CC -qversion 2>&1   | head -n 1`;;
  *)      COMP_VERSION=`$CC -V 2>&1   | head -n 1`;;
esac

if test -z "$COMP_VERSION" ; then COMP_VERSION="unknown"; fi;
AC_DEFINE_UNQUOTED(COMP_VERSION, ["$COMP_VERSION"], [Compiler version])

# Checks for username, hostname and system type
USERNAME=$LOGNAME
if test -z "$USERNAME" ; then USERNAME=$USER; fi;
if test -z "$USERNAME" ; then USERNAME="unknown"; fi;
AC_DEFINE_UNQUOTED([USER_NAME],["$USERNAME"], [User name])
AC_SUBST([USER_NAME],["$USERNAME"])

AS_IF([test -z "$HOST"],
      [HOST=unknown
       AS_IF([test -x /bin/hostname],[HOST=$(hostname)],
             [AS_IF([test -x /bin/uname],
                    [HOST=$(uname -n)])])])
AC_DEFINE_UNQUOTED([HOST_NAME],["$HOST"],[Host name])
AC_SUBST([HOST_NAME],["$HOST"])

AC_DEFINE_UNQUOTED([SYSTEM_TYPE],["$ac_cv_build"], [System type])
AC_SUBST([SYSTEM_TYPE],["$ac_cv_build"])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
103
104
105
106
#  ----------------------------------------------------------------------
#  Check for math library
AC_CHECK_LIB(m, floor)
#  ----------------------------------------------------------------------
107
108
# Add basic configure options
ACX_OPTIONS
Uwe Schulzweida's avatar
Uwe Schulzweida committed
109
#  ----------------------------------------------------------------------
110
# Compile with MPI support
111
AC_ARG_ENABLE(mpi,AS_HELP_STRING([--enable-mpi],[Compile with MPI compiler [default=no]]),enable_mpi=yes,enable_mpi=no)
112
113
AS_IF([test x"${enable_mpi}" = x"yes"],
      [USE_MPI=yes])
114
HAVE_PARALLEL_NC4=0
115
AS_IF([test x"$USE_MPI" = xyes],
116
  [AC_DEFINE([USE_MPI],[1],[parallel I/O requested and available])
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
   AC_PATH_PROGS([MPI_LAUNCH],[mpirun mpiexec],[true])
   AS_IF([test x"$cross_compiling" = xno],
     [AC_MSG_CHECKING([if $MPI_LAUNCH works])
      saved_CFLAGS=$CFLAGS
      saved_LIBS=$LIBS
      CFLAGS="$CFLAGS $MPI_C_INCLUDE"
      LIBS="$LIBS $MPI_C_LIB"
      AC_LINK_IFELSE([AC_LANG_SOURCE([
@%:@include <stdio.h>
@%:@include <stdlib.h>

@%:@include <mpi.h>

@%:@define xmpi(ret)           \\
  do {                      \\
    if (ret != MPI_SUCCESS) \\
      exit(EXIT_FAILURE);   \\
  } while (0)

int
main(int argc, char **argv)
{
  xmpi(MPI_Init(&argc, &argv));
  char *numarg = argv@<:@1@:>@;
  int cmdnum = atoi(numarg);
  int procnum = 1;
  xmpi(MPI_Allreduce(MPI_IN_PLACE, &procnum, 1, MPI_INT, MPI_SUM,
                     MPI_COMM_WORLD));
  xmpi(MPI_Finalize());
  return (procnum == cmdnum)?EXIT_SUCCESS:EXIT_FAILURE;
}
])],
         [AS_IF([$MPI_LAUNCH -n 4 ./conftest$EXEEXT 4],
            [AC_MSG_RESULT([yes])],
            [AC_MSG_RESULT([no])
             AC_MSG_FAILURE([mpirun doesn't work])])],
         [AC_MSG_FAILURE([Cannot compile simple MPI program])])
      CFLAGS=$saved_CFLAGS
      LIBS=$saved_LIBS
     ])
   AS_IF([test "x$MPI_LAUNCH" = xtrue],
     [AC_MSG_WARN([MPI launch command unavailable])])

160
161
162
   PKG_CHECK_MODULES([YAXT],[yaxt],
     [AC_DEFINE([HAVE_YAXT],,[yaxt library is available])],
     [AC_MSG_FAILURE([Required yaxt library unavailable.])])
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
   AS_IF([test x"$ENABLE_NC4" = xyes],
     [AC_CHECK_HEADERS([netcdf_par.h],
        [AC_CHECK_DECL([MPI_Bcast],
           [HAVE_PARALLEL_NC4=1],
           [AC_MSG_WARN([The supplied netCDF library does not support MPI parallel invocations])],
           [AC_INCLUDES_DEFAULT
@%:@include <netcdf_par.h>])],
        [AC_CHECK_DECL([MPI_Bcast],
           [HAVE_PARALLEL_NC4=1],
           [AC_MSG_WARN([The supplied netCDF library does not support MPI parallel invocations])],
           [AC_INCLUDES_DEFAULT
@%:@include <netcdf.h>])
])
      dnl parallel netCDF support still requires ScalES-PPM and YAXT to
      dnl re-arrange the data when running with more than one collector
      AS_IF([test $HAVE_PARALLEL_NC4 = 1],
        [PKG_CHECK_MODULES([PPM_CORE],[scales-ppm-core],
           [enable_ppm=yes
            AC_DEFINE([HAVE_PPM_CORE],,
              [ScalES PPM C core library is available])
           ],
           [enable_ppm=no])
        ])
      dnl if not both scales-ppm and yaxt are available, netcdf can only be
      dnl used in serial mode
188
      AS_IF([test x$enable_ppm != xyes],
189
190
191
        [HAVE_PARALLEL_NC4=0])
     ])
  ],
192
193
  [MPI_LAUNCH="`pwd`/util/serialrun"
   AC_SUBST([MPI_LAUNCH])])
194
195
196
197
AS_IF([test $HAVE_PARALLEL_NC4 -gt 0],
  [AC_DEFINE([HAVE_PARALLEL_NC4],[1],
             [netCDF library does support MPI parallel invocations])])
AC_SUBST([HAVE_PARALLEL_NC4])
198
AM_CONDITIONAL([USE_MPI],[test x"$USE_MPI" = xyes])
199
AC_SUBST([USE_MPI])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
200
201
202
203
#  ----------------------------------------------------------------------
#  Create the Fortran Interface via iso_c_binding module (Fortran 2003 Standard)
AC_ARG_ENABLE(iso-c-interface,
              AS_HELP_STRING([--enable-iso-c-interface],
204
                             [Create Fortran Interface via iso_c_bindings facility of F2003 [default=no]]).
Uwe Schulzweida's avatar
Uwe Schulzweida committed
205
206
              ,enable_isoc=${enableval},enable_isoc=no)
AM_CONDITIONAL([CREATE_ISOC],[test $enable_isoc = 'yes'])
207
208
209
210
211
212
213
214
215
216
# in case the Fortran interface uses the more modern F90-style interface,
# the FCFLAGS for users of the library have to include a switch to use the
# .mod file
CDI_F90_INTERFACE_FCFLAGS=''
AS_IF([test "x${enable_isoc}" = "xyes"],
  [AC_LANG_PUSH([Fortran])
   ACX_SL_FC_CHECK_MOD_PATH_FLAG
   AC_LANG_POP([Fortran])
   CDI_F90_INTERFACE_FCFLAGS="${FC_MOD_FLAG}${includedir}"])
AC_SUBST([CDI_F90_INTERFACE_FCFLAGS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
217
#  Check the module extension of the fortran compiler
218
219
AS_IF([test -n "$FC" && test "X$FC" != "Xno"],
  [ACX_SL_FC_MOD_SUFFIX(,[FCMODEXT=mod])])
220
# -----------------------------------------------------------------------
221
222
# Check for SWIG - Generator for script-language bindings
AC_ARG_ENABLE(swig,
223
224
225
226
              [AS_HELP_STRING([--enable-swig],[use swig to create extra bindings [default=no] (EXPERIMENTAL)])],
              [AC_CHECK_PROG(SWIG,swig,swig)],
              [enable_swig=no])
AM_CONDITIONAL(ENABLE_SWIG,[test "x$SWIG" != "x"])
227
228
229
#  ----------------------------------------------------------------------
#  Create the Ruby Interface via swig
AC_ARG_ENABLE(ruby,
230
  [AS_HELP_STRING([--enable-ruby],[ruby language bindings [default=no] (EXPERIMENTAL)])],
231
  [AC_CHECK_PROG(RUBY,ruby,ruby)
232
   RUBY_INCLUDES="$($RUBY $srcdir/config/interface.rb)"
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
   save_CPPFLAGS=$CPPFLAGS
   CPPFLAGS="$CPPFLAGS $RUBY_INCLUDES"
   AC_CHECK_HEADER([ruby.h],,[enable_ruby=no
                              RUBY=
                             ])
   CPPFLAGS=$save_CPPFLAGS
   AS_IF([test "x$RUBY" != "x"],
         [AS_IF([test "x$SWIG" = "x"],
                [AC_MSG_NOTICE([Ruby bindings: Swig is disabled, pregenerated files will be used. Use '--enable-swig' for swig usage])])],
                [AS_IF([test `$SWIG -help 2>&1 | $GREP -c '\-ruby *- Generate'` = 0],
                       [AC_MSG_NOTICE([No (swig does not support -ruby option)])
                        enable_ruby=no
                       ])])],
  [enable_ruby=no])
AM_CONDITIONAL(ENABLE_RUBY,[test "x$enable_ruby" != "xno"])
AS_IF([test "x$enable_ruby" != "xno"],[AC_SUBST([ENABLE_RUBY],[true])],[AC_SUBST([ENABLE_RUBY],[false])])
249
#  ----------------------------------------------------------------------
250
#  Create the Python Interface via swig
251
AC_ARG_ENABLE(python,
252
  [AS_HELP_STRING([--enable-python],[python language bindings [default=no] (EXPERIMENTAL)])],
253
  [AC_CHECK_PROG(PYTHON,python,python)
Thomas Jahns's avatar
Thomas Jahns committed
254
255
256
257
258
259
260
261
262
263
264
265
   enable_python=no
   for PYTHON_INCLUDES in \
     "-I`$PYTHON -c 'from distutils import sysconfig;print sysconfig.get_python_inc()'`" \
     "-I`$PYTHON -c 'from distutils import sysconfig;print sysconfig.get_python_lib(1,1)' | $SED 's/lib/include/'`"
   do
     save_CPPFLAGS=$CPPFLAGS
     CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
     AC_CHECK_HEADER([Python.h],[enable_python=yes
       break])
     CPPFLAGS=$save_CPPFLAGS
   done
   AS_IF([test "x$enable_python" != "xno"],
266
         [AS_IF([test "x$SWIG" = "x"],
Thomas Jahns's avatar
Thomas Jahns committed
267
268
                [AC_MSG_NOTICE([Python bindings: Swig is disabled, pregenerated files will be used. Use '--enable-swig' for swig usage])],
                [PYTHON=])],
269
270
271
272
273
274
275
276
277
                [AS_IF([test `$SWIG -help 2>&1 | $GREP -c '\-python *- Generate'` = 0],
                       [AC_MSG_NOTICE([No (swig does not support -python option)])
                        enable_python=no
                       ])])],
  [enable_python=no])
AM_CONDITIONAL(ENABLE_PYTHON, [test "x$enable_python" != "xno"])
AS_IF([test "x$enable_python" != "xno"],[AC_SUBST([ENABLE_PYTHON],[true])],[AC_SUBST([ENABLE_PYTHON],[false])])
#  ----------------------------------------------------------------------
AM_CONDITIONAL(CREATE_INTERFACES, [test  "x$enable_ruby" = "xyes" -o "x$enable_python" = "xyes"])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
278
#  ----------------------------------------------------------------------
279
#  Check C / Fortran interface
280
ACX_CHECK_CFINT([$srcdir/src/cfortran.h])
281
282
283
284
AM_CONDITIONAL([USE_FC],[test -n "$FC" && test "X$FC" != "Xno" && test x$acx_cv_check_cfint = "xyes"])dnl
dnl
AC_SUBST([CPPFLAGS])dnl
dnl
285
AC_ARG_VAR([BUILD_CFLAGS],
286
287
288
  [append to CFLAGS during build but not in configure phase])dnl
AC_CONFIG_COMMANDS_PRE([CFLAGS="$CFLAGS${BUILD_CFLAGS+ $BUILD_CFLAGS}"])dnl
AM_SUBST_NOTMAKE([BUILD_CFLAGS])dnl
289
AC_ARG_VAR([BUILD_FCFLAGS],
290
291
292
  [append to FCFLAGS during build but not in configure phase])dnl
AC_CONFIG_COMMANDS_PRE([FCFLAGS="$FCFLAGS${BUILD_FCFLAGS+ $BUILD_FCFLAGS}"])dnl
AM_SUBST_NOTMAKE([BUILD_FCFLAGS])dnl
293
AC_ARG_VAR([BUILD_LDFLAGS],
294
295
296
  [append to LDFLAGS during build but not in configure phase])dnl
AC_CONFIG_COMMANDS_PRE([LDFLAGS="$LDFLAGS${BUILD_LDFLAGS+ $BUILD_LDFLAGS}"])dnl
AM_SUBST_NOTMAKE([BUILD_LDFLAGS])dnl
297
AC_ARG_VAR([BUILD_CC],
298
299
300
  [replace CC with expansion of $BUILD_CC during build but not in configure phase])dnl
AC_CONFIG_COMMANDS_PRE([CC="${BUILD_CC-$CC}"])dnl
AM_SUBST_NOTMAKE([BUILD_CC])dnl
301
AC_ARG_VAR([BUILD_CXX],
302
303
304
  [replace CXX with expansion of $BUILD_CXX during build but not in configure phase])dnl
AC_CONFIG_COMMANDS_PRE([CXX="${BUILD_CXX-$CXX}"])dnl
AM_SUBST_NOTMAKE([BUILD_CXX])dnl
305
AC_ARG_VAR([BUILD_FC],
306
307
308
  [replace FC with expansion of $BUILD_FC during build but not in configure phase])dnl
AC_CONFIG_COMMANDS_PRE([FC="${BUILD_FC-$FC}"])dnl
AM_SUBST_NOTMAKE([BUILD_FC])dnl
309
AC_ARG_VAR([BUILD_F77],
310
311
312
  [replace F77 with expansion of $BUILD_F77 during build but not in configure phase])dnl
AC_CONFIG_COMMANDS_PRE([F77="${BUILD_F77-$F77}"])dnl
AM_SUBST_NOTMAKE([BUILD_F77])dnl
313
314


315
316
317
318
# Checks for compiler
COMPILER="$CC $CFLAGS"
AC_DEFINE_UNQUOTED(COMPILER, ["$COMPILER"], [Compiler])

319
320
321
322
323
324
AC_CONFIG_FILES([tests/test_cksum_grib \
                 tests/test_cksum_nc \
                 tests/test_cksum_nc2 \
                 tests/test_cksum_nc4 \
                 tests/test_cksum_extra \
                 tests/test_cksum_service \
325
                 tests/test_cksum_ieg \
326
                 tests/test_chunk_cksum \
327
                 tests/pio_write_run \
Thomas Jahns's avatar
Thomas Jahns committed
328
329
330
331
                 tests/pio_cksum_mpinonb \
                 tests/pio_cksum_fpguard \
                 tests/pio_cksum_asynch \
                 tests/pio_cksum_writer \
332
                 tests/pio_cksum_cdf \
333
                 util/serialrun],[chmod a+x "$ac_file"])
334

335
336
AC_OUTPUT([Makefile src/Makefile interfaces/Makefile app/Makefile \
	tests/Makefile examples/Makefile cdi.settings \
337
	examples/pio/Makefile src/pkgconfig/cdi.pc src/pkgconfig/cdipio.pc])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
338

339
340
341
#  ----------------------------------------------------------------------
#  Show configuration
AC_MSG_NOTICE([CDI is configured with the following options:])
342
./config.status cdi.settings
343
cat cdi.settings
344

345
346
AS_IF([test "$ac_cv_prog_cc_c99" = "no"],
      [AC_MSG_NOTICE([
347

348
349
  Warning: The C compiler does not accept ANSI C99 source code!
])])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
350
351
352
353
354
355
AC_MSG_NOTICE([

  Configuration completed.

    You can now say 'make' to compile the CDI package and 'make install' to install it afterwards.
])