File: configure.ac

package info (click to toggle)
libhdf4 4.2.13-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 27,132 kB
  • sloc: ansic: 153,672; sh: 15,589; fortran: 12,333; java: 4,765; xml: 1,150; makefile: 1,020; yacc: 680; pascal: 420; lex: 170; cpp: 77; csh: 41
file content (1127 lines) | stat: -rw-r--r-- 35,134 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
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
## Process this file with autoconf to produce configure.
##
##
## Copyright by The HDF Group.
## Copyright by the Board of Trustees of the University of Illinois.
## All rights reserved.
##
## This file is part of HDF.  The full HDF copyright notice, including
## terms governing use, modification, and redistribution, is contained in
## the COPYING file, which can be found at the root of the source code
## distribution tree, or in https://support.hdfgroup.org/ftp/HDF/releases/.
## If you do not have access to either file, you may request a copy from
## help@hdfgroup.org.
##
##
AC_REVISION($Id$)

## ======================================================================
## Initialize configure.
## ======================================================================
## AC_INIT takes the name of the package, the version number, and an
## email address to report bugs. AC_CONFIG_SRCDIR takes a unique file
## as its argument.
##
## NOTE: Do not forget to change the version number here when we do a
## release!!!
##
AC_INIT([HDF], [4.2.13], [help@hdfgroup.org])
AC_CONFIG_SRCDIR([hdf/src/atom.c])
AC_CONFIG_AUX_DIR([bin])
AC_CONFIG_HEADER([hdf/src/h4config.h])
AC_CONFIG_MACRO_DIR([m4])

## AM_INIT_AUTOMAKE takes a list of options that should be applied to
## every Makefile.am when automake is run.
AM_INIT_AUTOMAKE([foreign])

## AM_MAINTAINER_MODE turns off "rebuild rules" that contain dependencies
## for Makefiles, configure, etc.  If AM_MAINTAINER_MODE
## is *not* included here, these files will be rebuilt if out of date.
## This is a problem because if users try to build on a machine with
## the wrong versions of autoconf and automake, these files will be
## rebuilt with the wrong versions and bad things can happen.
## Also, CVS doesn't preserve dependencies between timestamps, so
## Makefiles will often think rebuilding needs to occur when it doesn't.
## Developers should './configure --enable-maintainer-mode' to turn on
## rebuild rules.
AM_MAINTAINER_MODE

## ----------------------------------------------------------------------
## Set prefix default (install directory) to a directory in the build area.
## This allows multiple src-dir builds within one host.
AC_PREFIX_DEFAULT([`pwd`/hdf4])

## Run post processing on files created by configure.
## src/h4config.h:
## libhdf4.settings:
## Remove all lines begun with "#" which are generated by CONDITIONAL's of
## configure.
AC_CONFIG_COMMANDS([h4config], [
  echo "modifying hdf/src/h4config.h"
  sed 's/#define /#define H4_/' < hdf/src/h4config.h |\
    sed 's/#undef /#undef H4_/' > h4config
  cp h4config hdf/src/h4config.h
  rm -f h4config

#if test ! -f hdf/src/h4config.h; then
#    /bin/mv -f h4config hdf/src/h4config.h
#  elif (diff h4config hdf/src/h4config.h >/dev/null); then
#    /bin/rm -f h4config
#    echo "hdf/src/h4config.h is unchanged"
#  else
#    /bin/mv -f h4config hdf/src/h4config.h
#  fi

  echo "Post process libhdf4.settings"
  sed '/^#/d' < libhdf4.settings > libhdf4.settings.TMP
  cp libhdf4.settings.TMP libhdf4.settings
  rm -f libhdf4.settings.TMP
])

## ======================================================================
## Information on the package
## ======================================================================

## Dump all shell variables values.
AC_MSG_CHECKING([shell variables initial values])
set >&AS_MESSAGE_LOG_FD
AC_MSG_RESULT([done])

AC_CANONICAL_HOST

AC_MSG_CHECKING([if basename works])
BASENAME_TEST="`basename /foo/bar/baz/qux/basename_works`"
if test $BASENAME_TEST != "basename_works"; then
  AC_MSG_ERROR([basename program doesn't work])
else
  AC_MSG_RESULT([yes])
fi

AC_MSG_CHECKING([if xargs works])
XARGS_TEST="`echo /foo/bar/baz/qux/xargs_works | xargs basename`"
if test $XARGS_TEST != "xargs_works"; then
  AC_MSG_ERROR([xargs program doesn't work])
else
  AC_MSG_RESULT([yes])
fi

## Source any special files that we need. These files normally aren't
## present but can be used by the maintainers to fine tune things like
## turning on debug or profiling flags for the compiler. The search order
## is:
##
##         CPU-VENDOR-OS
##         VENDOR-OS
##         CPU-OS
##         CPU-VENDOR
##         OS
##         VENDOR
##         CPU
##
## If the `OS' ends with a version number then remove it. For instance,
## `freebsd3.1' would become `freebsd'
##
case "$host_os" in
  aix4.*)       host_os_novers="aix4.x"     ;;
  aix5.*)       host_os_novers="aix5.x"     ;;
  darwin10.*)   host_os_novers="darwin10.x" ;;
  darwin11.*)   host_os_novers="darwin11.x" ;;
  darwin12.*)   host_os_novers="darwin12.x" ;;
  freebsd*)     host_os_novers="freebsd"    ;;
  solaris2.*)   host_os_novers="solaris2.x" ;;
  *)            host_os_novers="$host_os"   ;;
