forked from HDFGroup/hdf5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
4615 lines (4051 loc) · 163 KB
/
configure.ac
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
## Process this file with autoconf to produce configure.
##
## Copyright by The HDF Group.
## All rights reserved.
##
## This file is part of HDF5. The full HDF5 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://www.hdfgroup.org/licenses.
## If you do not have access to either file, you may request a copy from
## help@hdfgroup.org.
## ----------------------------------------------------------------------
## Initialize configure.
##
AC_PREREQ([2.71])
## 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([HDF5], [1.15.0], [help@hdfgroup.org])
AC_CONFIG_SRCDIR([src/H5.c])
AC_CONFIG_HEADERS([src/H5config.h])
AC_CONFIG_AUX_DIR([bin])
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 subdir-objects])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) # use silent rules where available - automake 1.11
## AM_MAINTAINER_MODE determines the behavior of "rebuild rules" that contain
## dependencies for Makefile.in files, configure, src/H5config.h, etc. If
## AM_MAINTAINER_MODE is enabled, these files will be rebuilt if out of date.
## When disabled, the autotools build files can get out of sync and the build
## system will not complain or try to regenerate downstream files.
##
## The AM_MAINTAINER_MODE macro also determines whether the
## --(enable|disable)-maintainer-mode configure option is available. When the
## macro is present, with or without a parameter, the option will be added
## to the generated configure script.
##
## In summary:
##
## AM_MAINTAINER_MODE([enable])
## - Build dependencies ON by default
## - Configure option exists
##
## AM_MAINTAINER_MODE([disable])
## - Build dependencies OFF by default
## - Configure option exists
##
## AM_MAINTAINER_MODE
## - Build dependencies OFF by default
## - Configure option exists
##
## No AM_MAINTAINER_MODE macro
## - Build dependencies ON by default
## - No configure option to control build dependencies
##
## The biggest concern for us is that version control systems like git
## usually don't preserve dependencies between timestamps, so the build
## system will often think that upstream build files like Makefile.am are
## dirty and that rebuilding needs to occur when it doesn't. This is a problem
## in release branches where we provide the autotools-generated files. Users
## who don't have autoconf, automake, etc. will then have difficulty building
## release branches checked out from git.
##
## By default, maintainer mode is enabled in development branches and disabled
## in release branches.
AM_MAINTAINER_MODE([enable])
## ----------------------------------------------------------------------
## 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`/hdf5])
## Run post processing on files created by configure
##
## src/H5pubconf.h:
## Generate src/H5pubconf.h from src/H5config.h by prepending H5_ to all
## macro names. This avoid name conflict between HDF5 macro names and those
## generated by another software package that uses the HDF5 library.
##
## src/libhdf5.settings:
## Remove all lines beginning with "#" which are generated by CONDITIONAL's
## of configure.
##
## src/H5build_settings.c
## Remove all lines beginning with "#" which are generated by CONDITIONAL's
## of configure. This uses a check for whitespace after the pound sign
## to avoid clobbering include statements.
AC_CONFIG_COMMANDS([pubconf], [
echo "creating src/H5pubconf.h"
sed 's/#define /#define H5_/' <src/H5config.h |\
sed 's/#undef /#undef H5_/' >pubconf
if test ! -f src/H5pubconf.h; then
mv -f pubconf src/H5pubconf.h
elif (diff pubconf src/H5pubconf.h >/dev/null); then
rm -f pubconf
echo "src/H5pubconf.h is unchanged"
else
mv -f pubconf src/H5pubconf.h
fi
echo "Post process src/libhdf5.settings"
sed '/^#/d' < src/libhdf5.settings > libhdf5.settings.TMP
cp libhdf5.settings.TMP src/libhdf5.settings
rm -f libhdf5.settings.TMP
echo "Post process src/H5build_settings.c"
sed '/^# /d' < src/H5build_settings.c > H5build_settings.TMP
cp H5build_settings.TMP src/H5build_settings.c
rm -f H5build_settings.TMP
])
## It's possible to configure for a host other than the one on which
## configure is currently running by using the --host=foo flag.
## For machines on which HDF5 is often configured, it can be convenient
## to specify the name of the machine rather than its canonical type.
##
## There are currently no hosts, but if there were they would be
## listed by hostname and the alias would point to a file in
## the config directory:
##
##case $host_alias in
## <some host>)
## host_alias=<config file in config directory>
## ;;
##esac
AC_CANONICAL_HOST
AC_SUBST([CPPFLAGS])
AC_SUBST([JNIFLAGS])
AC_SUBST([AR_FLAGS])
## H5_CFLAGS (and company) are for CFLAGS that should be used on HDF5, but
## not exported to h5cc (or h5fc, etc.)
##
AC_SUBST([H5_CFLAGS])
AC_SUBST([H5_CPPFLAGS])
AC_SUBST([H5_FCFLAGS])
AC_SUBST([H5_CXXFLAGS])
AC_SUBST([H5_JNIFLAGS])
AC_SUBST([H5_JAVACFLAGS])
AC_SUBST([H5_JAVAFLAGS])
AC_SUBST([H5_LDFLAGS])
## AM_CFLAGS (and company) are for CFLAGS that should be used on HDF5,
## and WILL be exported to h5cc (or h5fc, etc) if set by configure.
AC_SUBST([AM_CFLAGS])
AC_SUBST([AM_FCFLAGS])
AC_SUBST([AM_CXXFLAGS])
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_JNIFLAGS])
AC_SUBST([AM_JAVACFLAGS])
AC_SUBST([AM_JAVAFLAGS])
AC_SUBST([AM_LDFLAGS])
## Make sure flags are initialized.
AM_CFLAGS="${AM_CFLAGS}"
AM_CXXFLAGS="${AM_CXXFLAGS}"
AM_FCFLAGS="${AM_FCFLAGS}"
AM_CPPFLAGS="${AM_CPPFLAGS}"
AM_JNIFLAGS="${AM_JNIFLAGS}"
AM_JAVACFLAGS="${AM_JAVACFLAGS}"
AM_JAVAFLAGS="${AM_JAVAFLAGS}"
AM_LDFLAGS="${AM_LDFLAGS}"
## Flags passed in by the user
CFLAGS="${CFLAGS}"
CXXFLAGS="${CXXFLAGS}"
FCFLAGS="${FCFLAGS}"
CPPFLAGS="${CPPFLAGS}"
JNIFLAGS="${JNIFLAGS}"
JAVACFLAGS="${JAVACFLAGS}"
JAVAFLAGS="${JAVAFLAGS}"
LDFLAGS="${LDFLAGS}"
AR_FLAGS="${AR_FLAGS}"
## Configure may need to alter any of the *FLAGS variables in order for
## various checks to work correctly. Save the user's value here so it
## can be restored once all configure checks are complete.
saved_user_CFLAGS="$CFLAGS"
saved_user_CXXFLAGS="$CXXFLAGS"
saved_user_FCFLAGS="$FCFLAGS"
saved_user_JAVACFLAGS="$JAVACFLAGS"
saved_user_JAVAFLAGS="$JAVAFLAGS"
saved_user_LDFLAGS="$LDFLAGS"
saved_user_CPPFLAGS="$CPPFLAGS"
## Strip out -Werror from CFLAGS since that can cause checks to fail when
## compiling test programs fails due to warnings
##
## Regex:
##
## -Werror Literal -Werror
## \( Start optional capturing group
## = Literal equals sign
## [^[:space:]] Non-space characters
## \+ 1 or more of the above
## \) End optional capturing group
## \? 0 or 1 capturing group matches
##
## Note that the outer pair of '[]' ends up getting removed
WERROR_SED='s/-Werror\(=[[^[:space:]]]\+\)\?//g'
CFLAGS_SED="`echo $CFLAGS | sed -e $WERROR_SED`"
if test $? -eq 0; then
CFLAGS="$CFLAGS_SED"
fi
CXXFLAGS_SED="`echo $CXXFLAGS | sed -e $WERROR_SED`"
if test $? -eq 0; then
CXXFLAGS="$CXXFLAGS_SED"
fi
FCFLAGS_SED="`echo $FCFLAGS | sed -e $WERROR_SED`"
if test $? -eq 0; then
FCFLAGS="$FCFLAGS_SED"
fi
JAVACFLAGS_SED="`echo $JAVACFLAGS | sed -e $WERROR_SED`"
if test $? -eq 0; then
JAVACFLAGS="$JAVACFLAGS_SED"
fi
CPPFLAGS_SED="`echo $CPPFLAGS | sed -e $WERROR_SED`"
if test $? -eq 0; then
CPPFLAGS="$CPPFLAGS_SED"
fi
## Support F9X variable to define Fortran compiler if FC variable is
## not used. This should be deprecated in the future.
if test "x" = "x$FC"; then
FC=${F9X}
fi
## ----------------------------------------------------------------------
## Dump all shell variables values.
##
AC_MSG_CHECKING([shell variables initial values])
set >&AS_MESSAGE_LOG_FD
AC_MSG_RESULT([done])
## ----------------------------------------------------------------------
## Save system information for the library settings file.
##
AC_SUBST([UNAME_INFO])
UNAME_INFO=`uname -a`
## ----------------------------------------------------------------------
## Some platforms have broken basename, and/or xargs programs. Check
## that it actually does what it's supposed to do. Catch this early
## since configure and scripts relies upon them heavily and there's
## no use continuing if it's broken.
##
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
## xargs basename used in configure to get the CC_BASENAME value
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
## ----------------------------------------------------------------------
## Check that the cache file was build on the same host as what we're
## running on now.
##
AC_CACHE_CHECK([for cached host], [hdf5_cv_host], [hdf5_cv_host="none"]);
if test $hdf5_cv_host = "none"; then
hdf5_cv_host=$host
elif test $hdf5_cv_host != $host; then
AC_MSG_ERROR([
The config.cache file was generated on $hdf5_cv_host but
this is $host. Please remove that file and try again.
config.cache file is invalid])
fi
## ----------------------------------------------------------------------
## Check if we should consider certain compiler warnings as errors
##
## We have to set WARNINGS_AS_ERRORS before sourcing a $host_config
## file, below.
##
## These should NOT be on by default as the risk of breakage is high
## when compiling HDF5 on new (or new versions) of platforms and
## compilers. It can also cause failures when header files we have no
## control over (e.g. MPI, HDFS) raise warnings.
##
AC_MSG_CHECKING([enable warnings as errors])
AC_ARG_ENABLE([warnings-as-errors],
[AS_HELP_STRING([--enable-warnings-as-errors],
[Determines whether certain warnings will be
considered errors. This is mainly for use
by HDF5 library developers.
[default=no]
])],
[WARNINGS_AS_ERRORS=$enableval])
## Set default
if test "X-$WARNINGS_AS_ERRORS" = X- ; then
WARNINGS_AS_ERRORS=no
fi
case "X-$WARNINGS_AS_ERRORS" in
X-yes|X-no)
AC_MSG_RESULT([$WARNINGS_AS_ERRORS])
;;
*)
AC_MSG_ERROR([Unrecognized value: $WARNINGS_AS_ERRORS])
;;
esac
## ----------------------------------------------------------------------
## 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
aix*)
host_os_novers=aix
;;
freebsd*)
host_os_novers=freebsd
;;
netbsd*)
host_os_novers=netbsd
;;
solaris*)
host_os_novers=solaris
;;
*)
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`"
. $host_config
fi
## Source any special site-specific file
hname="`hostname`"
while test -n "$hname"; do
file=$srcdir/config/site-specific/host-$hname
AC_MSG_CHECKING([for config $file])
if test -f "$file"; then
. $file
AC_MSG_RESULT([found])
break
fi
AC_MSG_RESULT([no])
hname_tmp=$hname
hname="`echo $hname | cut -d. -f2-99`"
test "$hname_tmp" = "$hname" && break
done
##
## Enable/disable sanitizer checks for clang compilers, initially address sanitizer
##
AC_MSG_CHECKING([for clang sanitizer checks])
AC_ARG_ENABLE([sanitize-checks],
[AS_HELP_STRING([--enable-sanitize-checks=address],
[(clang/clang++ compilers only) Enable sanitize checks.
Address is useful for detecting issues dealing with
memory. See AddressSanitizer in config/sanitizer/README.md
for more information.
[default=none]
])],
[CLANG_SANITIZE_CHECKS=$enableval])
# Set default
if test "X-$CLANG_SANITIZE_CHECKS" = X- ; then
CLANG_SANITIZE_CHECKS=none
fi
if test "X$CC_BASENAME" = "Xclang"; then
AC_SUBST([CLANG_SANITIZE_CHECKS])
# There are several sanitizer tools. At present we are testing
# and describing only -fsanitizer=address with autotools.
case "X-$CLANG_SANITIZE_CHECKS" in
X-no|X-none)
CLANG_SANITIZE_CHECKS=none
CLANG_SANITIZE_LIST=
;;
*)
CLANG_SANITIZE_LIST=$CLANG_SANITIZE_CHECKS
;;
esac
AC_MSG_RESULT([$CLANG_SANITIZE_CHECKS])
# Other tools can be added to the list of checks
# The clang compiler doesn't support some of them; they should be
# checked before adding them to the list in the help message.
# The sanitizers/sanitizers.cmake file lists these options:
# address, memory, memoryWithOrigins, undefined, thread, leak,
# 'address;undefined'. Which and which combinations of these are
# supported varies by compiler version, but unsupported options
# or combinations will result in configure errors reported in config.log.
# Comma separated lists of sanitize options will be entered intact in
# one -fsanitize=<list> flag. Space separated lists will be entered in
# separate -fsanitize=<item> flags.
# NOTE: No sanity checking done here!
if test -n "$CLANG_SANITIZE_LIST"; then
H5_CFLAGS="$H5_CFLAGS -fno-omit-frame-pointer"
H5_CXXFLAGS="$H5_CXXFLAGS -fno-omit-frame-pointer"
for sanitizer in `echo $CLANG_SANITIZE_LIST`; do
H5_CFLAGS="$H5_CFLAGS -fsanitize=${sanitizer}"
H5_CXXFLAGS="$H5_CXXFLAGS -fsanitize=${sanitizer}"
done
fi
fi
## ----------------------------------------------------------------------
## Determine build mode (debug, production, clean).
## This has to be done early since the build mode is referred to
## frequently.
##
AC_MSG_CHECKING([build mode])
AC_ARG_ENABLE([build-mode],
[AS_HELP_STRING([--enable-build-mode=(debug|production|clean)],
[Sets the build mode. Debug turns on symbols, API
tracing, asserts, and debug optimization,
as well as several other minor configure options
that aid in debugging.
Production turns high optimizations on.
Clean turns nothing on and disables optimization
(i.e.: a 'clean slate' configuration).
All these settings can be overridden by using
specific configure flags.
[default=debug]
])],
[BUILD_MODE=$enableval])
## Set the default
## Depends on branch, set via script at branch creation time
if test "X-$BUILD_MODE" = X- ; then
BUILD_MODE=debug
fi
## Allow this variable to be substituted in
## other files (src/libhdf5.settings.in, etc.)
AC_SUBST([BUILD_MODE])
case "X-$BUILD_MODE" in
X-clean)
AC_MSG_RESULT([clean])
;;
X-debug)
AC_DEFINE([DEBUG_BUILD], [1], [Define if this is a debug build.])
H5_CFLAGS="$H5_CFLAGS $DEBUG_CFLAGS"
H5_CPPFLAGS="$H5_CPPFLAGS $DEBUG_CPPFLAGS"
H5_CXXFLAGS="$H5_CXXFLAGS $DEBUG_CXXFLAGS"
H5_FCFLAGS="$H5_FCFLAGS $DEBUG_FCFLAGS"
AC_MSG_RESULT([debug])
;;
X-production)
H5_CFLAGS="$H5_CFLAGS $PROD_CFLAGS"
H5_CPPFLAGS="$H5_CPPFLAGS $PROD_CPPFLAGS"
H5_CXXFLAGS="$H5_CXXFLAGS $PROD_CXXFLAGS"
H5_FCFLAGS="$H5_FCFLAGS $PROD_FCFLAGS"
AC_MSG_RESULT([production])
;;
*)
AC_MSG_ERROR([Unrecognized build mode: $BUILD_MODE. Use debug, production, or clean.])
esac
## ----------------------------------------------------------------------
## Some built-in configure checks can only see CFLAGS (not AM_CFLAGS), so
## we need to add this in so configure works as intended. We will need to
## reset this value at the end of configure, to preserve the user's settings.
CFLAGS="${AM_CFLAGS} ${CFLAGS}"
FCFLAGS="${AM_FCFLAGS} ${FCFLAGS}"
JAVACFLAGS="${AM_JAVACFLAGS} ${JAVACFLAGS}"
JAVAFLAGS="${AM_JAVAFLAGS} ${JAVAFLAGS}"
CXXFLAGS="${AM_CXXFLAGS} ${CXXFLAGS}"
CPPFLAGS="${AM_CPPFLAGS} ${CPPFLAGS}"
LDFLAGS="${AM_LDFLAGS} ${LDFLAGS}"
## ----------------------------------------------------------------------
## Enable dependency tracking unless the configure options or a
## site-specific file told us not to. This prevents configure from
## silently disabling dependencies for some compilers.
##
if test -z "${enable_dependency_tracking}"; then
enable_dependency_tracking="yes"
fi
## ----------------------------------------------------------------------
## Check for programs.
##
AC_PROG_CC
CC_BASENAME="`echo $CC | cut -f1 -d' ' | xargs basename 2>/dev/null`"
## ----------------------------------------------------------------------------
## Configure disallows unsupported combinations of options. However, users
## may want to override and build with unsupported combinations for their
## own use. They can use the --enable-unsupported configure flag, which
## ignores any errors from configure due to incompatible flags.
AC_MSG_CHECKING([if unsupported combinations of configure options are allowed])
AC_ARG_ENABLE([unsupported],
[AS_HELP_STRING([--enable-unsupported],
[Allow unsupported combinations of configure options])],
[ALLOW_UNSUPPORTED=$enableval])
case "X-$ALLOW_UNSUPPORTED" in
X-|X-no)
AC_MSG_RESULT([no])
;;
X-yes)
AC_MSG_RESULT([yes])
;;
*)
;;
esac
## ----------------------------------------------------------------------
## Data types and their sizes.
##
AC_TYPE_OFF_T
AC_CHECK_TYPE([ssize_t], [],
[AC_DEFINE_UNQUOTED([ssize_t], [long],
[Define to `long' if <sys/types.h> does not define.])])
AC_C_BIGENDIAN
AC_CHECK_SIZEOF([char])
AC_CHECK_SIZEOF([short])
AC_CHECK_SIZEOF([int])
AC_CHECK_SIZEOF([unsigned])
AC_CHECK_SIZEOF([long])
AC_CHECK_SIZEOF([long long])
AC_CHECK_SIZEOF([float])
AC_CHECK_SIZEOF([double])
AC_CHECK_SIZEOF([long double])
#-----------------------------------------------------------------------------
# Option for enabling/disabling support for non-standard features, datatypes,
# etc. These features should still be checked for at configure time, but these
# options allow disabling of support for these features when compiler support
# is incomplete or broken. In this case, configure time checks may not be
# enough to properly enable/disable a feature and can cause library build
# problems.
#-----------------------------------------------------------------------------
AC_MSG_CHECKING([if non-standard feature support is enabled])
AC_ARG_ENABLE([nonstandard-features],
[AS_HELP_STRING([--enable-nonstandard-features],
[Enable support for non-standard programming language features [default=yes]])],
[NONSTANDARD_FEATURES=$enableval])
## Set default
if test "X-$NONSTANDARD_FEATURES" = X- ; then
NONSTANDARD_FEATURES=yes
fi
case "X-$NONSTANDARD_FEATURES" in
X-yes|X-no)
AC_MSG_RESULT([$NONSTANDARD_FEATURES])
;;
*)
AC_MSG_ERROR([Unrecognized value: $NONSTANDARD_FEATURES])
;;
esac
## ----------------------------------------------------------------------
## Check if _Float16 support is available
##
AC_MSG_CHECKING([if _Float16 support is enabled])
AC_ARG_ENABLE([nonstandard-feature-float16],
[AS_HELP_STRING([--enable-nonstandard-feature-float16],
[Enable support for _Float16 C datatype [default=yes]])],
[ENABLE_FLOAT16=$enableval])
## Set default
if test "X-$ENABLE_FLOAT16" = X- ; then
ENABLE_FLOAT16=$NONSTANDARD_FEATURES
fi
case "X-$ENABLE_FLOAT16" in
X-yes|X-no)
AC_MSG_RESULT([$ENABLE_FLOAT16])
;;
*)
AC_MSG_ERROR([Unrecognized value: $ENABLE_FLOAT16])
;;
esac
HAVE__FLOAT16="no"
if test "X$ENABLE_FLOAT16" = "Xyes"; then
AC_MSG_NOTICE([checking if _Float16 support is available])
AC_CHECK_SIZEOF([_Float16])
if test "$ac_cv_sizeof__Float16" != 0; then
# Some compilers expose the _Float16 datatype, but not the macros and
# functions used with the datatype. We need the macros for proper
# datatype conversion support. Check for these here.
AC_CHECK_DECL([FLT16_EPSILON], [], [], [[
#define __STDC_WANT_IEC_60559_TYPES_EXT__
#include <float.h>]])
AC_CHECK_DECL([FLT16_MIN], [], [], [[
#define __STDC_WANT_IEC_60559_TYPES_EXT__
#include <float.h>]])
AC_CHECK_DECL([FLT16_MAX], [], [], [[
#define __STDC_WANT_IEC_60559_TYPES_EXT__
#include <float.h>]])
AC_CHECK_DECL([FLT16_MIN_10_EXP], [], [], [[
#define __STDC_WANT_IEC_60559_TYPES_EXT__
#include <float.h>]])
AC_CHECK_DECL([FLT16_MAX_10_EXP], [], [], [[
#define __STDC_WANT_IEC_60559_TYPES_EXT__
#include <float.h>]])
AC_CHECK_DECL([FLT16_MANT_DIG], [], [], [[
#define __STDC_WANT_IEC_60559_TYPES_EXT__
#include <float.h>]])
if test "X$ac_cv_have_decl_FLT16_EPSILON" = "Xyes" &&
test "X$ac_cv_have_decl_FLT16_MIN" = "Xyes" &&
test "X$ac_cv_have_decl_FLT16_MAX" = "Xyes" &&
test "X$ac_cv_have_decl_FLT16_MIN_10_EXP" = "Xyes" &&
test "X$ac_cv_have_decl_FLT16_MAX_10_EXP" = "Xyes" &&
test "X$ac_cv_have_decl_FLT16_MANT_DIG" = "Xyes" ; then
# Some compilers like OneAPI on Windows appear to detect _Float16 support
# properly up to this point, and, in the absence of any architecture-specific
# tuning compiler flags, will generate code for H5Tconv.c that performs
# software conversions on _Float16 variables with compiler-internal functions
# such as __extendhfsf2, __truncsfhf2, or __truncdfhf2. However, these
# compilers will fail to link these functions into the build for currently
# unknown reasons and cause the build to fail. Since these are compiler-internal
# functions that we don't appear to have much control over, let's try to
# compile a program that will generate these functions to check for _Float16
# support. If we fail to compile this program, we will simply disable
# _Float16 support for the time being.
AC_MSG_CHECKING([if compiler can correctly compile and run a test program which converts _Float16 to other types with casts])
TEST_SRC="`(echo \"#define H5_FLOAT16_CONVERSION_FUNCS_LINK_TEST 1\"; cat $srcdir/config/cmake/ConversionTests.c)`"
AC_CACHE_VAL([hdf5_cv_float16_conversion_funcs_link],
[AC_RUN_IFELSE(
[AC_LANG_SOURCE([$TEST_SRC])],
[hdf5_cv_float16_conversion_funcs_link=yes],
[hdf5_cv_float16_conversion_funcs_link=no],
[hdf5_cv_float16_conversion_funcs_link=no])])
AC_MSG_RESULT(${hdf5_cv_float16_conversion_funcs_link})
# Some compilers, notably AppleClang on MacOS 12, will succeed in the
# configure check above when optimization flags like -O3 are manually
# passed in CFLAGS. However, the build will then fail when it reaches
# compilation of H5Tconv.c because of the issue mentioned above. MacOS
# 13 appears to have fixed this, but, just to be sure, make sure the
# check also passes without the passed in CFLAGS.
conftest_cflags_backup="$CFLAGS"
CFLAGS=""
AC_MSG_CHECKING([if compiler can correctly compile and run a test program which converts _Float16 to other types with casts (without CFLAGS)])
TEST_SRC="`(echo \"#define H5_FLOAT16_CONVERSION_FUNCS_LINK_NO_FLAGS_TEST 1\"; cat $srcdir/config/cmake/ConversionTests.c)`"
AC_CACHE_VAL([hdf5_cv_float16_conversion_funcs_link_no_flags],
[AC_RUN_IFELSE(
[AC_LANG_SOURCE([$TEST_SRC])],
[hdf5_cv_float16_conversion_funcs_link_no_flags=yes],
[hdf5_cv_float16_conversion_funcs_link_no_flags=no],
[hdf5_cv_float16_conversion_funcs_link_no_flags=no])])
AC_MSG_RESULT(${hdf5_cv_float16_conversion_funcs_link_no_flags})
CFLAGS="$conftest_cflags_backup"
if test ${hdf5_cv_float16_conversion_funcs_link} = "yes" &&
test ${hdf5_cv_float16_conversion_funcs_link_no_flags} = "yes"; then
# Finally, MacOS 13 appears to have a bug specifically when converting
# long double values to _Float16. Release builds of the dt_arith test
# would cause any assignments to a _Float16 variable to be elided,
# whereas Debug builds would perform incorrect hardware conversions by
# simply chopping off all the bytes of the value except for the first 2.
# These tests pass on MacOS 14, so let's perform a quick test to check
# if the hardware conversion is done correctly.
AC_MSG_CHECKING([if compiler can correctly convert long double values to _Float16])
TEST_SRC="`(echo \"#define H5_LDOUBLE_TO_FLOAT16_CORRECT_TEST 1\"; cat $srcdir/config/cmake/ConversionTests.c)`"
if test ${ac_cv_sizeof_long_double} = 0; then
hdf5_cv_ldouble_to_float16_correct=${hdf5_cv_ldouble_to_float16_correct=no}
else
AC_CACHE_VAL([hdf5_cv_ldouble_to_float16_correct],
[AC_RUN_IFELSE(
[AC_LANG_SOURCE([$TEST_SRC])],
[hdf5_cv_ldouble_to_float16_correct=yes],
[hdf5_cv_ldouble_to_float16_correct=no],
[hdf5_cv_ldouble_to_float16_correct=yes])])
fi
AC_MSG_RESULT(${hdf5_cv_ldouble_to_float16_correct})
# Backup and clear CFLAGS before performing configure check again
conftest_cflags_backup="$CFLAGS"
CFLAGS=""
AC_MSG_CHECKING([if compiler can correctly convert long double values to _Float16 (without CFLAGS)])
TEST_SRC="`(echo \"#define H5_LDOUBLE_TO_FLOAT16_CORRECT_NO_FLAGS_TEST 1\"; cat $srcdir/config/cmake/ConversionTests.c)`"
if test ${ac_cv_sizeof_long_double} = 0; then
hdf5_cv_ldouble_to_float16_correct_no_flags=${hdf5_cv_ldouble_to_float16_correct_no_flags=no}
else
AC_CACHE_VAL([hdf5_cv_ldouble_to_float16_correct_no_flags],
[AC_RUN_IFELSE(
[AC_LANG_SOURCE([$TEST_SRC])],
[hdf5_cv_ldouble_to_float16_correct_no_flags=yes],
[hdf5_cv_ldouble_to_float16_correct_no_flags=no],
[hdf5_cv_ldouble_to_float16_correct_no_flags=yes])])
fi
AC_MSG_RESULT(${hdf5_cv_ldouble_to_float16_correct_no_flags})
CFLAGS="$conftest_cflags_backup"
if test ${hdf5_cv_ldouble_to_float16_correct} = "yes" &&
test ${hdf5_cv_ldouble_to_float16_correct_no_flags} = "yes"; then
AC_DEFINE([LDOUBLE_TO_FLOAT16_CORRECT], [1],
[Define if your system can convert long double to _Float16 values correctly.])
else
AC_MSG_NOTICE([Conversions from long double to _Float16 appear to be incorrect. These will be emulated through a soft conversion function.])
fi
HAVE__FLOAT16="yes"
# Check if we can use fabsf16
AC_CHECK_FUNC([fabsf16], [AC_DEFINE([HAVE_FABSF16], [1],
[Define if has fabsf16 function])], [])
# Define HAVE__FLOAT16 macro for H5pubconf.h if _Float16 is available.
AC_DEFINE([HAVE__FLOAT16], [1], [Determine if _Float16 is available])
fi
fi
AC_MSG_CHECKING([if _Float16 support is enabled])
AC_MSG_RESULT([$HAVE__FLOAT16])
fi
else
AC_DEFINE([SIZEOF__FLOAT16], [0])
fi
# Define HAVE__FLOAT16 value to substitute into other files for conditional testing
AC_SUBST([HAVE__FLOAT16])
## ----------------------------------------------------------------------
## Check if the Fortran interface should be enabled
##
## This needs to be exposed for the library info file even if Fortran is disabled.
AC_SUBST([HDF_FORTRAN])
## Default is no Fortran
HDF_FORTRAN=no
AC_SUBST([HDF5_INTERFACES]) HDF5_INTERFACES=""
AC_MSG_CHECKING([if Fortran interface enabled])
AC_ARG_ENABLE([fortran],
[AS_HELP_STRING([--enable-fortran],
[Compile the Fortran interface [default=no]])],
[HDF_FORTRAN=$enableval])
AC_MSG_RESULT([$HDF_FORTRAN])
if test "X$HDF_FORTRAN" = "Xyes"; then
## ----------------------------------------------------------------------
## Check for non-standard extension __FLOAT128
##
HAVE_FLOAT128=0
HAVE_QUADMATH=0
FLT128_DIG=0
LDBL_DIG=0
AC_CHECK_SIZEOF([__float128])
AC_CHECK_SIZEOF([_Quad])
AC_CHECK_HEADERS([quadmath.h], [HAVE_QUADMATH=1], [])
PAC_FC_LDBL_DIG
AC_SUBST([PAC_C_MAX_REAL_PRECISION])
if test "$ac_cv_sizeof___float128" != 0 && test "$FLT128_DIG" != 0 ; then
AC_DEFINE([HAVE_FLOAT128], [1], [Determine if __float128 is available])
PAC_C_MAX_REAL_PRECISION=$FLT128_DIG
else
PAC_C_MAX_REAL_PRECISION=$LDBL_DIG
fi
AC_DEFINE_UNQUOTED([PAC_C_MAX_REAL_PRECISION], $PAC_C_MAX_REAL_PRECISION, [Determine the maximum decimal precision in C])
AC_MSG_RESULT([$PAC_C_MAX_REAL_PRECISION])
VERS_MAJOR=`cat $srcdir/src/H5public.h | sed -n 's/^#define H5_VERS_MAJOR //p'`
VERS_MINOR=`cat $srcdir/src/H5public.h | sed -n 's/^#define H5_VERS_MINOR //p'`
VERS_RELEASE=`cat $srcdir/src/H5public.h | sed -n 's/^#define H5_VERS_RELEASE //p'`
AC_DEFINE_UNQUOTED([VERS_MAJOR_TMP], $VERS_MAJOR, [Define major library version])
AC_DEFINE_UNQUOTED([VERS_MINOR_TMP], $VERS_MINOR, [Define minor library version])
AC_DEFINE_UNQUOTED([VERS_RELEASE_TMP], $VERS_RELEASE, [Define release library version])
## We will output an include file for Fortran, H5config_f.inc which
## contains various configure definitions used by the Fortran Library.
## Prepend H5_ to all macro names. This avoids name conflict between HDF5 macro
## names and those generated by another software package that uses the HDF5 library.
AC_CONFIG_HEADERS([fortran/src/H5config_f.inc],
[cat fortran/src/H5config_f.inc | sed '1d;s%^/\* \(.*\) \*/%\1%;s/#define /#define H5_/;s/#undef /#undef H5_/' >fortran/src/H5config_f.inc.tmp; sed -i 's\_TMP\\g' fortran/src/H5config_f.inc.tmp; mv -f fortran/src/H5config_f.inc.tmp fortran/src/H5config_f.inc])
AC_SUBST([FC])
HDF5_INTERFACES="$HDF5_INTERFACES fortran"
## --------------------------------------------------------------------
## HDF5 integer variables for the H5fortran_types.f90 file.
##
AC_SUBST([R_LARGE])
AC_SUBST([R_INTEGER])
AC_SUBST([HADDR_T])
AC_SUBST([HSIZE_T])
AC_SUBST([HSSIZE_T])
AC_SUBST([HID_T])
AC_SUBST([SIZE_T])
AC_SUBST([OBJECT_NAMELEN_DEFAULT_F])
## --------------------------------------------------------------------
## Fortran source extension
##
AC_FC_SRCEXT([f90])
AC_SUBST([F9XSUFFIXFLAG])
AC_SUBST([FSEARCH_DIRS])
## --------------------------------------------------------------------
## Check for a Fortran compiler and how to include modules.
##
AC_PROG_FC([PAC_FC_SEARCH_LIST],)
AC_F9X_MODS
## Allow setting the fortran module install dir
AC_ARG_WITH([fmoddir],
[AS_HELP_STRING([--with-fmoddir=DIR], [Fortran module install directory])],
[fmoddir=$withval],
[fmoddir="\${includedir}"])
AC_SUBST([fmoddir], [$fmoddir])
## Change to the Fortran 90 language
AC_LANG_PUSH(Fortran)
## Checking if the compiler supports the required Fortran 2003 features and
## stopping if it does not.
PAC_PROG_FC_HAVE_F2003_REQUIREMENTS
if test "X$HAVE_F2003_REQUIREMENTS" = "Xno"; then
AC_MSG_ERROR([Fortran compiler lacks required Fortran 2003 features; unsupported Fortran 2003 compiler, remove --enable-fortran])
fi
## Checking if the compiler supports fortran character being allocatable
PAC_HAVE_CHAR_ALLOC
## --------------------------------------------------------------------
## Define wrappers for the C compiler to use Fortran function names
##
AC_FC_WRAPPERS
## --------------------------------------------------------------------
## See if the fortran compiler supports the intrinsic function "SIZEOF"
PAC_PROG_FC_SIZEOF
## See if the fortran compiler supports the intrinsic function "C_SIZEOF"
PAC_PROG_FC_C_SIZEOF
## See if the fortran compiler supports the intrinsic function "STORAGE_SIZE"
PAC_PROG_FC_STORAGE_SIZE
## --------------------------------------------------------------------
## Checking if the fortran compiler supports ISO_FORTRAN_ENV (Fortran 2008)
HAVE_ISO_FORTRAN_ENV="0"
PAC_PROG_FC_ISO_FORTRAN_ENV
if test "X$CHECK_ISO_FORTRAN_ENV" = "Xyes"; then
HAVE_ISO_FORTRAN_ENV="1"
AC_DEFINE([HAVE_ISO_FORTRAN_ENV], [1], [Define if Fortran supports ISO_FORTRAN_ENV (F08)])
fi
## Set the sizeof function for use later in the fortran tests
if test "X$HAVE_STORAGE_SIZE_FORTRAN" = "Xyes";then
FC_SIZEOF_A="STORAGE_SIZE(a, c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t)"
FC_SIZEOF_B="STORAGE_SIZE(b, c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t)"
FC_SIZEOF_C="STORAGE_SIZE(c, c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t)"
else
if test "X$HAVE_SIZEOF_FORTRAN" = "Xyes";then
FC_SIZEOF_A="SIZEOF(a)"
FC_SIZEOF_B="SIZEOF(b)"
FC_SIZEOF_C="SIZEOF(c)"
else
## If neither intrinsic functions SIZEOF or STORAGE_SIZE is available then stop configure with an error
AC_MSG_ERROR([Fortran compiler requires either intrinsic functions SIZEOF or STORAGE_SIZE])
fi
fi
## Check KIND and size of native integer
PAC_FC_NATIVE_INTEGER
## Find all available KINDs
if test "X$HAVE_ISO_FORTRAN_ENV" = "X1";then
PAC_FC_AVAIL_KINDS_F08
else
PAC_FC_AVAIL_KINDS
fi
## Find all SIZEOFs for available KINDs
PAC_FC_SIZEOF_INT_KINDS
PAC_FC_SIZEOF_REAL_KINDS
AC_SUBST([PAC_FC_ALL_REAL_KINDS])
AC_SUBST([PAC_FC_MAX_REAL_PRECISION])
AC_SUBST([PAC_FORTRAN_NUM_INTEGER_KINDS])
AC_SUBST([PAC_FC_ALL_INTEGER_KINDS])
AC_SUBST([PAC_FC_ALL_REAL_KINDS_SIZEOF])
AC_SUBST([PAC_FC_ALL_INTEGER_KINDS_SIZEOF])
AC_SUBST([PAC_FORTRAN_NATIVE_INTEGER_KIND])
AC_SUBST([PAC_FORTRAN_NATIVE_INTEGER_SIZEOF])
AC_SUBST([PAC_FORTRAN_NATIVE_REAL_KIND])
AC_SUBST([PAC_FORTRAN_NATIVE_REAL_SIZEOF])
AC_SUBST([PAC_FORTRAN_NATIVE_DOUBLE_KIND])
AC_SUBST([PAC_FORTRAN_NATIVE_DOUBLE_SIZEOF])
AC_SUBST([HAVE_Fortran_INTEGER_SIZEOF_16])
AC_SUBST([FORTRAN_HAVE_C_LONG_DOUBLE])
AC_SUBST([FORTRAN_C_LONG_DOUBLE_IS_UNIQUE])
AC_SUBST([FORTRAN_C_BOOL_IS_UNIQUE])
AC_SUBST([HAVE_ISO_FORTRAN_ENV])
AC_SUBST([H5CONFIG_F_NUM_RKIND])
AC_SUBST([H5CONFIG_F_RKIND])
AC_SUBST([H5CONFIG_F_RKIND_SIZEOF])
AC_SUBST([H5CONFIG_F_NUM_IKIND])
AC_SUBST([H5CONFIG_F_IKIND])
AC_SUBST([Fortran_COMPILER_ID])
Fortran_COMPILER_ID=none
AC_DEFINE_UNQUOTED([Fortran_COMPILER_ID], $Fortran_COMPILER_ID, [Define Fortran compiler ID])
## Setting definition if there is a 16 byte fortran integer
if `echo $PAC_FC_ALL_INTEGER_KINDS_SIZEOF | grep '16' >/dev/null`; then
HAVE_Fortran_INTEGER_SIZEOF_16="1"
AC_DEFINE([HAVE_Fortran_INTEGER_SIZEOF_16], [1], [Determine if INTEGER*16 is available])
else
HAVE_Fortran_INTEGER_SIZEOF_16="0"
AC_DEFINE([HAVE_Fortran_INTEGER_SIZEOF_16], [0], [Determine if INTEGER*16 is available])
fi
if test "X$HAVE_STORAGE_SIZE_FORTRAN" = "Xyes"; then
AC_DEFINE([FORTRAN_HAVE_STORAGE_SIZE], [1], [Define if we have Fortran intrinsic STORAGE_SIZE])
fi
if test "X$HAVE_C_SIZEOF_FORTRAN" = "Xyes"; then
AC_DEFINE([FORTRAN_HAVE_C_SIZEOF], [1], [Define if we have Fortran intrinsic C_SIZEOF])
fi
if test "X$HAVE_SIZEOF_FORTRAN" = "Xyes"; then
AC_DEFINE([FORTRAN_HAVE_SIZEOF], [1], [Define if we have Fortran intrinsic SIZEOF])
fi
if test "X$HAVE_CHAR_ALLOC_FORTRAN" = "Xyes"; then
AC_DEFINE([FORTRAN_HAVE_CHAR_ALLOC], [1], [Define if Fortran supports allocatable character])
fi
## See if C_LONG_DOUBLE is available
PAC_PROG_FC_HAVE_C_LONG_DOUBLE
FORTRAN_HAVE_C_LONG_DOUBLE="0"
if test "X$HAVE_C_LONG_DOUBLE_FORTRAN" = "Xyes"; then
FORTRAN_HAVE_C_LONG_DOUBLE="1"
AC_DEFINE([FORTRAN_HAVE_C_LONG_DOUBLE], [1], [Define if we have Fortran C_LONG_DOUBLE])
fi
## Is C_LONG_DOUBLE different from C_DOUBLE
FORTRAN_C_LONG_DOUBLE_IS_UNIQUE="0"
if test "$FORTRAN_HAVE_C_LONG_DOUBLE" = "1"; then