File: configure.ac

package info (click to toggle)
hdf-eos4 3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,960 kB
  • sloc: ansic: 43,570; sh: 11,324; fortran: 9,649; makefile: 261
file content (578 lines) | stat: -rwxr-xr-x 16,685 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
###################################
#       -*- Autoconf -*-
###################################



###################################
# Boilerplate autoconf setup
###################################
AC_PREREQ([2.59])
AC_INIT([hdf-eos2], [3.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

LT_INIT([disable-shared])


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

AC_CONFIG_HEADER([include/HE2_config.h])
AC_CONFIG_FILES([Makefile
                include/Makefile
                doc/Makefile
                src/Makefile
                samples/Makefile
		hdf-eos4.pc
                testdrivers/Makefile
                testdrivers/grid/Makefile
                testdrivers/point/Makefile
                testdrivers/swath/Makefile])


###################################
#     Additional Macros
###################################
m4_include(m4/hdf4.m4)
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"
])


###################################
#  JPEG library checks
###################################

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

HDF_CHECK_LIB([jpeg],[jpeg],[jpeg_set_defaults],[,/usr/local/lib,/opt/local/lib,/usr/lib64])
AS_IF(
    [test -z "$HAVE_LIBJPEG"],
    [AC_MSG_ERROR(unable to find libjpeg)]
)