esac

host_config="none"
for f in $host_cpu-$host_vendor-$host_os        \
         $host_cpu-$host_vendor-$host_os_novers \
         $host_vendor-$host_os                  \
         $host_vendor-$host_os_novers           \
         $host_cpu-$host_os                     \
         $host_cpu-$host_os_novers              \
         $host_cpu-$host_vendor                 \
         $host_os                               \
         $host_os_novers                        \
         $host_vendor                           \
         $host_cpu ; do
  AC_MSG_CHECKING([for config $f])
  if test -f "$srcdir/config/$f"; then
    host_config=$srcdir/config/$f
    AC_MSG_RESULT([found])
    break
  fi
  AC_MSG_RESULT([no])
done
if test "X$host_config" != "Xnone"; then
  CC_BASENAME="`echo $CC | cut -f1 -d' ' | xargs basename 2>/dev/null`"
  F77_BASENAME="`echo $F77 | cut -f1 -d' ' | xargs basename 2>/dev/null`"
  CXX_BASENAME="`echo $CXX | cut -f1 -d' ' | xargs basename 2>/dev/null`"
  . $host_config
fi

## ======================================================================
## Checks for NetCDF-2.3.2 support
## ======================================================================

# We disable Fortran netCDF APIs and their testing when --disable-netcdf is used.
# Let's define a proper variable to be used in mfhdf/testfortran.sh.in to run
# the netCDF Fortran APIs test program "ftest".
AC_SUBST(TEST_FORTRAN_NETCDF) TEST_FORTRAN_NETCDF="yes"

AC_ARG_ENABLE([netcdf],
              [AS_HELP_STRING([--enable-netcdf],
                              [Build HDF4 versions of NetCDF APIs (version 2.3.2) [default=yes]])],,
              [enableval="yes"])

case "$enableval" in
  yes)
    BUILD_NETCDF="yes"
    AC_DEFINE([HAVE_NETCDF], [1], [Define if we support HDF NetCDF APIs version 2.3.2])
    ;;
  no)
    BUILD_NETCDF="no"
    TEST_FORTRAN_NETCDF="no"
    ;;
esac
AM_CONDITIONAL([HDF_BUILD_NETCDF], [test "X$BUILD_NETCDF" = "Xyes"])
AC_SUBST([BUILD_NETCDF])

## ======================================================================
## Checks for programs
## ======================================================================

AC_PROG_MAKE_SET

AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX

AC_ARG_ENABLE([fortran],
              [AS_HELP_STRING([--enable-fortran],
                              [Build Fortran into library [default=yes]])],,
              [enableval="yes"])

case "$enableval" in
  yes)
    BUILD_FORTRAN="yes"
    AC_PROG_F77
    AC_F77_WRAPPERS

    if test "X$F77" = "X"; then
      BUILD_FORTRAN="no"
    fi
    ;;
  no)
    BUILD_FORTRAN="no"
    F77="no"
    ;;
esac
AM_CONDITIONAL([HDF_BUILD_FORTRAN], [test "X$BUILD_FORTRAN" = "Xyes"])
AC_SUBST([BUILD_FORTRAN])

## ----------------------------------------------------------------------
## Check if they would like the Java native interface (JNI) compiled
##
AC_SUBST([JNIFLAGS])
AC_SUBST([H4_JAVACFLAGS])
AC_SUBST([H4_JAVAFLAGS])

## This needs to be exposed for the library info file even if Java is disabled.
AC_SUBST([HDF_JAVA])

## Default is no Java
HDF_JAVA=no

AC_SUBST([H4_CLASSPATH]) H4_CLASSPATH=""
AC_MSG_CHECKING([if Java JNI interface enabled])

AC_ARG_ENABLE([java],
              [AS_HELP_STRING([--enable-java],
                              [Compile the Java JNI interface [default=no]])],
              [HDF_JAVA=$enableval])

if test "X$HDF_JAVA" = "Xyes"; then
  if test "X${enable_shared}" != "Xno"; then
    echo "yes"
    if test "X$CLASSPATH" = "X"; then
      H4_CLASSPATH=".:$srcdir/java/lib"
    else
      H4_CLASSPATH=".:$CLASSPATH:$srcdir/java/lib"
    fi
    ## Checks for programs.
    AX_JAVA_OPTIONS
    H4_JAVACFLAGS=$JAVACFLAGS
    H4_JAVAFLAGS=$JAVAFLAGS
    AX_PROG_JAVAC
    AX_PROG_JAVA
    AX_PROG_JAR
    AX_PROG_JAVADOC
    ## Find the include directories needed for building JNI code
    AX_JNI_INCLUDE_DIR()
    for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS
    do
      JNIFLAGS="$JNIFLAGS -I$JNI_INCLUDE_DIR"
    done
    ## Find junit for testing the JNI code
    AX_CHECK_CLASSPATH()
    CLASSPATH_ENV=$H4_CLASSPATH
    AX_CHECK_JUNIT()
    AX_CHECK_JAVA_HOME

    AC_MSG_RESULT([yes])
  else
    AC_MSG_ERROR([Java requires shared libraries to be built])
    HDF_JAVA="no"
    AC_MSG_RESULT([no])
  fi
