1dnl Process this file with autoconf to produce a configure script.
2
3AC_DEFUN([_AM_AUTOCONF_VERSION],[])
4
5AC_PREREQ([2.59])
6AC_INIT([grib_api],[ ], [Software.Support@ecmwf.int])
7
8AC_CONFIG_AUX_DIR([config])
9
10LT_INIT([shared])
11AC_SUBST([LIBTOOL_DEPS])
12AC_CONFIG_MACRO_DIR([m4])
13
14# Source file containing package/library versioning information.
15
16 . ${srcdir}/version.sh
17
18GRIB_API_MAIN_VERSION="${GRIB_API_MAJOR_VERSION}.${GRIB_API_MINOR_VERSION}.${GRIB_API_REVISION_VERSION}"
19 echo $GRIB_API_MAIN_VERSION
20
21PACKAGE_VERSION="${GRIB_API_MAIN_VERSION}"
22GRIB_API_VERSION_STR="${GRIB_API_MAIN_VERSION}"
23GRIB_API_PATCH_VERSION="${GRIB_API_REVISION_VERSION}"
24AC_SUBST(GRIB_API_MAIN_VERSION)
25AC_SUBST(GRIB_API_VERSION_STR)
26AC_SUBST(GRIB_API_MAJOR_VERSION)
27AC_SUBST(GRIB_API_MINOR_VERSION)
28AC_SUBST(GRIB_API_PATCH_VERSION)
29
30AC_SUBST(GRIB_ABI_CURRENT)
31AC_SUBST(GRIB_ABI_REVISION)
32AC_SUBST(GRIB_ABI_AGE)
33
34echo "configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}"
35
36# Ensure that make can run correctly
37AM_SANITY_CHECK
38
39AC_CONFIG_SRCDIR([src/grib_api.h])
40AC_CONFIG_HEADER([src/config.h])
41AC_CONFIG_FILES([src/grib_api_version.h])
42AC_CONFIG_FILES([rpms/grib_api.pc rpms/grib_api.spec rpms/grib_api_f90.pc])
43AM_INIT_AUTOMAKE($PACKAGE_NAME,[${PACKAGE_VERSION}],[http://www.ecmwf.int])
44
45definition_files_path="${datadir}/grib_api/definitions"
46samples_files_path="${datadir}/grib_api/samples"
47ifs_samples_files_path="${datadir}/grib_api/ifs_samples"
48default_perl_install="${prefix}/perl"
49
50AC_DEFINE_UNQUOTED(GRIB_API_MAIN_VERSION,$GRIB_API_MAIN_VERSION,Grib Api version)
51AC_DEFINE_UNQUOTED(GRIB_API_MAJOR_VERSION,$GRIB_API_MAJOR_VERSION,Grib Api Major release)
52AC_DEFINE_UNQUOTED(GRIB_API_MINOR_VERSION,$GRIB_API_MINOR_VERSION,Grib Api Minor release)
53AC_DEFINE_UNQUOTED(GRIB_API_REVISION_VERSION,$GRIB_API_REVISION_VERSION,Grib Api Revision release)
54
55AC_DEFINE_UNQUOTED(GRIB_ABI_CURRENT,$GRIB_ABI_CURRENT,Grib Api Current ABI version)
56AC_DEFINE_UNQUOTED(GRIB_ABI_REVISION,$GRIB_ABI_REVISION,Grib Api Revision ABI version)
57AC_DEFINE_UNQUOTED(GRIB_ABI_AGE,$GRIB_ABI_AGE,Grib Api Age of ABI version)
58
59
60AH_TEMPLATE([_LARGE_FILE_API],
61			[Needs to be undefined on some AIX])
62
63PERLDIR=perl
64AC_SUBST(PERLDIR)
65
66
67dnl Checks for programs.
68AC_PROG_CC(xlc_r xlc gcc cc pgcc)
69AC_PROG_CPP
70AC_PROG_INSTALL
71AC_PROG_LN_S
72AC_PROG_MAKE_SET
73AC_PROG_YACC
74AC_PROG_LEX
75AC_PROG_F77(pgf90 pgf77 xlf gfortran f77 g77 f90 ifort)
76AC_PROG_FC(pgf90 xlf90 gfortran f90 ifort)
77
78dnl check availability of pthreads
79AC_ARG_ENABLE([pthread],
80  [AS_HELP_STRING([--enable-pthread],[enable POSIX threads [by default disabled]])],
81    [pthreads=${enableval}] , [pthreads=no]
82)
83if test "x${pthreads}" = xyes; then
84   GRIB_PTHREADS=1
85else
86   GRIB_PTHREADS=0
87fi
88
89if test $GRIB_PTHREADS -eq 1
90then
91   AC_GRIB_PTHREADS
92   AC_GRIB_LINUX_PTHREADS
93else
94   GRIB_LINUX_PTHREADS=0
95fi
96
97AC_DEFINE_UNQUOTED(GRIB_PTHREADS,$GRIB_PTHREADS,1->pthreads enabled 0->pthreads disabled)
98AC_DEFINE_UNQUOTED(GRIB_LINUX_PTHREADS,$GRIB_LINUX_PTHREADS,1->pthreads enabled 0->pthreads disabled)
99
100dnl check IBM POWER 6/7 optimisations option
101AC_ARG_ENABLE([ibmpower67_opt],
102  [AS_HELP_STRING([--enable-ibmpower67_opt],[enable IBM POWER 6/7 optimisations [by default disabled]])],
103    [ibmpower67_opts=${enableval}] , [ibmpower67_opts=no]
104)
105if test "x${ibmpower67_opts}" = xyes; then
106   GRIB_IBMPOWER67_OPT=1
107else
108   GRIB_IBMPOWER67_OPT=0
109fi
110AC_DEFINE_UNQUOTED(GRIB_IBMPOWER67_OPT,$GRIB_IBMPOWER67_OPT,1->IBM Power6/7 Optimisations enabled 0->IBM Power6/7 Optimisations disabled)
111
112
113dnl check on uppercase fortran modules not working to be fixed
114dnl some fortran compilers change the name of the .mod file in upper case!
115ac_cv_prog_f90_uppercase_mod=no
116AC_PROG_FC_UPPERCASE_MOD
117AM_CONDITIONAL(UPPER_CASE_MOD, [test "x$ac_cv_prog_f90_uppercase_mod" = xyes])
118
119AC_IEEE_BE
120AC_DEFINE_UNQUOTED(IEEE_BE,$IS_IEEE_BE,1-> ieee big endian float/double 0->no ieee big endian float/double)
121
122AC_IEEE_LE
123AC_DEFINE_UNQUOTED(IEEE_LE,$IS_IEEE_LE,1-> ieee little endian float/double 0->no ieee little endian float/double)
124
125dnl disable ieee native packing
126AC_ARG_ENABLE([ieee-native],
127  [AS_HELP_STRING([--disable-ieee-native],[disable ieee native packing])],
128     without_ieee=1,without_ieee=0)
129
130if test $without_ieee -eq 1
131then
132AC_DEFINE_UNQUOTED(IEEE_LE,0,1-> ieee little endian float/double 0->no ieee little endian float/double)
133AC_DEFINE_UNQUOTED(IEEE_BE,0,1-> ieee big endian float/double 0->no ieee big endian float/double)
134fi
135
136AC_BIG_ENDIAN
137AC_DEFINE_UNQUOTED(IS_BIG_ENDIAN,$IS_BIG_ENDIAN,1-> big endian 0->little endian)
138
139AC_INLINE
140AC_DEFINE_UNQUOTED(GRIB_INLINE,$HAS_INLINE,inline if available)
141
142AC_ALIGN
143AC_DEFINE_UNQUOTED(GRIB_MEM_ALIGN,$MEM_ALIGN,memory alignment required)
144
145AC_CHECK_FUNC([posix_memalign],
146    [AC_DEFINE_UNQUOTED(POSIX_MEMALIGN,1,posix_memalign present)])
147
148AC_ARG_ENABLE([align-memory],
149  [AS_HELP_STRING([--enable-align-memory],[enable memory alignment [by default disabled]])],
150                  AC_DEFINE_UNQUOTED(GRIB_MEM_ALIGN,1,memory alignment required),
151)
152
153dnl use vectorised code
154AC_ARG_ENABLE([vector],
155  [AS_HELP_STRING([--enable-vector],[enable vectorised code [by default disabled]] )],
156	 [vectorise=${enableval}],[vectorise=no])
157if test "x${vectorise}" = xyes
158then
159   vectorise=1
160else
161   vectorise=0
162fi
163AC_DEFINE_UNQUOTED(VECTOR,$vectorise,vectorised code)
164
165dnl enable memory management
166AC_ARG_ENABLE([memory-management],
167  [AS_HELP_STRING([--enable-memory-management],[enable memory [by default disabled]])],
168AC_DEFINE_UNQUOTED(MANAGE_MEM,1,memory management) ,
169AC_DEFINE_UNQUOTED(MANAGE_MEM,0,memory management)
170	 )
171
172dnl enable development configuration
173DEVEL_RULES=''
174AC_ARG_ENABLE([development],
175  [AS_HELP_STRING([--enable-development],[enable development configuration [by default disabled]])],
176    [GRIB_DEVEL=${enableval}] , [GRIB_DEVEL=no]
177)
178if test "x${GRIB_DEVEL}" = xyes
179then
180   GRIB_DEVEL=1
181   DEVEL_RULES='extrules.am'
182else
183   GRIB_DEVEL=0
184   DEVEL_RULES='dummy.am'
185fi
186AC_SUBST(DEVEL_RULES)
187AC_SUBST(GRIB_DEVEL)
188
189AM_CONDITIONAL([WITH_MARS_TESTS], [test $GRIB_DEVEL -eq 1])
190
191dnl Large file support
192AC_FUNC_FSEEKO
193CREATE_H=''
194if test x"$ac_cv_func_fseeko" != xyes ; then
195	CREATE_H='./create_h.sh 1'
196else
197	CREATE_H='./create_h.sh 0'
198fi
199
200AC_SYS_LARGEFILE
201
202dnl What OS are we running?
203AC_CANONICAL_HOST
204
205dnl RPM related variables
206RPM_HOST_CPU=${host_cpu}
207RPM_HOST_VENDOR=${host_vendor}
208RPM_HOST_OS=${host_os}
209RPM_CONFIGURE_ARGS=${ac_configure_args}
210AC_SUBST(RPM_HOST_CPU)
211AC_SUBST(RPM_HOST_VENDOR)
212AC_SUBST(RPM_HOST_OS)
213AC_SUBST(RPM_CONFIGURE_ARGS)
214AC_ARG_WITH(rpm-release, [  --with-rpm-release=NUMBER       The rpms will use this release number  (defaults to 1)],
215                RPM_RELEASE="$withval", RPM_RELEASE=1)
216AC_SUBST(RPM_RELEASE)
217
218
219GRIB_SAMPLES_PATH=$samples_files_path
220GRIB_TEMPLATES_PATH=$samples_files_path
221GRIB_DEFINITION_PATH=$definition_files_path
222
223AC_SUBST(GRIB_TEMPLATES_PATH)
224AC_SUBST(GRIB_SAMPLES_PATH)
225AC_SUBST(GRIB_DEFINITION_PATH)
226
227dnl Fortran interface
228AC_ARG_ENABLE([fortran],
229  [AS_HELP_STRING([--disable-fortran],[disable fortran interface [by default enabled]])],
230     [with_fortran=${enableval}], [with_fortran=yes])
231
232if test "x${with_fortran}" = xyes; then
233   without_fortran=0
234else
235   without_fortran=1
236fi
237
238if test "x$FC" = "x"
239then
240  without_fortran=1
241fi
242
243dnl check on uppercase fortran modules not working to be fixed
244dnl some fortran compilers change the name of the .mod file in upper case!
245ac_cv_prog_f90_uppercase_mod=no
246AC_PROG_FC_UPPERCASE_MOD
247AM_CONDITIONAL(UPPER_CASE_MOD, [test "x$ac_cv_prog_f90_uppercase_mod" = xyes])
248
249dnl check if the fortran compiler has problems using modules when in debug mode
250dnl Porland compilers versions 7 and 8 are known to fail here
251AC_PROG_FC_DEBUG_IN_MODULE
252AM_CONDITIONAL(DEBUG_IN_MOD, [test "x$ac_cv_prog_f90_debug_in_module" = xyes])
253
254if test $without_fortran -ne 1 && test "x$ac_cv_prog_f90_debug_in_module" != xyes \
255		&& test "x$enable_shared" = xyes && test "x$FCFLAGS" = "x-g"
256then
257	without_fortran=1
258	AC_MSG_WARN([
259
260  Your Fortran compiler ($FC) does not support linking to dynamic library modules when debug is enabled. This is a known
261problem with Portland compilers versions 7 and 8, for example. Possible workarounds are:
262
263  - Use a Portland compiler version 10 or higher or a different compiler.
264  - Disable shared libraries (e.g. configure --disable-shared)
265  - Disable debug (e.g. configure FCFLAGS=\"\")
266
267  Compilation of the Fortran module has been disabled
268
269])
270fi
271
272
273if test $without_fortran -ne 1
274then
275  FORTRAN_MOD=fortran
276  AC_SUBST(FORTRAN_MOD)
277  F90_CHECK="examples/F90"
278  AC_SUBST(F90_CHECK)
279
280  dnl detect the Fortran 90 modules inclusion flag.
281  AX_F90_MODULE_FLAG
282  if test "$ax_cv_f90_modflag" = "not found" ; then
283    AC_MSG_ERROR([unable to find compiler flag for modules inclusion])
284  fi
285  F90_MODULE_FLAG=$ax_cv_f90_modflag
286  AC_SUBST([F90_MODULE_FLAG])
287fi
288
289dnl ifs_samples
290AC_ARG_WITH([ifs-samples],
291        [AS_HELP_STRING([--with-ifs-samples=ifs-samples-dir],[ifs_samples will be installed in ifs-samples-dir])],
292        ifs_samples=$withval, ifs_samples='none')
293IFS_SAMPLES_DIR=""
294
295if test $ifs_samples != 'none'
296then
297	IFS_SAMPLES_DIR=$ifs_samples
298else
299	IFS_SAMPLES_DIR=$ifs_samples_files_path
300fi
301AC_SUBST([IFS_SAMPLES_DIR])
302
303
304dnl EMOS
305AC_ARG_WITH([emos],
306        [AS_HELP_STRING([--with-emos=EMOS],[use emos for tests])],
307        emos=$withval, emos='none')
308
309EMOS_LIB=""
310if test "$emos" != 'none'
311then
312  EMOS_LIB=$emos
313  AC_DEFINE(HAVE_LIBEMOS,1,Define if you have EMOS library)
314fi
315
316
317dnl fortran libraries
318AC_ARG_WITH([fortranlibdir],
319        [AS_HELP_STRING([--with-fortranlibdir=FORTRANDIR],[fortran libraries directory ])],
320        fortranlibdir=$withval, fortranlibdir='')
321
322AC_ARG_WITH([fortranlibs],
323        [AS_HELP_STRING([--with-fortranlibs=FORTRANLIBS],[fortran libraries to link from C])],
324        fortranlibs=$withval, fortranlibs='none')
325
326if test "$fortranlibs" != 'none'
327then
328   EMOS_LIB="$emos -L$fortranlibdir $fortranlibs -Wl,-rpath $fortranlibdir"
329fi
330
331AC_SUBST(EMOS_LIB)
332
333dnl timer
334AC_ARG_ENABLE([timer],
335  [AS_HELP_STRING([--enable-timer],[enable timer [by default disabled]])],
336     [with_timer=${enableval}], [with_timer=no])
337if test "x${with_timer}" = xyes; then
338  AC_DEFINE(GRIB_TIMER,1,1->Timer on 0->Timer off)
339else
340  AC_DEFINE(GRIB_TIMER,0,1->Timer on 0->Timer off)
341fi
342
343
344dnl multithread packing
345AC_ARG_ENABLE([omp-packing],
346  [AS_HELP_STRING([--enable-omp-packing],[enable OpenMP multithreaded packing [by default disabled]])],
347     [with_omp=${enableval}], [with_omp=no])
348if test "x${with_omp}" = xyes; then
349  AC_DEFINE(OMP_PACKING,1,1->OpenMP packing 0->single thread packing)
350else
351  AC_DEFINE(OMP_PACKING,0,1->OpenMP packing 0->single thread packing)
352fi
353
354AC_ARG_WITH([netcdf],
355[AS_HELP_STRING([--with-netcdf=NETCDF],[enable netcdf encoding/decoding using netcdf library in NETCDF])],
356				netcdf_dir=$withval,netcdf_dir='none')
357with_netcdf=0
358if test $netcdf_dir != 'none'
359then
360	with_netcdf=1
361	CFLAGS="$CFLAGS -I${netcdf_dir}/include"
362    NETCDF_LDFLAGS="-L${netcdf_dir}/lib -lnetcdf"
363    ORIG_LDFLAGS=$LDFLAGS
364    LDFLAGS="$LDFLAGS $NETCDF_LDFLAGS"
365    AC_CHECK_LIB(netcdf,nc_open,netcdf_ok=1,netcdf_ok=0)
366    LDFLAGS=$ORIG_LDFLAGS
367	if test $netcdf_ok -eq 0
368	then
369      AC_MSG_NOTICE([
370!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
371  CONFIGURATION ERROR: netcdf test not passed.
372  Please check that the path to the netcdf library given in --with-netcdf=PATH_TO_NETCDF
373  is correct. Otherwise build without netcdf.
374!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375	  ])
376	  test 0 -eq 1
377	  exit
378    fi
379    AC_SUBST(NETCDF_LDFLAGS)
380    AC_DEFINE(HAVE_NETCDF,1,NETCDF enabled)
381fi
382
383dnl Check for jpeg
384AC_ARG_ENABLE([jpeg],
385  [AS_HELP_STRING([--disable-jpeg],[disable jpeg 2000 for grib 2 decoding/encoding [by default enabled]])],
386     without_jpeg=1,without_jpeg=0)
387
388AC_ARG_WITH([jasper],
389        [AS_HELP_STRING([--with-jasper=JASPER],[use specified jasper installation directory])],
390        jasper_dir=$withval, jasper_dir='system')
391
392JASPER_DIR=$jasper_dir
393AC_SUBST(JASPER_DIR)
394
395if test $jasper_dir != 'system'
396then
397  CFLAGS="$CFLAGS -I${jasper_dir}/include"
398  LDFLAGS="$LDFLAGS -L${jasper_dir}/lib"
399fi
400
401AC_ARG_WITH([openjpeg],
402        [AS_HELP_STRING([--with-openjpeg=OPENJPEG],[use specified openjpeg installation directory])],
403        openjpeg_dir=$withval, openjpeg_dir='system')
404
405OPENJPEG_DIR=$openjpeg_dir
406AC_SUBST(OPENJPEG_DIR)
407
408if test $openjpeg_dir != 'system'
409then
410  CFLAGS="$CFLAGS -I${openjpeg_dir}/include"
411  LDFLAGS="$LDFLAGS -L${openjpeg_dir}/lib"
412fi
413
414if test $without_jpeg -ne 1
415then
416    AC_DEFINE(HAVE_JPEG,1,JPEG enabled)
417    AC_CHECK_LIB(jasper,jas_stream_memopen,jasper_ok=1,jasper_ok=0)
418    AC_CHECK_LIB(openjpeg,opj_image_create,openjpeg_ok=1,openjpeg_ok=0)
419
420    jpeg_ok=0
421
422    # prefer openjpeg over jasper
423	if test $openjpeg_ok -eq 1
424	then
425	  jpeg_ok=1
426      LIB_OPENJPEG='-lopenjpeg -lm'
427      LIBS="$LIB_OPENJPEG $LIBS"
428      AC_DEFINE(HAVE_LIBOPENJPEG,1,Define if you have JPEG version 2 "Openjpeg" library)
429      AC_SUBST(LIB_OPENJPEG)
430    elif test $jasper_ok -eq 1
431    then
432	  jpeg_ok=1
433      LIB_JASPER='-ljasper'
434      LIBS="$LIB_JASPER $LIBS"
435      AC_DEFINE(HAVE_LIBJASPER,1,Define if you have JPEG version 2 "Jasper" library)
436      AC_SUBST(LIB_JASPER)
437	fi
438
439	if test $jpeg_ok -eq 0
440	then
441      AC_MSG_NOTICE([
442!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
443!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
444  CONFIGURATION ERROR: jpeg library (jasper or openjpeg) required.
445  jpeg library installation is not working or missing.
446
447  To fix this problem you have the following options.
448  1) Install without jpeg support enabled (--disable-jpeg), but you will not be able to
449     decode grib2 data encoded in jpeg.
450  2) Check if you have a jpeg library installed in a path different from your system path.
451     In this case you can provide your jpeg library installation path to the configure
452     through the options:
453        --with-jasper="jasper_lib_path"
454        --with-openjpeg="openjpeg_lib_path"
455  3) Download and install one of the supported jpeg libraries.
456!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
457!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
458	  ])
459	  [ 0 -eq 1 ]
460	  exit
461    fi
462  JPEG_TEST="jpeg.sh"
463  AC_SUBST(JPEG_TEST)
464fi
465
466dnl check for libaec
467CCSDS_TEST=""
468AC_ARG_WITH([aec],
469            [AS_HELP_STRING([--with-aec=DIR],
470                            [use specified libaec installation directory])],
471            ,[with_aec=no])
472
473if test "x$with_aec" != xno ; then
474  if test "x$with_aec" != xyes ; then
475    LDFLAGS="$LDFLAGS -L$with_aec/lib"
476    CPPFLAGS="$CPPFLAGS -I$with_aec/include"
477  fi
478  AC_CHECK_LIB(aec, aec_encode, , [AC_MSG_FAILURE(
479                 [aec test failed (--without-aec to disable)])])
480  CCSDS_TEST="ccsds.sh"
481  LIB_AEC='-laec'
482  AC_SUBST(LIB_AEC)
483  AEC_DIR="$with_aec"
484  AC_SUBST(AEC_DIR)
485
486fi
487AC_SUBST(CCSDS_TEST)
488
489dnl Check for png
490AC_ARG_WITH([png-support],
491  [AS_HELP_STRING([--with-png-support],[add support for png decoding/encoding])],
492     with_png=1,with_png=0)
493
494if test $with_png -gt 0
495then
496    AC_MSG_CHECKING(for PNG )
497    AC_MSG_RESULT()
498    AC_CHECK_HEADER(png.h,passed=1,passed=0)
499     AC_CHECK_LIB(png,png_read_png,passed=1,passed=0)
500    AC_MSG_CHECKING(if PNG support package is complete)
501
502    if test $passed -gt 0
503    then
504      LIB_PNG='-lpng'
505      LIBS="$LIB_PNG $LIBS"
506      AC_DEFINE(HAVE_LIBPNG,1,Define to 1 if you have the png library (-lpng))
507      AC_SUBST(LIB_PNG)
508      AC_MSG_RESULT(yes)
509    else
510      AC_MSG_RESULT(no -- some components failed test)
511    fi
512fi
513
514dnl Perl installation directory
515
516#PERL_INSTALL_OPTIONS="PREFIX=$prefix INSTALLDIRS=perl"
517PERL_INSTALL_OPTIONS="LIB=$default_perl_install"
518
519AC_ARG_ENABLE([install-system-perl],
520        [AS_HELP_STRING([--enable-install-system-perl],[perl modules will install in the standard perl installation ])],
521        enable_perl_install='yes', enable_perl_install='no')
522
523if test "$enable_perl_install" = 'yes'
524then
525    PERL_INSTALL_OPTIONS=""
526fi
527
528AC_SUBST(PERL_INSTALL_OPTIONS)
529
530dnl Disable build/install of Perl grib_api.
531AC_ARG_WITH([perl],
532        [AS_HELP_STRING([--with-perl=PERL],[use specified Perl binary to configure Perl grib_api])],
533        with_perl=$withval, with_perl='no')
534
535dnl Look for PERL if Perl requested
536if test "$with_perl" != 'no'
537then
538  if test "$with_perl" != 'yes'
539  then
540    AC_CACHE_CHECK(for perl,ac_cv_path_PERL,ac_cv_path_PERL="$with_perl");
541    PERL=$ac_cv_path_PERL
542    AC_SUBST(PERL)dnl
543  else
544    AC_PATH_PROGS(PERL,perl perl5,perl)dnl
545  fi
546fi
547
548dnl Get full paths
549builddir=`pwd`
550
551dnl Options to pass when configuring Perl grib_api
552GRIB_API_LIB="${builddir}/src/grib_api.a"
553GRIB_API_INC="${builddir}/src"
554AC_ARG_WITH([perl-options],
555  [AS_HELP_STRING([--with-perl-options=[OPTIONS]], [options to pass on command-line when
556                          generating Perl grib_api's Makefile from Makefile.PL])],
557  PERL_MAKE_OPTIONS=$withval)
558AC_SUBST(PERL_MAKE_OPTIONS)
559AC_SUBST(GRIB_API_LIB)
560AC_SUBST(GRIB_API_INC)
561
562AM_CONDITIONAL(WITH_PERL, test $with_perl != no)
563
564dnl Enable the Python interface in the build
565AC_ARG_ENABLE([python],
566  [AS_HELP_STRING([--enable-python],[Enable the Python interface in the build [by default disabled]])])
567
568dnl Check if the user wants numpy disabled
569AC_ARG_ENABLE([numpy],
570  [AS_HELP_STRING([--disable-numpy],[Disable NumPy as the data handling package for the Python interface [by default enabled]])])
571
572dnl Look for Python if requested
573if test "x$enable_python" = "xyes"
574then
575  dnl search for a python interpreter on the system dnl abort if one not found
576  dnl am_path_python sets many python vars - RTFM for more info
577  AM_PATH_PYTHON([2.5])
578
579  AC_ARG_VAR([PYTHON_INCLUDES], [Include flags for python])
580  AC_ARG_VAR([PYTHON_LDFLAGS], [Link flags for python])
581  AC_ARG_VAR([PYTHON_CFLAGS], [C flags for python])
582  AC_ARG_VAR([PYTHON_LIBS], [Libraries for python])
583  AC_ARG_VAR([PYTHON_CONFIG], [Path to python-config])
584
585  AC_PATH_PROGS([PYTHON_CONFIG],
586                [python$PYTHON_VERSION-config python-config],
587                [no],
588                [`dirname $PYTHON`])
589  AS_IF([test "$PYTHON_CONFIG" = no], [AC_MSG_ERROR([cannot find python-config for $PYTHON.])])
590
591  AC_MSG_CHECKING([python include flags])
592  PYTHON_INCLUDES=`$PYTHON_CONFIG --includes`
593  AC_MSG_RESULT([$PYTHON_INCLUDES])
594
595  AC_MSG_CHECKING([python link flags])
596  PYTHON_LDFLAGS=`$PYTHON_CONFIG --ldflags`
597  AC_MSG_RESULT([$PYTHON_LDFLAGS])
598
599  AC_MSG_CHECKING([python C flags])
600  PYTHON_CFLAGS=`$PYTHON_CONFIG --cflags`
601  AC_MSG_RESULT([$PYTHON_CFLAGS])
602
603  AC_MSG_CHECKING([python libraries])
604  PYTHON_LIBS=`$PYTHON_CONFIG --libs`
605  AC_MSG_RESULT([$PYTHON_LIBS])
606
607  # macro that gets the include path for Python.h which is used to build
608  # the shared library corresponding to the GRIB API Python module.
609  # AX_PYTHON_DEVEL
610
611  # enable testing scripts if building with Python
612  PYTHON_CHECK='examples/python'
613  AC_SUBST(PYTHON_CHECK)
614
615  data_handler=numpy
616  if test "x$enable_numpy" != "xno"
617  then
618    AC_MSG_CHECKING(whether numpy is installed)
619
620    has_numpy=`$PYTHON -c "import numpy;print numpy" 2> /dev/null`
621    if test "x$has_numpy" = "x"
622    then
623       AC_MSG_RESULT(no)
624       AC_MSG_ERROR([NumPy is not installed. Use --disable-numpy if you want to disable Numpy from the build.])
625    else
626       AC_MSG_RESULT(yes)
627       NUMPY_INCLUDE=`$PYTHON -c "import numpy;print numpy.get_include()"`
628       AC_SUBST(NUMPY_INCLUDE)
629    fi
630  else
631    data_handler=array
632  fi
633
634  PYTHON_DATA_HANDLER=$data_handler
635  AC_SUBST(PYTHON_DATA_HANDLER)
636fi
637
638AM_CONDITIONAL([WITH_PYTHON], [test x$PYTHON != x])
639AM_CONDITIONAL([WITH_FORTRAN], [test x$FORTRAN_MOD != x])
640AM_CONDITIONAL([CREATING_SHARED_LIBS], [test "x$enable_shared" = xyes])
641
642
643dnl AC_DISABLE_SHARED
644dnl LT_INIT
645
646dnl Checks for ar and rm
647AC_CHECK_PROG(RM, rm, rm)
648AC_CHECK_TOOL(AR, ar, ar)
649
650dnl Check if -pedantic available
651grib_api_PROG_CC_WARNING_PEDANTIC([-Wall])
652
653dnl Enable -Werror despite compiler version
654grib_api_ENABLE_WARNINGS_ARE_ERRORS
655
656dnl Checks for libraries
657AC_CHECK_LIB(m,pow)
658
659dnl Checks for header files.
660AC_HEADER_DIRENT
661AC_HEADER_STDC
662AC_CHECK_HEADERS([stddef.h stdlib.h string.h sys/param.h sys/time.h unistd.h math.h stdarg.h assert.h ctype.h fcntl.h])
663
664dnl Checks for typedefs, structures, and compiler characteristics.
665AC_TYPE_SIZE_T
666AC_HEADER_TIME
667
668dnl Checks for library functions.
669AC_FUNC_CLOSEDIR_VOID
670AC_TYPE_SIGNAL
671AC_FUNC_VPRINTF
672AC_CHECK_FUNCS([bzero gettimeofday])
673
674AX_LINUX_DISTRIBUTION
675
676AC_OUTPUT( Makefile src/Makefile fortran/Makefile tools/Makefile data/Makefile definitions/Makefile samples/Makefile ifs_samples/grib1/Makefile ifs_samples/grib1_mlgrib2/Makefile ifs_samples/grib1_mlgrib2_ieee64/Makefile tests/Makefile examples/C/Makefile examples/F90/Makefile tigge/Makefile perl/GRIB-API/Makefile.PL perl/Makefile python/Makefile examples/python/Makefile)
677
678AC_MSG_NOTICE([
679
680  Configuration completed.
681
682  You can now say 'make' to compile the grib_api package, 'make check' to
683  test it  and 'make install' to install it afterwards.
684
685  +------------------+
686  | IMPORTANT NOTICE |
687  +---------------------------------------------------------------------------------------------+
688  | Please note that 'ecCodes' is now the primary GRIB encoding/decoding package used at ECMWF. |
689  | Replacing GRIB API with ecCodes is expected to be transparent for current GRIB API users.   |
690  | In particular the 'grib_' functions are included in the ecCodes library.                    |
691  |                                                                                             |
692  | GRIB API support is being discontinued at the end of 2018.                                  |
693  | You are strongly advised to start the migration process.                                    |
694  |                                                                                             |
695  | For more details, please see:                                                               |
696  |   https://software.ecmwf.int/wiki/display/ECC/ecCodes+Home                                  |
697  +---------------------------------------------------------------------------------------------+
698
699     ])
700