File: configure.ac

package info (click to toggle)
hdf-eos5 2%3A2.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,688 kB
  • sloc: ansic: 92,051; fortran: 31,463; sh: 11,395; makefile: 492
file content (584 lines) | stat: -rwxr-xr-x 15,936 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
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
160
161
162
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
###################################
#       -*- Autoconf -*-
###################################



###################################
# Boilerplate autoconf setup
###################################
AC_PREREQ([2.59])
AC_INIT([hdf-eos5], [2.0], null@bogus.email)
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_MACRO_DIR([m4])

AM_INIT_AUTOMAKE([foreign])
AM_MAINTAINER_MODE

## Note we disable shared libraries otherwise gfortran fails linking against the resulting
## libX.la files. With shared libraries disables, libtool links gfortran against the static
## library libX.a. If fortran is disabled, this can be overridden using --enabled-shared
## with configure

#AC_DISABLE_SHARED
AC_PROG_LIBTOOL



###################################
# Files that need to be configured
###################################

AC_CONFIG_HEADER([include/HE5_config.h])
AC_CONFIG_FILES([Makefile
                include/Makefile
                src/Makefile
                samples/Makefile
                testdrivers/Makefile
                testdrivers/grid/Makefile
                testdrivers/point/Makefile
                testdrivers/swath/Makefile
                testdrivers/za/Makefile
                testdrivers/threads/Makefile
                doc/Makefile
		hdf-eos5.pc])


###################################
#     Additional Macros
###################################
m4_include(m4/stdlib.m4)
m4_include(m4/stdinc.m4)



###################################
#       Start checks
###################################

AC_LANG(C)

# Check for the math library that HDF4 needs
#
AC_CHECK_LIB([m], [ceil])


######################################################################
#  Check size of some types
# We pass these through directly via the cpp flags rather than the config
# file to make it easier (given the current code state) to get it where
# it needs to go.
######################################################################
AC_CHECK_SIZEOF(long)
CPPFLAGS="${CPPFLAGS} -DSIZEOF_LONG=$ac_cv_sizeof_long"



###################################
#  Check endian-ness
###################################
AC_C_BIGENDIAN([
    AC_DEFINE([BIG_ENDIAN],[1],[Define if system is big-endian])
    CPPFLAGS="${CPPFLAGS} -DBIG_ENDIAN=1"
])


###################################
#  pthread library checks
# This will be needed if the HDF5
# library is threaded, otherwise it
# will be ignored.
###################################
AC_CHECK_LIB([pthread], [pthread_create])


###################################
#  ZLIB library checks
###################################

# HDFEOS does not need libz directly, but the HDF library might. This means
# we only need to find the libary, not the header files.

HDF_CHECK_LIB([zlib],[z],[compress2],[,/usr/local/lib,/opt/local/lib,/usr/lib64])
AS_IF(
    [test -z "$HAVE_LIBZ"],
    [AC_MSG_ERROR(unable to find libz)]
)



###################################
#  FORTRAN compiler check
###################################

# User may enable fortran components explicity with --enable-fortran
# or --enable-fortran=yes

AC_PROG_F77
AC_PROG_FC

AC_ARG_ENABLE(
    [fortran],
    AS_HELP_STRING([--enable-fortran], [Enable fortran components/tests]),,)

# Check to see if explicitly disabled

AS_IF(
    [test "x$enable_fortran" != "xyes"],
    [
         FC=""
         F77=""
    ])

AS_IF([test -n "$FC"],
    [
        AC_CHECK_SIZEOF([int*])
        AS_IF(
            [test "x$ac_cv_sizeof_intp" == "x4"],
            [
                F2CFORTRAN_32PTR="yes"
            ],[
                AC_MSG_NOTICE([Non-32 bit system; some fortran tests will be skipped])
            ])

        AC_MSG_CHECKING([fortran compiler])
        AC_LANG_PUSH([Fortran])
        AC_LINK_IFELSE(
            [
                AC_LANG_PROGRAM([], [
                    INTEGER :: I
                    REAL :: R
                    I=TRANSFER(R,I)
                ])
            ],[
                AC_MSG_RESULT([Fortran 90 code was successfully compiled; assume f90 or later])
                F2CFORTRAN_90="yes"
            ],[
                AC_MSG_RESULT([Fortran 90 code format was not compiled; assume f77])
            ])
        AC_LANG_POP([Fortran])

        F2CFORTRAN_MACRO="yes"
        CPPFLAGS="$CPPFLAGS -Df2cFortran=1"
    ],[
        AC_MSG_NOTICE([Fortran compiler not found])
        F2CFORTRAN_MACRO="no"
    ])