else
  AC_MSG_RESULT([no])
fi

## -------------------------------------------------------------------------
## Build static libraries by default. Furthermore, fortran shared libraries
## are unsupported. Disallow a user from enabling both shared libraries and
## fortran.
#this test is overwritten in debian - we allow shared fortran libraries
#if test "X${enable_shared}" != "Xyes"; then
#    enable_shared="no"
#fi
#
#if test "X${enable_shared}" = "Xyes"; then
#    if test "X${BUILD_FORTRAN}" = "Xyes"; then
#        AC_MSG_ERROR([Cannot build shared fortran libraries. Please configure with --disable-fortran flag.])
#    fi
#fi

AC_PROG_INSTALL
AC_PROG_LN_S

AC_CHECK_PROGS([AR], [ar xar], [:], [$PATH])

AC_CHECK_PROGS([YACC], ['bison -y' byacc yacc], [none], [])

if test "$YACC" = "none"; then
  AC_MSG_ERROR([cannot find yacc utility])
fi

AC_CHECK_PROGS([LEX], [flex lex], [none], [])

if test "$LEX" = "none"; then
  AC_MSG_ERROR([cannot find lex utility])
fi

AC_CHECK_PROG([DIFF],     [diff],     [diff -w])
AC_CHECK_PROG([MAKEINFO], [makeinfo], [makeinfo])
AC_CHECK_PROG([NEQN],     [neqn],     [neqn])
AC_CHECK_PROG([TBL],      [tbl],      [tbl])

AC_SUBST([AR])
AC_SUBST([DIFF])
AC_SUBST([STATIC_SHARED])
AC_SUBST([SHARED_EXTENSION])
AC_SUBST([enable_shared])
AC_SUBST([enable_static])
AC_SUBST([UNAME_INFO]) UNAME_INFO=`uname -a`
AC_SUBST([STATIC_EXEC]) STATIC_EXEC=no
AC_SUBST([LT_STATIC_EXEC])

## ======================================================================
## Libtool initialization
## ======================================================================
LT_INIT([dlopen disable-shared])
LT_OUTPUT

## ----------------------------------------------------------------------
## Check if we should install only statically linked executables.
##   This check needs to occur after libtool is initialized because
##   we check a libtool cache value and may issue a warning based
##   on its result.
AC_MSG_CHECKING([if we should install only statically linked executables])
AC_ARG_ENABLE([static_exec],
              [AS_HELP_STRING([--enable-static-exec],
                              [Install only statically linked executables
                               [default=no]])],
              [STATIC_EXEC=$enableval])

if test "X$STATIC_EXEC" = "Xyes"; then
  echo "yes"
  ## Issue a warning if -static flag is not supported.
  if test "X$lt_cv_prog_compiler_static_works" = "Xno"; then
      echo "    warning: -static flag not supported on this system; executable won't statically link shared system libraries."
  fi
  LT_STATIC_EXEC="-all-static"
else
  echo "no"
  LT_STATIC_EXEC=""
fi

AC_SUBST([LT_STATIC_EXEC])

## ======================================================================
## Checks for libraries
## ======================================================================

## ----------------------------------------------------------------------
## Fake --with-xxx option to allow us to create a help message for the
## following --with-xxx options which can take either a =DIR or =INC,LIB
## specifier.
##
AC_ARG_WITH([fnord],
  [
 For the following --with-xxx options, you can specify where the header
 files and libraries are in two different ways:

    --with-xxx=INC,LIB - Specify individually the include directory and
                         library directory separated by a comma
    --with-xxx=DIR     - Specify only the directory which contains the
                         include/ and lib/ subdirectories
  ])

## ----------------------------------------------------------------------
## Is the GNU zlib present? It has a header file `zlib.h' and a library
## `-lz' and their locations might be specified with the `--with-zlib'
## command-line switch. The value is an include path and/or a library path.
## If the library path is specified then it must be preceded by a comma.
AC_ARG_WITH([zlib],
            [AS_HELP_STRING([--with-zlib=DIR],
                            [Use zlib library [default=yes]])],,
            [withval=yes])