###################################
#  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_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"],
    [
        # If we have Fortran 77, check its name mangling
        # We expect this to be one of UL, ul, UL_, ul_, _UL, _ul, _UL_, _ul_
        #
        AS_IF(
            [test -n "$F77"],
            [
                FORTRAN_77="yes"

                # Explicitly include known dependent macros, otherwise autotools will
                # bind them into the main body of the configure script where they will
                # be executed, regardeless as to whether or not FORTRAN is requested or
                # exists. This leads to failures on systems without FORTRAN compilers.
                
                AC_F77_LIBRARY_LDFLAGS
                AC_F77_DUMMY_MAIN
                _AC_F77_NAME_MANGLING
                AC_F77_FUNC([Ul],FORTRAN_NAME_MANGLE)

                # Set up the appropriate control definitions to give us the appropriate
                # FORTRAN api.
                #
                AS_IF(
                    # Check the common name mangling 'standards'

                    [test "$FORTRAN_NAME_MANGLE" == "ul"],[
                        FORTRAN_NAME_MANGLE="lower case"
                        CPPFLAGS="$CPPFLAGS -DFORTRAN_API _DFORTRAN_API_LOWERCASE -DFORTRAN_API_SUFFIX= -DFORTRAN_API_PREFIX="
                    ],

                    [test "$FORTRAN_NAME_MANGLE" == "ul_"],[
                        FORTRAN_NAME_MANGLE="lower case, trailing underscore"
                        CPPFLAGS="$CPPFLAGS -DFORTRAN_API -DFORTRAN_API_LOWERCASE -DFORTRAN_API_SUFFIX=_ -DFORTRAN_API_PREFIX="
                    ],

                    [test "$FORTRAN_NAME_MANGLE" == "_ul"],[
                        FORTRAN_NAME_MANGLE="lower case, leading underscore"
                        CPPFLAGS="$CPPFLAGS -DFORTRAN_API -DFORTRAN_API_LOWERCASE -DFORTRAN_API_SUFFIX= -DFORTRAN_API_PREFIX=_"
                    ],

                    [test "$FORTRAN_NAME_MANGLE" == "UL"],[
                        FORTRAN_NAME_MANGLE="upper case"
                        CPPFLAGS="$CPPFLAGS -DFORTRAN_API _DFORTRAN_API_UPPERCASE -DFORTRAN_API_SUFFIX= -DFORTRAN_API_PREFIX="
                    ],

                    [test "$FORTRAN_NAME_MANGLE" == "UL_"],[
                        FORTRAN_NAME_MANGLE="upper case, trailing underscore"
                        CPPFLAGS="$CPPFLAGS -DFORTRAN_API -DFORTRAN_API_UPPERCASE -DFORTRAN_API_SUFFIX=_ -DFORTRAN_API_PREFIX="
                    ],

                    [test "$FORTRAN_NAME_MANGLE" == "_UL"],[
                        FORTRAN_NAME_MANGLE="upper case, leading underscore"
                        CPPFLAGS="$CPPFLAGS -DFORTRAN_API -DFORTRAN_API_UPPERCASE -DFORTRAN_API_SUFFIX= -DFORTRAN_API_PREFIX=_"
                    ],

                    [test -n "$FORTRAN_NAME_MANGLE"],
                    [
                        AC_MSG_ERROR([Unsupported fortran name-mangling - please use --disable-fortran])
                        FORTRAN_77="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="-I$szlib_inc $CPPFLAGS"
                LDFLAGS="-L$szlib_lib $LDFLAGS"
            ])

        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 <stdlib.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 HDF4 library
###################################

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

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


AS_IF(
    [test "x$withval" == "xno"],
    [
        AC_MSG_ERROR([HDF4 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

        CHECK_LIBHDF4([,/usr/local/lib,/opt/local/lib,/usr/lib64/hdf])


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

        CHECK_INCHDF4([,/usr/local/include,/opt/local/include,/usr/include/hdf])
    ],


    # A user specified directory (one or two)

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

        CPPFLAGS="-I$hdf4_inc $CPPFLAGS"
        LDFLAGS="-L$hdf4_lib $LDFLAGS"

        AC_CHECK_LIB([df],[Hopen])
        AC_CHECK_LIB([mfhdf],[hdf_close])
        AC_CHECK_HEADERS([hdf.h])
        AC_CHECK_HEADERS([mfhdf.h])
    ])


# Verify presence of all required headers and libraries, and
# that we can link an hdf4 program. This will set
# HAVE_HDF4 if found, otherwise it will error out.

CHECK_HDF4





###################################
#  Check for SZIP in HDF4 library
###################################

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

AC_MSG_CHECKING([for hdf4 szip decoding filter])
AC_RUN_IFELSE(
    [AC_LANG_PROGRAM(
        [
            #include <hdf.h>
	    #include <stdlib.h>
        ],[
            comp_coder_t codertype = COMP_CODE_SZIP;
            uint32 configinfo;
            int decoder = 0;

            HCget_config_info(codertype, &configinfo);
            decoder = configinfo & COMP_DECODER_ENABLED;
            if (decoder) exit(0);
            else exit(1);
        ])
    ],
    [
        AC_MSG_RESULT([yes])

        # HDF4 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([HDF4 requires SZIP, please use --with-szlib])
            ])

        AC_DEFINE(HAVE_HDF4_SZIP_DECODER, 1, [Define if HDF4 has szip decoder filter])
    ],[
        AC_MSG_RESULT([no])
    ])



AC_MSG_CHECKING([for hdf4 szip encoding support])
AC_RUN_IFELSE(
    [AC_LANG_PROGRAM(
        [
            #include <hdf.h>
	    #include <stdlib.h>
        ],[
            comp_coder_t codertype = COMP_CODE_SZIP;
            uint32 configinfo;
            int encoder = 0;

            HCget_config_info(codertype, &configinfo);
            encoder = configinfo & COMP_ENCODER_ENABLED;
            if (encoder) exit(0);
            else exit(1);
        ])
    ],[
        AC_MSG_RESULT([yes])
        AS_IF(
            [test "x$USE_SZIP_ENCODER" != "xyes"],
            [
                AC_MSG_ERROR([HDF4 requires SZIP with encoding support])
            ])

        AC_DEFINE(HAVE_HDF4_SZIP_ENCODER, 1, [Define if HDF4 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_MALLOC
AC_FUNC_MEMCMP
AC_FUNC_REALLOC
AC_FUNC_ERROR_AT_LINE
AC_CHECK_FUNCS([memchr memmove memset pow sqrt strchr strstr])

# Add a macro to distinguish automatic configuration from
# the original configuration; this will affect the handling
# of HDFEOSVersion.h file.
AC_DEFINE([EOS2_AUTO_CONFIG], [1], [Define the automatic configuration macro.])



AM_CONDITIONAL([FORTRAN_77_CONDITIONAL], [test "X$FORTRAN_77" = "Xyes"])
AM_CONDITIONAL([FORTRAN_90_CONDITIONAL], [test "X$FORTRAN_90" = "Xyes"])
AM_CONDITIONAL([SZIP_ENCODER_CONDITIONAL], [test "X$USE_SZIP_ENCODER" = "Xyes"])


AC_OUTPUT


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

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

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

AC_MSG_NOTICE([ ])
AC_MSG_NOTICE([        -- FORTRAN --])
AS_IF(
    [test "x$FORTRAN_77" == "xyes"],
    [
        AC_MSG_NOTICE([F77:                      $F77])
        AC_MSG_NOTICE([FORTRAN name mangling:    $FORTRAN_NAME_MANGLE ])
    ],
    [
        AC_MSG_NOTICE([Not building FORTRAN 77 code])
    ])