###################################
#  SZLIB checks
###################################

dnl --------------------------------------------------
dnl Check whether szlib is enabled.
dnl If HDF4 is built with szlib, user should use --with-szlib=DIR option.
dnl If this option is given, whether SZIP is decoder only or decoder plus encoder
dnl should be checked.

AC_ARG_WITH([szlib],
            [AC_HELP_STRING([--with-szlib=DIR],
                            [Use szlib library for external szlib I/O
                             filter.  Linker must be able to find szlib
                             if HDF4 was build with szip.])],,
            withval=default)

AS_IF(
    ## if withval==no szlib is disabled
    ##
    [test "x$withval" == "xno"],
    [
        HAVE_LIBSZ="no"
    ],


    ## Look for it, but do not abort if we can't find it
    ##
    [test "x$withval" == "xdefault"],
    [
        HDF_CHECK_INC_PATH([szlib.h],[,/usr/local/include,/opt/local/include,/opt/local/lib/libaec/include])
        HDF_CHECK_LIB_PATH([sz],[SZ_BufftoBuffCompress],[,/usr/local/lib,/opt/local/lib,/opt/local/lib/libaec/lib,/usr/lib64])
    ],


    ## if withval==yes We need to find szlib
    ##
    [test "x$withval" == "xyes"],
    [

        HDF_CHECK_INC_PATH([szlib.h],[,/usr/local/include,/opt/local/include,/opt/local/lib/libaec/include])
        AS_IF(
            [test "x$ac_cv_header_szlib_h" != "xyes"],
            [AC_MSG_ERROR([couldn't find szlib header])]
        )

        HDF_CHECK_LIB_PATH([sz],[SZ_BufftoBuffCompress],[,/usr/local/lib,/opt/local/lib,/opt/local/lib/libaec/lib,/usr/lib64])
        AS_IF(
            [test "x$HAVE_LIBSZ" != "xyes"],
            [AC_MSG_ERROR([couldn't find szlib library])]
        )
    ],

    ##  Else
    ##
    [
        szlib_inc="`echo $withval |awk -F, '{print $1}'`"
        szlib_lib="`echo $withval |awk -F, '{print $2}'`"
        AS_IF(
            [test -z "$szlib_inc"],
            [
                # No options provided at all
            ],
            [
                # A single option provided - use it for both inc and lib, but add suffix
                AS_IF(
                    [test -z "$szlib_lib"],
                    [
                        szlib_lib="$szlib_inc/lib"
                        szlib_inc="$szlib_inc/include"
                    ])
                CPPFLAGS="$CPPFLAGS -I$szlib_inc"
                LDFLAGS="$LDFLAGS -L$szlib_lib"
            ])

        AC_CHECK_HEADERS(
            [szlib.h],,
            [
                AC_MSG_ERROR([couldn't find szlib header file])
            ])
        AC_CHECK_LIB(
            [sz],
            [SZ_BufftoBuffCompress],,
            [
                AC_MSG_ERROR([couldn't find szlib library])
            ])

        HAVE_LIBSZ="yes"
    ])



# If szlib is available, additional checks are required to determine the
# available functionality. By default decoding is assumed. We are really just
# interested in whether or not encoding is also enabled.

AS_IF(
    [test "x$HAVE_LIBSZ" == "xyes"],
    [
        # Check for encoding functionality

        AC_MSG_CHECKING([if szlib is functional])
        AC_TRY_RUN(
            [
                #include <stddef.h>
		#include <stdlib.h>
                #include <szlib.h>

                int main(void)
                {
                    SZ_encoder_enabled();
                    exit(0);
                }
            ],[
                AC_MSG_RESULT([yes])
            ],[
                AC_MSG_ERROR([szlib is not functional])
            ])
        AC_DEFINE(HAVE_FILTER_SZIP, 1, [Define if support for szip filter is enabled])

        AC_MSG_CHECKING([szlib encoding])
        AC_TRY_RUN(
            [
                #include <stddef.h>
                #include <szlib.h>

                int main(void)
                {
                    /* SZ_encoder_enabled returns 1 if encoder is present */
                    if(SZ_encoder_enabled() == 1)
                        exit(0);
                    else
                        exit(1);
                }
            ],[
                AC_MSG_RESULT([yes])
                AC_DEFINE(HAVE_FILTER_SZIP_ENCODER, 1, [Define if support for szip encoder filter is enabled])
                USE_SZIP_ENCODER="yes"
            ],[
                AC_MSG_RESULT([no])
            ])
    ])



###################################
#  Check for HDF5 library
###################################

# Note that this is a required component - we cannot build HDF-EOS5 without it

AC_ARG_WITH(
    [hdf5],
    [AC_HELP_STRING(
        [--with-hdf5=DIR],
        [Specify path to HDF5 library to use while building
        [default=yes]]
    )],,
    withval=yes)


AS_IF(
    [test "x$withval" == "xno"],
    [
        AC_MSG_ERROR([HDF5 is a required dependency.])
    ],

    # No options, so we must try and find the HDF4 library

    [test "x$withval" == "xyes"],
    [
        # Test some library locations to see if we can find the HDF libraries

        HDF_CHECK_LIB_PATH([hdf5],[H5Fcreate],[,/usr/local/lib,/opt/local/lib,/usr/lib64,/usr/lib/x86_64-linux-gnu/hdf5/serial])

        # Check to see if we can find the HDF5 header file

        HDF_CHECK_INC_PATH([hdf5.h],[,/usr/local/include,/opt/local/include,/usr/include/hdf5/serial])
    ],


    # A user specified directory (one or two)

    [
        hdf5_inc="`echo $withval |awk -F, '{print $1}'`"
        hdf5_lib="`echo $withval |awk -F, '{print $2}'`"
        AS_IF(
            [test -z "$hdf5_lib"],
            [
                hdf5_lib="$hdf5_inc/lib"
                hdf5_inc="$hdf5_inc/include"
            ])

        HDF_CHECK_LIB_PATH([hdf5],[H5Fcreate],[,$hdf5_lib])
        HDF_CHECK_INC_PATH([hdf5.h],[,$hdf5_inc])
    ])

# Verify presence of all required headers and libraries

AS_IF(
    [test -z "$HAVE_LIBHDF5"],
    [AC_MSG_ERROR(unable to find HDF5 library)]
)
AS_IF(
    [test "x$ac_cv_header_hdf5_h" != "xyes"],
    [AC_MSG_ERROR([couldn't find HDF5 library header files])]
)


###################################
#  Check for High Level HDF5 lib
###################################
AC_CHECK_LIB([hdf5_hl],[H5DSset_label])



###################################
#  Check for thread safety in
#  HDF5 library
###################################

AC_MSG_CHECKING([if HDF5 threadsafe mode is enabled])
AC_RUN_IFELSE(
    [AC_LANG_PROGRAM(
        [
            #include <hdf5.h>
        ],[
            #ifdef H5_HAVE_THREADSAFE
                return 0;
            #else
                return 1;
            #endif
        ])
    ],[
        AC_MSG_RESULT([yes])
        HDF5_THREADSAFE="yes"
        AS_IF(
            [test "x$ac_cv_lib_pthread_pthread_create" == "xno"],
            [
                AC_MSG_ERROR([HDF5 is multi-threaded, but no threading library found])
            ])
    ],
    [
        AC_MSG_RESULT([no])
        HDF5_THREADSAFE="no"
    ])

# Record threadsafe status in config.h and for Makefiles

if test "x$HDF5_THREADSAFE" = "xyes"; then
    AC_DEFINE([_HDFEOS5_THREADSAFE], [1], [Define if threadsafe HDF-EOS is enabled])
fi
AM_CONDITIONAL([HDF5_THREADSAFE], [test "x$HDF5_THREADSAFE" = "xyes"])


###################################
#  Check for H5free_memory in
#  HDF5 library
###################################
AC_CHECK_FUNCS([H5free_memory])

###################################
#  Check for SZIP in HDF5 library
###################################

# At this point, we know we can link against hdf5.

AC_MSG_CHECKING([for hdf5 szip decoding filter])
AC_RUN_IFELSE(
    [AC_LANG_PROGRAM(
        [
            #include <H5Ipublic.h>
            #include <H5Zpublic.h>
        ],[
            herr_t ret;
            unsigned int flags = 0;
            int decoder = 0;

            ret = H5Zget_filter_info(H5Z_FILTER_SZIP, &flags);
            if (ret < 0) exit(1);
            decoder = flags & H5Z_FILTER_CONFIG_DECODE_ENABLED;
            if (decoder)
                exit(0);
            else
                exit(1);
        ])
    ],
    [
        AC_MSG_RESULT([yes])

        # HDF5 supports decoding. We have to make sure szlib is included. In the case
        # of static library linkage, this would already have been verified (the program
        # wouldn't run), but shared object libraries might use lazy resolution, so we
        # verify
        AS_IF(
            [test "x$HAVE_LIBSZ" != "xyes"],
            [
                AC_MSG_ERROR([HDF5 requires SZIP, please use --with-szlib])
            ])

        AC_DEFINE(HAVE_HDF5_SZIP_DECODER, 1, [Defined if HDF5 has szip decoder filter])
        AC_DEFINE(H5_HAVE_FILTER_SZIP, 1, [Define if HDF5 has szip any type of filter])
    ],[
        AC_MSG_RESULT([no])
    ])



AC_MSG_CHECKING([for hdf5 szip encoding support])
AC_RUN_IFELSE(
    [AC_LANG_PROGRAM(
        [
            #include <H5Ipublic.h>
            #include <H5Zpublic.h>
        ],[
            herr_t ret;
            unsigned int flags = 0;
            int encoder = 0;

            ret = H5Zget_filter_info(H5Z_FILTER_SZIP, &flags);
	        if (ret < 0) exit(1);
            encoder = flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED;
            if (encoder)
                exit(0);
            else
                exit(1);
        ])
    ],[
        AC_MSG_RESULT([yes])
        AS_IF(
            [test "x$USE_SZIP_ENCODER" != "xyes"],
            [
                AC_MSG_ERROR([HDF5 requires SZIP with encoding support])
            ])
        AC_DEFINE(HAVE_HDF5_SZIP_ENCODER, 1, [Define if HDF5 has szip encoder filter])
    ],[
        AC_MSG_RESULT([no])
    ])



###################################
#  Enable/disable installation of
# GCTP headers (usually not needed)
###################################
AC_ARG_ENABLE(
    [gctp-include],
    AS_HELP_STRING([--enable-gctp-include], [Enable installation of GCTP library headers]),,)

AM_CONDITIONAL([GCTP_INCLUDE_CONDITIONAL], [test "x$enable_gctp_include" == "xyes"])





###################################
#  Miscellaneous checks
###################################

CFLAGS=$CFLAGS

# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET

# Checks for libraries.

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([limits.h malloc.h stdlib.h string.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_OFF_T
AC_TYPE_SIZE_T

# Checks for library functions.
AC_FUNC_MEMCMP
AC_FUNC_ERROR_AT_LINE
AC_CHECK_FUNCS([memchr memmove memset pow sqrt strchr strstr])



# Use version 1 of the hdf5 API

AC_DEFINE([H5_USE_16_API], [1], [Define if HDF-EOS5 should use version 1 api])


AM_CONDITIONAL([F2CFORTRAN_CONDITIONAL], [test "x$F2CFORTRAN_MACRO" = "xyes"])
AM_CONDITIONAL([F2CFORTRAN_90_CONDITIONAL], [test "x$F2CFORTRAN_90" = "xyes"])
AM_CONDITIONAL([F2CFORTRAN_32PTR_CONDITIONAL], [test "x$F2CFORTRAN_32PTR" = "xyes"])
AM_CONDITIONAL([SZIP_ENCODER_CONDITIONAL], [test "x$H5_HAVE_FILTER_SZIP" = "xyes"])


AC_OUTPUT


###################################
# SUMMARY
###################################

AC_MSG_NOTICE([------------------------------------------])
AC_MSG_NOTICE([        Configuration Summary])
AC_MSG_NOTICE([------------------------------------------])

AC_MSG_NOTICE([ ])
AC_MSG_NOTICE([CC:                       $CC])
AC_MSG_NOTICE([FC:                       $FC])
AC_MSG_NOTICE([F77:                      $F77])
AC_MSG_NOTICE([C flags:                  $CFLAGS])
AC_MSG_NOTICE([CPP flags:                $CPPFLAGS])
AC_MSG_NOTICE([LD flags:                 $LDFLAGS])
AC_MSG_NOTICE([LIB flags:                $LIBS])