case "$withval" in
  yes)
    HAVE_ZLIB="yes"
    AC_CHECK_HEADERS([zlib.h], [HAVE_ZLIB_H="yes"], [unset HAVE_ZLIB])
    if test "x$HAVE_ZLIB" = "xyes" -a "x$HAVE_ZLIB_H" = "xyes"; then
      AC_CHECK_LIB([z], [compress2],, [unset HAVE_ZLIB])
    fi
    if test -z "$HAVE_ZLIB"; then
      if test -n "$HDF4_CONFIG_ABORT"; then
        AC_MSG_ERROR([couldn't find zlib library])
      fi
    else
      AC_CHECK_FUNC([compress2], [HAVE_COMPRESS2="yes"])
    fi
    ;;
  no)
    HAVE_ZLIB="no"
    AC_MSG_ERROR([zlib library required to build HDF4])
    ;;
  *)
    HAVE_ZLIB="yes"
    case "$withval" in
      *,*)
        zlib_inc="`echo $withval | cut -f1 -d,`"
        zlib_lib="`echo $withval | cut -f2 -d, -s`"
        ;;
      *)
        if test -n "$withval"; then
          zlib_inc="$withval/include"
          zlib_lib="$withval/lib"
        fi
        ;;
    esac

    ## Trying to include -I/usr/include and -L/usr/lib is redundant and
    ## can mess some compilers up.
    if test "X$zlib_inc" = "X/usr/include"; then
      zlib_inc=""
    fi
    if test "X$zlib_lib" = "X/usr/lib"; then
      zlib_lib=""
    fi

    if test -n "$zlib_inc"; then
      CPPFLAGS="$CPPFLAGS -I$zlib_inc"
    fi

    AC_CHECK_HEADERS([zlib.h], [HAVE_ZLIB_H="yes"], [unset HAVE_ZLIB])

    if test -n "$zlib_lib"; then
      LDFLAGS="$LDFLAGS -L$zlib_lib"
    fi

    if test "x$HAVE_ZLIB" = "xyes" -a "x$HAVE_ZLIB_H" = "xyes"; then
      AC_CHECK_LIB([z], [compress2],, [unset HAVE_ZLIB])
    fi

    if test -z "$HAVE_ZLIB"; then
      AC_MSG_ERROR([couldn't find zlib library])
    else
      AC_CHECK_FUNC([compress2], [HAVE_COMPRESS2="yes"])
    fi
    ;;
esac

## ----------------------------------------------------------------------
## Is the JPEG library present?
AC_ARG_WITH([jpeg],
            [AS_HELP_STRING([--with-jpeg=DIR],
                            [Use jpeg library [default=yes]])],,
            [withval=yes])

case "$withval" in
  yes)
    HAVE_JPEG="yes"
    AC_CHECK_HEADERS([jpeglib.h], [HAVE_JPEG_H="yes"], [unset HAVE_JPEG])
    if test "x$HAVE_JPEG" = "xyes" -a "x$HAVE_JPEG_H" = "xyes"; then
      AC_CHECK_LIB([jpeg], [jpeg_start_decompress],, [unset HAVE_JPEG])
    fi

    if test -z "$HAVE_JPEG"; then
      AC_MSG_ERROR([couldn't find jpeg library])
    fi
    ;;
  no)
    HAVE_JPEG="no"
    AC_MSG_ERROR([jpeg library required to build HDF4])
    ;;
  *)
    HAVE_JPEG="yes"
    case "$withval" in
      *,*)
        jpeg_inc="`echo $withval | cut -f1 -d,`"
        jpeg_lib="`echo $withval | cut -f2 -d, -s`"
        ;;
      *)
        if test -n "$withval"; then
          jpeg_inc="$withval/include"
          jpeg_lib="$withval/lib"
        fi
        ;;
    esac

    ## Trying to include -I/usr/include and -L/usr/lib is redundant and
    ## can mess some compilers up.
    if test "X$jpeg_inc" = "X/usr/include"; then
      jpeg_inc=""
    fi
    if test "X$jpeg_lib" = "X/usr/lib"; then
      jpeg_lib=""
    fi

    if test -n "$jpeg_inc"; then
      CPPFLAGS="$CPPFLAGS -I$jpeg_inc"
    fi

    AC_CHECK_HEADERS([jpeglib.h], [HAVE_JPEG_H="yes"], [unset HAVE_JPEG])

    if test -n "$jpeg_lib"; then
      LDFLAGS="$LDFLAGS -L$jpeg_lib"
    fi

    if test "x$HAVE_JPEG" = "xyes" -a "x$HAVE_JPEG_H" = "xyes"; then
      AC_CHECK_LIB([jpeg], [jpeg_start_decompress],, [unset HAVE_JPEG])
    fi

    if test -z "$HAVE_JPEG"; then
      AC_MSG_ERROR([couldn't find jpeg library])
    fi
    ;;
esac

## ----------------------------------------------------------------------
## Is the szip library present?
AC_SUBST(USE_COMP_SZIP) USE_COMP_SZIP="no"
AC_SUBST(SZIP_HAS_ENCODER) SZIP_HAS_ENCODER="no"
AC_ARG_WITH([szlib],
            [AS_HELP_STRING([--with-szlib=DIR],
                            [Use szlib library [default=no]])],,
            [withval=no])

case "$withval" in
  yes)
    HAVE_SZIP="yes"
    AC_CHECK_HEADERS([szlib.h], [HAVE_SZLIB_H="yes"], [unset HAVE_SZIP])
    if test "x$HAVE_SZLIB" = "xyes" -a "x$HAVE_SZLIB_H" = "xyes"; then
      AC_CHECK_LIB([sz], [SZ_BufftoBuffCompress],, [unset HAVE_SZIP])
    fi

    if test -z "$HAVE_SZIP"; then
      AC_MSG_ERROR([couldn't find szlib library])
    fi
    ;;
  no)
    HAVE_SZIP="no"
    AC_MSG_CHECKING([for szlib])
    AC_MSG_RESULT([suppressed])
    SZIP_INFO="${SZIP_INFO}disabled"
    ;;
  *)
    HAVE_SZIP="yes"
    case "$withval" in
      *,*)
        szip_inc="`echo $withval | cut -f1 -d,`"
        szip_lib="`echo $withval | cut -f2 -d, -s`"
        ;;
      *)
        if test -n "$withval"; then
          szip_inc="$withval/include"
          szip_lib="$withval/lib"
        fi
        ;;
    esac

    ## Trying to include -I/usr/include and -L/usr/lib is redundant and
    ## can mess some compilers up.
    if test "X$szip_inc" = "X/usr/include"; then
      szip_inc=""
    fi
    if test "X$szip_lib" = "X/usr/lib"; then
      szip_lib=""
    fi

    if test -n "$szip_inc"; then
      CPPFLAGS="$CPPFLAGS -I$szip_inc"
    fi

    AC_CHECK_HEADERS([szlib.h], [HAVE_SZLIB_H="yes"], [unset HAVE_SZIP])

    if test -n "$szip_lib"; then
      LDFLAGS="$LDFLAGS -L$szip_lib"
    fi

    if test "x$HAVE_SZIP" = "xyes" -a "x$HAVE_SZLIB_H" = "xyes"; then
      AC_CHECK_LIB([sz], [SZ_BufftoBuffCompress],, [unset HAVE_SZIP])
    fi

    if test -z "$HAVE_SZIP"; then
      AC_MSG_ERROR([couldn't find szlib library])
    else
      USE_COMP_SZIP="yes"
    fi
    ;;
esac

## Check to see if SZIP has encoder
if test "X$HAVE_SZIP" = "Xyes" -a "x$HAVE_SZLIB_H" = "xyes"; then
    ## SZLIB library is available. Check if it can encode.
    AC_MSG_CHECKING([for szlib encoder])

    ## Set LD_LIBRARY_PATH so encoder test can find the library and run.
    if test -z "$LD_LIBRARY_PATH"; then
        export LD_LIBRARY_PATH="$szip_lib"
    else
        export LD_LIBRARY_PATH="${szip_lib}:$LD_LIBRARY_PATH"
    fi

    AC_SUBST([LL_PATH]) LL_PATH="$LD_LIBRARY_PATH"

    AC_TRY_RUN([
    #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);
    }
    ], [CAN_ENCODE="yes"], [CAN_ENCODE="no"],)

    ## Report szip encoder test results
    if test "X$CAN_ENCODE" = "Xyes"; then
        AC_MSG_RESULT([yes])
    fi
    if test "X$CAN_ENCODE" = "Xno"; then
        AC_MSG_RESULT([no])
    fi

    ## Add "szip" to external filter list
    if test "X$CAN_ENCODE" = "Xyes"; then
        if test "X$SZIP_INFO" != "X"; then
            SZIP_INFO="${SZIP_INFO}"
        fi
        SZIP_INFO="${SZIP_INFO}enabled with encoder"
    fi

    if test "X$CAN_ENCODE" = "Xno"; then
        if test "X$SZIP_INFO" != "X"; then
            SZIP_INFO="${SZIP_INFO}"
        fi
        SZIP_INFO="${SZIP_INFO}enabled with decoder only"
    fi

    ## Create macro to specify if encoder is present
    if test "X$CAN_ENCODE" = "Xyes"; then
        AC_DEFINE([HAVE_SZIP_ENCODER], [1],
                [Define if szip has encoder])
        SZIP_HAS_ENCODER="yes"
    fi
fi
AC_SUBST([SZIP_INFO])
AC_SUBST([SZIP_HAS_ENCODER])

AM_CONDITIONAL([BUILD_SHARED_SZIP_CONDITIONAL], [test "X$USE_COMP_SZIP" = "Xyes" && test "X$LL_PATH" != "X"])

## ----------------------------------------------------------------------
## Is XDR support present? The TRY_LINK info was gotten from the
## mfhdf/libsrc/local_nc.c file.
AC_MSG_CHECKING([for xdr library support])

AC_ARG_ENABLE([hdf4-xdr],
              [AS_HELP_STRING([--enable-hdf4-xdr],
                              [Build xdr library from code in HDF4 source.
                               Not supported for 64 bit mode. [default="no"]])],
              [enableval="yes"],[enableval="no"])

case "$enableval" in
  yes)
    BUILD_XDR="yes"
    AC_MSG_RESULT([using HDF4 XDR]);
    ;;
  no)
    BUILD_XDR="no"
    ;;
esac

## For Solaris systems, add the -nsl for XDR support
##
## The SunRPC of the glibc has been replaced by a TI-RPC (Transport Independent RPC) library for IPv6 support
case "$host" in
  *-solaris*)
    LIBS="$LIBS -lnsl"  ;;
  *-pc-cygwin*)
    LIBS="$LIBS -ltirpc"
    CPPFLAGS="$CPPFLAGS -I/usr/include/tirpc"  ;;
  *) ;;
esac

if test "X$BUILD_XDR" != "Xyes"; then
    AC_TRY_LINK([
    #include <rpc/types.h>
    #include <rpc/xdr.h>], [xdr_int],
                [AC_MSG_RESULT([yes]); BUILD_XDR="no"],
                [AC_MSG_RESULT([no]); BUILD_XDR="yes"])
fi

AM_CONDITIONAL([HDF_BUILD_XDR], [test "X$BUILD_XDR" = "Xyes"])


## Check headers and add libraries for XDR if the HDF4 XDR library is not used.
if test "X$BUILD_XDR" != "Xyes"; then

  ## ======================================================================
  ## Checks for header files
  ## ======================================================================

  ## ----------------------------------------------------------------------
  ## We're trying to link against the rpc library when building on Cygwin,
  ## but we need to make sure that it is present on the system. Do that here,
  ## The SunRPC of the glibc has been replaced by a TI-RPC (Transport Independent RPC) library for IPv6 support
  case "$host" in
    *-pc-cygwin*)
      HAVE_RPC="yes"
      AC_CHECK_HEADER([rpc.h],[:], [unset HAVE_RPC])
      AC_CHECK_LIB([tirpc], [xdr_opaque],[:], [unset HAVE_RPC])
      if test -z "$HAVE_RPC"; then
        AC_MSG_ERROR([couldn't find tirpc library])
      fi
      ;;
  esac
fi

AC_HEADER_STDC

## ======================================================================
## Checks for types
## ======================================================================

## ======================================================================
## Checks for structures
## ======================================================================

## ======================================================================
## Checks for compiler characteristics
## ======================================================================

AC_PROG_CC_C_O
AC_PROG_CXXCPP

if test "X$BUILD_FORTRAN" = "Xyes"; then
  AC_PROG_F77_C_O
fi

## This is a bit of a hack. The AC_CHECK_SIZEOF macro is supposed to
## #define a value in a header file. However, we don't use a generated
## header file. So I check the value left over from autoconf's test  is
## >= 8.
AC_CHECK_SIZEOF([int*])

if test $ac_cv_sizeof_intp -ge 8; then
  CPPFLAGS="$CPPFLAGS -DBIG_LONGS"

  ## Define super secret special flag for AIX machines in 64-bit mode.
  case "${host}" in
    *-ibm-aix*) CPPFLAGS="$CPPFLAGS -DAIX5L64" ;;
    *)          ;;
  esac
  if test "X$BUILD_XDR" = "Xyes"; then
    AC_MSG_ERROR([--enable-hdf4-xdr is not supported for 64 bit mode.])
  fi
fi

## ----------------------------------------------------------------------
## Set some variables for general configuration information to be saved
## and installed with the libraries.
##

## HDF4 version from the first line of the README.txt file.
H4_VERSION="`cut -d' ' -f3 $srcdir/README.txt | head -1`"
AC_SUBST([H4_VERSION])

## Configuration date
AC_SUBST([CONFIG_DATE]) CONFIG_DATE="`date`"

## User doing the configuration
AC_SUBST([CONFIG_USER]) CONFIG_USER="`whoami`@`hostname`"

## Configuration mode (production, development, etc)
AC_SUBST([CONFIG_MODE])

AC_C_BIGENDIAN([], [CPPFLAGS="$CPPFLAGS -DSWAP"])

## Are we building this in debug or production mode? (Remove the -g flag
## in production mode.)
AC_MSG_CHECKING([for build mode])
AC_ARG_ENABLE([production],
              [AS_HELP_STRING([--enable-production],
                              [Determines how to run the compiler.])])

case "X-$enable_production" in
  X-|X-yes)
    AC_MSG_RESULT([production])
    CONFIG_MODE=production
    ## Remove the "-g" flag from compile line if it's in there.
    CFLAGS_temp=""
    if test -n "$CFLAGS"; then
      for d in $CFLAGS ; do
        if test "X$d" != "X-g"; then
          CFLAGS_temp="$CFLAGS_temp $d"
        fi
      done
      CFLAGS=$CFLAGS_temp
    fi

    FFLAGS_temp=""
    if test -n "$FFLAGS"; then
      for d in $FFLAGS ; do
        if test "X$d" != "X-g"; then
          FFLAGS_temp="$FFLAGS_temp $d"
        fi
      done
      FFLAGS=$FFLAGS_temp
    fi

    CXXFLAGS_temp=""
    if test -n "$CXXFLAGS"; then
      for d in $CXXFLAGS ; do
        if test "X$d" != "X-g"; then
          CXXFLAGS_temp="$CXXFLAGS_temp $d"
        fi
      done
      CXXFLAGS=$CXXFLAGS_temp
    fi

    CFLAGS="$CFLAGS $PROD_CFLAGS"
    CXXFLAGS="$CXXFLAGS $PROD_CXXFLAGS"
    FFLAGS="$FFLAGS $PROD_FFLAGS"
    CPPFLAGS="$CPPFLAGS $PROD_CPPFLAGS"
    ;;
  X-no)
    AC_MSG_RESULT([development])
    CONFIG_MODE=development
    CFLAGS="$CFLAGS $DEBUG_CFLAGS"
    FFLAGS="$FFLAGS $DEBUG_FFLAGS"
    CXXFLAGS="$CXXFLAGS $DEBUG_CXXFLAGS"
    CPPFLAGS="$CPPFLAGS $DEBUG_CPPFLAGS"
    ;;
  *)
    AC_MSG_RESULT([user-defined])
    ;;
esac

## ======================================================================
## Checks for library functions
## ======================================================================

AC_MSG_CHECKING([for math library support])
AC_TRY_LINK([#include <math.h>], [sinh(37.927)],
            [AC_MSG_RESULT([yes])],
            [AC_MSG_RESULT([no]); LIBS="$LIBS -lm"])

AC_CHECK_FUNCS([fork system vfork wait])


## ======================================================================
## Checks for system services
## ======================================================================

## Copy NetCDF header files.
#
## FIXME: This is code stolen^Wborrowed from the old HDF4 configure.
## These header files should probably be generated by autoconf instead
## of being copied depending upon the host.
case "$host" in
  *-linux*|*-k*bsd*-gnu|*-gnu*)BAR="linux"       ;;
  *-freebsd*)           BAR="fbsd"        ;;
  *-ibm-aix*)           BAR="aix"         ;;
  sparc64-*-solaris2*)  BAR="solaris64"   ;;
  *-*-solaris2*)        BAR="solaris"     ;;
  *-apple*)             BAR="apple"       ;;
  *-pc-cygwin*)         BAR="linux"       ;;
  *)                    echo "*** unknown host $host!"; exit 1 ;;
esac
src_files=""
src_files="`echo $src_files | sed -e s/FOO/${BAR}/g`"

for config_file in $src_files; do
  src_file="${srcdir}/`echo $config_file | sed -e s/:.*$//`"
  target_file="`echo $config_file | sed -e s/^[[^:]]*://g`"

  if test ! -r ${src_file}; then
    echo '***' "${progname}: cannot copy file \"${target_file}\"," 1>&2
    echo '***' "since the file \"${src_file}\" does not exist." 1>&2
    exit 1
  fi

  ## this sed command emulates the dirname command
  dstdir=`echo "$target_file" | sed -e 's,[[^/]]*$,,;s,/$,,;s,^$,.,'`

  ## Create directory for the target_file if it's not there.
  if test ! -d $dstdir; then
    ${srcdir}/bin/mkinstalldirs $dstdir
  fi

  echo "Copying \"${src_file}\" to \"${target_file}\" ."
  cp ${src_file} ${target_file}

  if test ! -r ${target_file}; then
    echo '***' "${progname}: cannot copy file \"${target_file}\"," 1>&2
    exit 1
  fi
done

## ------------------------------------------------------------------------
## Check to see if libtool has enabled shared libraries. Set a conditional
## as some Makefiles will build based on availability of shared libraries.
if (./libtool --features | grep '^enable shared libraries' > /dev/null); then
  enable_shared=yes
else
  enable_shared=no
fi

## ------------------------------------------------------------------------
## Specify shared library extension the host machine should recognize.
case "$host_os" in
  darwin*)
      SHARED_EXTENSION="dylib"
      ;;
  *)
      SHARED_EXTENSION="so"
      ;;
esac

## We don't need to say when we're entering directories if we're using
## GNU make because make does it for us.
if test "X$GMAKE" = "Xyes"; then
  AC_SUBST([SETX]) SETX=":"
else
  AC_SUBST([SETX]) SETX="set -x"
fi

AM_CONDITIONAL([HDF_BUILD_SHARED], [test "X$enable_shared" = "Xyes"])

## Compiler with version information. This consists of the full path
## name of the compiler and the reported version number.
AC_SUBST([CC_VERSION])
## Strip anything that looks like a flag off of $CC
CC_NOFLAGS=`echo $CC | sed 's/ -.*//'`

if `echo $CC_NOFLAGS | grep ^/ >/dev/null 2>&1`; then
  CC_VERSION="$CC"
else
  CC_VERSION="$CC";
  for x in `echo $PATH | sed -e 's/:/ /g'`; do
    if test -x $x/$CC_NOFLAGS; then
      CC_VERSION="$x/$CC"
      break
    fi
  done
fi


## ----------------------------------------------------------------------
##
## If --enable-static-exec and are specified together, there will be ld failures for
## "attempted static link of dynamic object" when the tools are built.  This check
## will prevent that error during configure instead.  It could go with the other
## --enable-static-exec checks, but since enable_static is set by default later in
## the configure process this check has to be delayed.
if test "X$STATIC_EXEC" = "Xyes"; then
  if test "X${enable_static}" != "Xyes"; then
    AC_MSG_ERROR([--enable-static-exec flag to build static executables requires static libraries.  Please configure with --enable-static flag.])
  fi
fi

## This part doesn't work yet since HDF4 config files do not contain
## information for cc_vendor and cc_version as HDF4 similar files do.
## Needs to be fixed EIP 2010-01-21
## if test -n "$cc_vendor" && test -n "$cc_version"; then
##  CC_VERSION="$CC_VERSION ($cc_vendor-$cc_version)"
## fi

if test -n "$cc_version_info"; then
  CC_VERSION="$CC_VERSION ( $cc_version_info)"
fi

## Fortran compiler with version information. This consists of the full path
## name of the compiler and the reported version number.
AC_SUBST([F77_VERSION])
## Strip anything that looks like a flag off of $F77
F77_NOFLAGS=`echo $F77 | sed 's/ -.*//'`

if `echo $F77_NOFLAGS | grep ^/ >/dev/null 2>&1`; then
  F77_VERSION="$F77"
else
  F77_VERSION="$F77";
  for x in `echo $PATH | sed -e 's/:/ /g'`; do
    if test -x $x/$F77_NOFLAGS; then
      F77_VERSION="$x/$F77"
      break
    fi
  done
fi
if test -n "$fc_version_info"; then
  F77_VERSION="$F77_VERSION ( $fc_version_info)"
fi

## This part doesn't work yet since HDF4 config files do not contain
## information for fortran_vendor and fortran_version.
## Needs to be fixed EIP 2010-01-21
## if test -n "$fortran_vendor" && test -n "$fortran_version"; then
##   F77_VERSION="$F77_VERSION ($fortran_vendor-$fortran_version)"
## fi

AC_SUBST([JAVA_VERSION])
## Strip anything that looks like a flag off of $JAVA
JAVA_NOFLAGS=`echo $JAVA | sed 's/ -.*//'`

if `echo $JAVA_NOFLAGS | grep ^/ >/dev/null 2>&1`; then
  JAVA_VERSION="$JAVA"
else
  JAVA_VERSION="$JAVA";
  for x in `echo $PATH | sed -e 's/:/ /g'`; do
    if test -x $x/$JAVA_NOFLAGS; then
      JAVA_VERSION="$x/$JAVA"
      break
    fi
  done
fi
java_version_info=`$JAVA -version 2>&1 |\
  grep 'version' | sed -e 's/version "//' | sed -e 's/"//'`
if test -n "$java_version_info"; then
  JAVA_VERSION="$JAVA_VERSION ($java_version_info)"
fi
AM_CONDITIONAL([BUILD_JAVA_CONDITIONAL], [test "X$HDF_JAVA" = "Xyes"])

## ----------------------------------------------------------------------
## Enable deprecated public API symbols
##
AC_SUBST([DEPRECATED_SYMBOLS])
AC_MSG_CHECKING([if deprecated public symbols are available]);
AC_ARG_ENABLE([deprecated-symbols],
              [AS_HELP_STRING([--enable-deprecated-symbols],
                     [Enable deprecated public API symbols [default=yes]])],
             [DEPREC_SYMBOLS=$enableval],
             [DEPREC_SYMBOLS=yes])

case "X-$DEPREC_SYMBOLS" in
  X-yes)
    AC_MSG_RESULT([yes])
    DEPRECATED_SYMBOLS=yes
    ;;
  X-no|*)
    AC_MSG_RESULT([no])
    DEPRECATED_SYMBOLS=no
    AC_DEFINE([NO_DEPRECATED_SYMBOLS], [1],
              [Define if deprecated public API symbols are disabled])
    ;;
esac

AC_CONFIG_FILES([Makefile
                 libhdf4.settings
                 hdf/Makefile
                 hdf/examples/Makefile
                 hdf/fortran/Makefile
                 hdf/fortran/examples/Makefile
                 hdf/src/Makefile
                 hdf/test/Makefile
                 hdf/util/Makefile
                 hdf/util/h4cc
                 hdf/util/h4fc
                 hdf/util/h4redeploy
                 hdf/util/testutil.sh
                 man/Makefile
        mfhdf/fortran/ftest.f
        mfhdf/fortran/jackets.c
        mfhdf/fortran/netcdf.inc
        mfhdf/libsrc/netcdf.h
                 mfhdf/Makefile
                 mfhdf/dumper/Makefile
                 mfhdf/dumper/testhdp.sh
                 mfhdf/examples/Makefile
                 mfhdf/examples/testexamples.sh
                 mfhdf/fortran/Makefile
                 mfhdf/fortran/examples/Makefile
                 mfhdf/fortran/testfortran.sh
                 mfhdf/hdfimport/Makefile
                 mfhdf/hdfimport/testutil.sh
                 mfhdf/hdiff/Makefile
                 mfhdf/hdiff/testhdiff.sh
                 mfhdf/hrepack/Makefile
                 mfhdf/hrepack/hrepack.sh
                 mfhdf/hrepack/hrepack_all.sh
                 mfhdf/libsrc/Makefile
                 mfhdf/ncdump/Makefile
                 mfhdf/ncdump/testncdump.sh
                 mfhdf/ncgen/Makefile
                 mfhdf/ncgen/testncgen.sh
                 mfhdf/nctest/Makefile
                 mfhdf/test/Makefile
                 mfhdf/test/testmfhdf.sh
                 mfhdf/xdr/Makefile
                 java/Makefile
                 java/src/Makefile
                 java/src/jni/Makefile
                 java/test/Makefile
                 java/test/junit.sh
                 java/examples/Makefile])

AC_CONFIG_COMMANDS([.classes], [], [$MKDIR_P java/src/.classes;
                $MKDIR_P java/test/.classes;
                $MKDIR_P java/examples/.classes])

AC_OUTPUT

## A temporary patch. These code were after where it did
## cp config/netcdf-XXX.h netcdf.h before.
## Moved it here after AC_CONFIG_FILES(... mfhdf/libsrc/netcdf.h ).
## Need a better and correct solution.
##
if test "X$BUILD_NETCDF" != "Xyes"; then
    echo "Renaming \"mfhdf/libsrc/netcdf.h\" to \"mfhdf/libsrc/hdf4_netcdf.h\" ."
    mv mfhdf/libsrc/netcdf.h mfhdf/libsrc/hdf4_netcdf.h
fi

chmod 755 hdf/util/h4cc hdf/util/h4redeploy

if test "X$BUILD_FORTRAN" = "Xyes"; then
  chmod 755 hdf/util/h4fc
fi

## show the configure settings
cat libhdf4.settings