-
Notifications
You must be signed in to change notification settings - Fork 9
/
configure.ac
2886 lines (2386 loc) · 90.2 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
## configure.ac - Autotools configuration file for Crypto++.
## written and placed in public domain by Jeffrey Walton.
## based on Debian configure.ac by László Böszörményi.
## Visit the link below for the original Debian Autotools files
## http://sources.debian.net/src/libcrypto++/5.6.4-8/debian/autotools/
##
## To generate the configure file perform the following. The extra steps are
## needed because the Autotools on some machines, like a PowerMac or Solaris,
## are not modern enough for macros like AC_PROG_LIBTOOL and AC_ENABLE_SHARED.
##
## autoupdate && libtoolize && autoreconf
##
## Our Autoconf tests are strict. We use custom AC_COMPILE_IFELSE and
## AC_LINK_IFELSE that rejects a feature test if there are any warnings or
## errors. We needed this because Autotools was mis-detecting features on AIX
## and Solarix using XLC and SunCC. We also needed the custom tests because
## Autoconf does not have a "warnings as errors" option that just works on all
## the compilers we support.
## TODO
##
## - Figure out how to make Autoconf stop using the fucking C compiler for tasks.
## The damn tool does not honor AC_PROG_CXX or observe the absence of
## AC_PROG_CC. It also fails to provide a AC_PROG_NO_CC macro. The damn tool
## is no better than Cmake.
##
## - Fix Autotools not treating warnings as errors. Our test programs are clean,
## so they should compile cleanly or the feature is not available. However,
## Autotools lacks a AC_TREAT_WARNINGS_AS_ERRORS-like macro or define.
##
## - Fix Autoconf using the wrong AR and ARFLAGS on platforms like OS X. Also
## see http://lists.gnu.org/archive/html/bug-autoconf/2017-11/msg00002.html.
##
## - Fix Autoconf not honoring LT_INIT. We are trying to enable PIC, static and
## shared by default but Autotools is ignoring [pic-only]. Also see
## https://stackoverflow.com/q/56215237/608639.
##
## - Fix Autoconf not using PIC/PIE for cryptest. The problem is bigger than the
## LT_INIT bug. There is no Uniform Name like bin_LTPROGRAMS to signal PIC/PIE
## should be used. Autoconf is guessing wrong and not using PIC/PIE.
##
## - Fix Autotools 'make dist' failures. If you run 'make dist' on x86_64, then
## the release tarball only works on x86_64. It is like it is pre-configured
## for only the x86_64 platform, and other platform code paths have been
## thrown away. WTF???
##
## - Fix Autoconf ignoring our config.h.in. This one looks like it is a problem
## without a solution. Also see https://stackoverflow.com/q/48436715/608639.
## (Gave up after https://github.com/weidai11/cryptopp/commit/c51f0ecbfd21.
## Now we can write new config_asm.h, config_cxx.h, and config_misc.h.)
##
## - Figure out how to write new configuration information to config_asm.h,
## config_cxx.h, and config_misc.h. According to the Autoconf manual we
## can use multiple headers. However, it does not seem to work in
## practice. Also see https://stackoverflow.com/q/56193203/608639.
##
## - Stop using local.h, and write the config data into a Crypto++ compatible
## config.h. There's not much to "Crypto++ compatible config.h". We need test
## and write preprocessor macros like CRYPTOPP_BIG_ENDIAN,
## CRYPTOPP_LITTLE_ENDIAN, CRYPTOPP_CXX11, etc. There's just a lot of them.
## This problem now appears to be closely related to the config.h.in problem.
## We can't supply a template and expect Autotools to honor it. Also see
## https://lists.gnu.org/archive/html/autoconf/2018-07/msg00014.html.
##
## - Fix incorrect use of --with-sysroot. Autotools does not seem to honor it
## when it is set. Also see http://stackoverflow.com/q/47226389/608639.
##
## - Fix MSYS2 compile error due to `lt-cryptest.c` and `lt-cryptestcwd.c`.
## They are C files and don't use necessary C++ flags. They also use Posix
## functions but fail to define _XOPEN_SOURCE. I'm guessing this has something
## to do with libtool, but I have no idea how to fix it at the moment. Also
## see http://lists.gnu.org/archive/html/bug-libtool/2017-11/msg00002.html.
##
## - Fix the ARM 32-builds. Running 'cryptest v' results in
## "unexpected reloc type 0x03". GNUmakefile and CMake are OK. I've been
## working on it (on and off) for three days and no closer to finding a
## solution. Autotools is such a broken heaping pile of shit... Also see
## https://sourceware.org/ml/binutils/2019-05/msg00287.html
##
## - Fix static initialization order fiasco tests. We don't know how to craft
## the tests because we don't know how to compile two files at once using
## Autotools. Also see https://stackoverflow.com/q/51662985/608639.
##
## - Fix -xarch for SHA when using SunCC. We don't know the arch value at the
## moment. If things work as expected we will fail the feature test and the
## code paths will be disabled. But we want them enabled once Sun supports
## the SHA extensions. See https://stackoverflow.com/q/45872180/608639.
##
## - Fix LDFLAGS on AIX. Autotools is adding unwanted flags to LDFLAGS and it
## is causing a runtime crash in startup code. See
## https://stackoverflow.com/q/51680113/608639.
##
## - Add ubsan and asan targets for testing.
##
## - Setup test environment with Dash, which appears to be the lamest shell.
##
## - Package Autotools propery, for a regular user's definition of "proper".
## I don't know what the final deliverables or artifacts are supposed to
## look like. We also get warnings and errors due to a missing m4/ directory
## even though we don't use it. Maybe we need to distribute an empty m4/
## directory to keep the tools quiet.
#############################################################################
## This configure.ac proceeds in five parts:
##
## 1. configure.ac preamble
##
## 2. compiler and host detection
##
## 3. configure options, like --disable-asm
##
## 4. CPU feature tests, like SSE, NEON, ARMv8, PowerPC
##
## 5. C++ feature tests, like C++11, alignof and alignas
##
## 6. miscellaneous feature and options
##
## 7. final setup, output artifacts and summary
##
# Print this early. Build is the machine where the compiler
# is running. Host is the machine the software will run.
echo "Host is $host"
echo "Build is $build"
#############################################################################
## PART 1 PART 1 PART 1 PART 1 PART 1 PART 1 PART 1 PART 1
## ==========================================================================
## configure.ac preamble
#############################################################################
AC_INIT([Crypto++], [8.8], [http://www.cryptopp.com/wiki/Bug_Report], [cryptopp], [http://www.cryptopp.com])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_HEADERS([local.h])
AC_CONFIG_FILES([Makefile] [libcryptopp.pc])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE
AM_PROG_AS
AC_PROG_LIBTOOL
AC_PROG_CXX
AC_LANG([C++])
LT_LANG([C++])
# Programs we use
AC_PROG_SED
AC_PROG_AWK
AC_PROG_GREP
AC_PROG_EGREP
# Detect build and host platforms
AC_CANONICAL_HOST
AC_CANONICAL_BUILD
## Assert this once to avoid surprises
AC_LANG_ASSERT([C++])
#############################################################################
## Our Autoconf tests are strict. We use custom AC_COMPILE_IFELSE and
## AC_LINK_IFELSE that rejects a feature test if there are any warnings or
## errors. We needed this because Autotools was mis-detecting features on
## AIX and Solarix using XLC and SunCC. We also needed the custom tests
## because Autoconf does not have a "warnings as errors" option that just
## works on all the compilers we support.
AC_DEFUN([XXX_COMPILE_IFELSE],
[AC_COMPILE_IFELSE(
[$1],
[retval=0
touch conftest.err
if test `cat conftest.err | wc -w` != "0"; then retval=1; fi
],[retval=1]
)
AS_IF([test $retval = 0],[$2],[$3])]
)
AC_DEFUN([XXX_LINK_IFELSE],
[AC_LINK_IFELSE(
[$1],
[retval=0
touch conftest.err
if test `cat conftest.err | wc -w` != "0"; then retval=1; fi
],[retval=1]
)
AS_IF([test $retval = 0],[$2],[$3])]
)
#############################################################################
## PART 2 PART 2 PART 2 PART 2 PART 2 PART 2 PART 2 PART 2
## ==========================================================================
## compiler and host detection
#############################################################################
## These are some variables that help us track platform and compiler.
## It speeds up configuration by adding some intelligence to the
## test selection process. It also avoids failed configurations by
## avoiding some tests that fail but Autotools reports as success.
IS_AIX_OS=`echo $host | $GREP -i -c 'aix'`
IS_SUN_OS=`uname -s | $GREP -i -c 'SunOS'`
IS_LINUX_OS=`echo "$host" | $GREP -i -c 'linux'`
IS_APPLE_OS=`echo "$host" | $EGREP -i -c 'apple|darwin'`
IS_ANDROID_OS=`echo $host | $GREP -i -c 'android'`
IS_CYGWIN_OS=`echo $host | $GREP -i -c 'cygwin'`
IS_MINGW_OS=`echo $host | $GREP -i -c 'mingw'`
IS_X86=`echo $host | $EGREP -i -c 'i.86|x86_64|amd64'`
IS_ARM32=`echo $host | $EGREP -i -c 'arm|armhf|arm7l|armeabi|armel'`
IS_ARMV8=`echo $host | $EGREP -i -c 'aarch32|aarch64|armv8'`
IS_PPC=`echo $host | $EGREP -i -c 'ppc|powerpc|powermac'`
IS_SPARC=`echo $host | $EGREP -i -c 'sparc|sparcv8|sparcv9|sparc64'`
## Debug builds add more goodies to help break things. I like breaking things.
IS_DEBUG=`echo $CPPFLAGS $CXXFLAGS | $GREP -i -c '\-DDEBUG'`
## Fixup
if test "$IS_ARMV8" != "0"; then
IS_ARM32=0
fi
#############################################################################
## Determine the compiler's target. GCC '-dumpmachine' is the target,
## so it represents what the compiler is building for (and not what its
## running on). We add '2>/dev/null' because IBM's xlC dumps the man page
## when presented with '-dumpmachine' since it is not a valid option.
## See if CXX is valid. Autotools just trucks on with an invalid one.
if test x"$CXX" != "x"; then
COMPILER_VALID=`command -v "$CXX"`
if test x"$COMPILER_VALID" = "x"; then
AC_MSG_FAILURE(["$CXX" is not a valid compiler or is not on-path])
fi
fi
## Compiler is valid. Try to detect the target and vendor.
## SunCC is empty, so we just use $build
COMPILER_TARGET=`"$CXX" "$CXXFLAGS" -dumpmachine 2>/dev/null`
if test x"$COMPILER_TARGET" = "x"; then
COMPILER_TARGET="$build"
fi
## Determine the compiler's vendor. We need to work around some Autoconf bugs.
COMPILER_VERSION=`"$CXX" --version 2>/dev/null | head -n 1`
## IBM xlC test if COMPILER_VERSION is empty
if test x"$COMPILER_VERSION" = "x"; then
COMPILER_VERSION=`"$CXX" -qversion 2>/dev/null | head -n 1`
fi
## SunCC test if COMPILER_VERSION is empty
if test x"$COMPILER_VERSION" = "x"; then
COMPILER_VERSION=`"$CXX" -V 2>&1 | head -n 1`
fi
## Microsoft test if COMPILER_VERSION is empty
if test `basename "$CXX"` = "cl.exe"; then
COMPILER_VERSION=`"$CXX" /? 2>&1 | head -n 1`
fi
IS_GCC_COMPILER=`echo $COMPILER_VERSION | $GREP -i -v 'Clang' | $EGREP -i -c 'GCC|G\+\+'`
IS_MSC_COMPILER=`echo $COMPILER_VERSION | $GREP -i -c 'Microsoft'`
IS_LLVM_COMPILER=`echo $COMPILER_VERSION | $EGREP -i -c 'LLVM|Clang'`
IS_SUN_COMPILER=`echo $COMPILER_VERSION | $EGREP -i -c 'Sun C'`
IS_ICC_COMPILER=`echo $COMPILER_VERSION | $GREP -i -c 'ICC'`
IS_XLC_COMPILER=`echo $COMPILER_VERSION | $GREP -i -c 'IBM XL'`
IS_PORTS_COMPILER=`echo $COMPILER_VERSION | $EGREP -i -c 'MacPorts|Homebrew'`
## A catch-all for compilers that claim to be GCC compatible. Each should be
## able to handle GCC syntax. It excludes XLC, SunCC and MSVC
if test "$IS_GCC_COMPILER" != "0" || test "$IS_LLVM_COMPILER" != "0" || \
test "$IS_ICC_COMPILER" != "0"; then
IS_GNUC_COMPILER=1
else
IS_GNUC_COMPILER=0
fi
if test "x$AS" = "x"; then
AS=`command -v as`
fi
## Friendly names for reporting
ASNAME=`basename "$AS"`
CXXNAME=`basename "$CXX"`
LDNAME=`basename "$LD"`
## Small fixup
case "$LDNAME" in
"ld "*) LDNAME=ld
;;
esac
#############################################################################
## PART 3 PART 3 PART 3 PART 3 PART 3 PART 3 PART 3 PART 3
## ==========================================================================
## configure options, like --disable-asm
#############################################################################
AC_ARG_ENABLE([pthreads],
AS_HELP_STRING([--disable-pthreads], [disable pthreads]))
AS_IF([test "x$enable_pthreads" = "xno"], [
: # AC_DEFINE([CRYPTOPP_DISABLE_PTHREADS], [1], [disable pthreads])
])
# Applies to all platforms
AC_ARG_ENABLE([asm],
AS_HELP_STRING([--disable-asm], [disable all ASM and intrinsics]))
AS_IF([test "x$enable_asm" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_ASM], [1], [disable all ASM and intrinsics])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_ASM"
])
# X86 defines
AC_ARG_ENABLE([sse2],
AS_HELP_STRING([--disable-sse2], [disable x86 SSE2 instructions]))
AS_IF([test "x$enable_sse2" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_SSE2], [1], [disable x86 SSE2 instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_SSE2"
])
AC_ARG_ENABLE([sse3],
AS_HELP_STRING([--disable-sse3], [disable x86 SSE3 instructions]))
AS_IF([test "x$enable_sse3" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_SSE3], [1], [disable x86 SSE3 instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_SSE3"
])
AC_ARG_ENABLE([ssse3],
AS_HELP_STRING([--disable-ssse3], [disable x86 SSSE3 instructions]))
AS_IF([test "x$enable_ssse3" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_SSSE3], [1], [disable x86 SSSE3 instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_SSSE3"
])
AC_ARG_ENABLE([sse4],
AS_HELP_STRING([--disable-sse4], [disable x86 SSE4.1 and SSE4.2 instructions]))
AS_IF([test "x$enable_sse4" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_SSE4], [1], [disable x86 SSE4.1 and SSE4.2 instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_SSE4"
])
AC_ARG_ENABLE([clmul],
AS_HELP_STRING([--disable-clmul], [disable x86 CLMUL instructions]))
AS_IF([test "x$enable_clmul" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_CLMUL], [1], [disable x86 CLMUL instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_CLMUL"
])
AC_ARG_ENABLE([aes],
AS_HELP_STRING([--disable-aes], [disable x86 AES instructions]))
AS_IF([test "x$enable_aes" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_AES], [1], [disable x86 AES instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_AES"
])
AC_ARG_ENABLE([sha],
AS_HELP_STRING([--disable-sha], [disable x86 SHA instructions]))
AS_IF([test "x$enable_sha" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_SHA], [1], [disable x86 SHA instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_SHA"
])
AC_ARG_ENABLE([avx],
AS_HELP_STRING([--disable-avx], [disable x86 AVX instructions]))
AS_IF([test "x$enable_avx" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_AVX], [1], [disable x86 AVX instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_AVX"
])
AC_ARG_ENABLE([avx2],
AS_HELP_STRING([--disable-avx2], [disable x86 AVX2 instructions]))
AS_IF([test "x$enable_avx2" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_AVX2], [1], [disable x86 AVX2 instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_AVX2"
])
# ARM-32 defines
AC_ARG_ENABLE([armv7],
AS_HELP_STRING([--disable-armv7], [disable ARM ARMv7 instructions]))
AS_IF([test "x$enable_armv7" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_ARM_ARMV7], [1], [disable ARM ARMv7 instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_ARM_ARMV7"
])
AC_ARG_ENABLE([neon],
AS_HELP_STRING([--disable-neon], [disable ARM NEON instructions]))
AS_IF([test "x$enable_neon" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_ARM_NEON], [1], [disable ARM NEON instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_ARM_NEON"
])
# ARMv8 defines
AC_ARG_ENABLE([asimd],
AS_HELP_STRING([--disable-asimd], [disable ARMv8 ASIMD instructions]))
AS_IF([test "x$enable_asimd" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_ARM_ASIMD], [1], [disable ARMv8 ASIMD instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_ARM_ASIMD"
])
AC_ARG_ENABLE([crc32],
AS_HELP_STRING([--disable-crc32], [disable ARMv8 CRC32 instructions]))
AS_IF([test "x$enable_crc32" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_ARM_CRC32], [1], [disable ARMv8 CRC32 instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_ARM_CRC32"
])
AC_ARG_ENABLE([pmull],
AS_HELP_STRING([--disable-pmull], [disable ARMv8 PMULL instructions]))
AS_IF([test "x$enable_pmull" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_ARM_PMULL], [1], [disable ARMv8 PMULL instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_ARM_PMULL"
])
AC_ARG_ENABLE([aes],
AS_HELP_STRING([--disable-aes], [disable ARMv8 AES instructions]))
AS_IF([test "x$enable_aes" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_ARM_AES], [1], [disable ARMv8 AES instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_ARM_AES"
])
AC_ARG_ENABLE([sha1],
AS_HELP_STRING([--disable-sha1], [disable ARMv8 SHA1 instructions]))
AS_IF([test "x$enable_sha1" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_ARM_SHA1], [1], [disable ARMv8 SHA1 instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_ARM_SHA1"
])
AC_ARG_ENABLE([sha256],
AS_HELP_STRING([--disable-sha256], [disable ARMv8 SHA256 instructions]))
AS_IF([test "x$enable_sha256" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_ARM_SHA256], [1], [disable ARMv8 SHA256 instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_ARM_SHA256"
])
AC_ARG_ENABLE([sha512],
AS_HELP_STRING([--disable-sha512], [disable ARMv8 SHA512 instructions]))
AS_IF([test "x$enable_sha512" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_ARM_SHA512], [1], [disable ARMv8 SHA512 instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_ARM_SHA512"
])
AC_ARG_ENABLE([sha3],
AS_HELP_STRING([--disable-sha3], [disable ARMv8 SHA3 instructions]))
AS_IF([test "x$enable_sha3" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_ARM_SHA3], [1], [disable ARMv8 SHA3 instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_ARM_SHA3"
])
AC_ARG_ENABLE([sm3],
AS_HELP_STRING([--disable-sm3], [disable ARMv8 SM3 instructions]))
AS_IF([test "x$enable_sm3" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_ARM_SM3], [1], [disable ARMv8 SM3 instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_ARM_SM3"
])
AC_ARG_ENABLE([sm4],
AS_HELP_STRING([--disable-sm4], [disable ARMv8 SM4 instructions]))
AS_IF([test "x$enable_sm4" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_ARM_SM4], [1], [disable ARMv8 SM4 instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_ARM_SM4"
])
# PPC defines
AC_ARG_ENABLE([altivec],
AS_HELP_STRING([--disable-altivec], [disable PPC Altivec instructions]))
AS_IF([test "x$enable_altivec" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_ALTIVEC], [1], [disable PPC Altivec instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_ALTIVEC"
])
AC_ARG_ENABLE([power7],
AS_HELP_STRING([--disable-power7], [disable POWER7 instructions]))
AS_IF([test "x$enable_altivec" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_POWER7], [1], [disable POWER7 instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_POWER7"
])
AC_ARG_ENABLE([power8],
AS_HELP_STRING([--disable-power8], [disable POWER8 instructions]))
AS_IF([test "x$enable_altivec" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_POWER8], [1], [disable POWER8 instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_POWER8"
])
AC_ARG_ENABLE([power9],
AS_HELP_STRING([--disable-power9], [disable POWER9 instructions]))
AS_IF([test "x$enable_altivec" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_POWER9], [1], [disable POWER9 instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_POWER9"
])
AC_ARG_ENABLE([aes],
AS_HELP_STRING([--disable-aes], [disable PPC AES instructions]))
AS_IF([test "x$enable_aes" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_POWER8_AES], [1], [disable PPC AES instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_POWER8_AES"
])
AC_ARG_ENABLE([vmull],
AS_HELP_STRING([--disable-vmull], [disable PPC VMULL instructions]))
AS_IF([test "x$enable_vmull" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_POWER8_VMULL], [1], [disable PPC VMULL instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_POWER8_VMULL"
])
AC_ARG_ENABLE([sha256],
AS_HELP_STRING([--disable-sha256], [disable PPC SHA256 instructions]))
AS_IF([test "x$enable_sha256" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_POWER8_SHA256], [1], [disable PPC SHA256 instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_POWER8_SHA256"
])
AC_ARG_ENABLE([sha512],
AS_HELP_STRING([--disable-sha512], [disable PPC SHA512 instructions]))
AS_IF([test "x$enable_sha512" = "xno"], [
AC_DEFINE([CRYPTOPP_DISABLE_POWER8_SHA512], [1], [disable PPC SHA512 instructions])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_POWER8_SHA512"
])
#############################################################################
## PART 4 PART 4 PART 4 PART 4 PART 4 PART 4 PART 4 PART 4
## ==========================================================================
## CPU feature tests, like SSE, NEON, ARMv8, PowerPC
#############################################################################
#############################################################################
## Die early on Android
if test "$IS_ANDROID_OS" != "0"; then
AC_MSG_CHECKING([if ANDROID_NDK_ROOT is set])
if test x"$ANDROID_NDK_ROOT" != "x"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
AC_MSG_ERROR([ANDROID_NDK_ROOT is not set. Please set ANDROID_NDK_ROOT])
fi
fi
#############################################################################
## Doxygen documentation
## This only provides a 'make html-doc' recipe in the Makefile.
## If Doxygen is available the user still must issue the command.
AC_CHECK_PROGS([DOXYGEN], [doxygen])
if test x"$DOXYGEN" = "x"; then
AM_CONDITIONAL([CRYPTOPP_DOXYGEN_AVAILABLE], [false])
else
AM_CONDITIONAL([CRYPTOPP_DOXYGEN_AVAILABLE], [true])
fi
#############################################################################
## Shared and static libraries
if true; then
## Cant use AC_ENABLE_STATIC and AC_ENABLE_SHARED. AIX Autotools is too old.
AC_MSG_RESULT([checking if static libraries should be enabled... yes])
## http://stackoverflow.com/a/21455267/608639
case $host_os in
msys* | mingw* | cygwin* )
AC_MSG_RESULT([checking if shared libraries should be enabled... no])
enable_shared=no; enable_static=yes;
;;
*)
AC_MSG_RESULT([checking if shared libraries should be enabled... yes])
enable_shared=yes; enable_static=yes;
;;
esac
fi
#############################################################################
## Pthread library
if true; then
## Add to both CXXFLAGS and LDFLAGS if supported.
## https://stackoverflow.com/q/2127797/608639.
SAVED_CXXFLAGS="$CXXFLAGS"
SAVED_LDFLAGS="$LDFLAGS"
CXXFLAGS="-pthread"
LDFLAGS="-pthread"
AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS])
XXX_LINK_IFELSE(
[AC_LANG_SOURCE([[int main() { return 0; }]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]
)
if test "$retval" = "0"; then
AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
AM_LDFLAGS="$AM_LDFLAGS $LDFLAGS"
fi
LDFLAGS="$SAVED_LDFLAGS"
CXXFLAGS="$SAVED_CXXFLAGS"
fi
#############################################################################
## Init priorities
## The tests below should be in two separate source file violating
## init order. One object file should perform the Foo or Bar static
## init, and the second source would have a static object using
## Foo::s_x or Bar::s_x. The problem is, we don't know how to do it.
## Also see https://stackoverflow.com/q/51662985/608639.
## We can only run one Init Priority test. Otherwise, running both tests
## cause 'CRYPTOPP_INIT_PRIORITY 250' and 'CRYPTOPP_INIT_PRIORITY 0' to be
## written, which results in "warning: CRYPTOPP_INIT_PRIORITY redefined".
## And of course, Autools does not allow us to undefine a macro.
## GCC-style
if true; then
SAVED_CXXFLAGS="$CXXFLAGS"
## -Wall -Werror are GCC and friends specific. The problem is,
## Autotools lacks a cross-platform AC_TREAT_WARNINGS_AS_ERRORS.
if test "$IS_MSC_COMPILER" = "0"; then
THIS_CXXFLAGS="-Wall -Werror"
fi
CXXFLAGS="$THIS_CXXFLAGS"
XXX_PROGRAM="#include <string>
struct Foo {
Foo(int x) : m_x(x) {}
Foo(const Foo& o) : m_x(o.m_x) {}
Foo& operator=(const Foo& o) {m_x=o.m_x; return *this;}
static int s_x;
int m_x;
};
int Foo::s_x = -1;
static Foo unused __attribute__ ((init_priority (250))) = Foo::s_x;
// This should be in a separate source file violating init order.
// The separate file should have a main() and be linked first.
// static Foo f = Foo::s_x;
// bool success = f.m_x == -1;"
AC_MSG_CHECKING([if $CXXNAME supports init_priority])
XXX_COMPILE_IFELSE(
[AC_LANG_SOURCE([$XXX_PROGRAM])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]
)
if test "$retval" = "0"; then
AC_SUBST([HAVE_GCC_INIT_PRIORITY], [1])
AC_DEFINE([CRYPTOPP_INIT_PRIORITY], [250], [Enable init_priority])
else
AC_DEFINE([CRYPTOPP_INIT_PRIORITY], [0], [Disable init_priority])
fi
CXXFLAGS="$SAVED_CXXFLAGS"
fi
## MSC-style
if false; then
## The problem is, Autotools lacks a cross-platform
## AC_TREAT_WARNINGS_AS_ERRORS. Clang, GCC, and friends will see
## "pragma init_seg" and issue an an unknown pragma warning.
## Adding -Wall or -Werror will cause MSC and friends to fail on
## the illegal flag.
if test "$IS_MSC_COMPILER" = "1"; then
THIS_CXXFLAGS="/WX"
else
THIS_CXXFLAGS="-Wall -Werror"
fi
CXXFLAGS="$THIS_CXXFLAGS"
XXX_PROGRAM="#include <string>
struct Bar {
Bar(int x) : m_x(x) {}
Bar(const Bar& o) : m_x(o.m_x) {}
Bar& operator=(const Bar& o) {m_x=o.m_x; return *this;}
static int s_x;
int m_x;
};
#pragma init_seg(".CRT$XCU")
int Bar::s_x = -1;
static Bar unused __attribute__ ((init_priority (250))) = Bar::s_x;
// This should be in a separate source file violating init order.
// The separate file should have a main() and be linked first.
// static Bar b = Bar::s_x;
// bool success = b.m_x == -1;"
AC_MSG_CHECKING([if $CXXNAME supports init_seg])
XXX_COMPILE_IFELSE(
[AC_LANG_SOURCE([$XXX_PROGRAM])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]
)
if test "$retval" = "0"; then
AC_SUBST([HAVE_MSC_INIT_PRIORITY], [1])
AC_DEFINE([CRYPTOPP_INIT_PRIORITY], [250], [Enable init_seg])
else
AC_DEFINE([CRYPTOPP_INIT_PRIORITY], [0], [Disable init_seg])
fi
CXXFLAGS="$SAVED_CXXFLAGS"
fi
#############################################################################
## Solaris, SunCC and missing optimizations
OPT_ANY=`echo $CXXFLAGS | $EGREP -c '\-O0|\-O1|\-O2|\-O3|\-O4|\-O5|\-xO0|\-xO1|\-xO2|\-xO3|\-xO4|\-xO5|\-Os|\-Og|\-Ofast'`
if test "$OPT_ANY" = "0"; then
SAVED_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="-O2"
AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS])
XXX_COMPILE_IFELSE(
[AC_LANG_SOURCE([[int main() { return 0; }]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]
)
if test "$retval" = "0"; then
AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
else
# SunCC
CXXFLAGS="-xO2"
AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS])
XXX_COMPILE_IFELSE(
[AC_LANG_SOURCE([[int main() { return 0; }]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]
)
if test "$retval" = "0"; then
AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
fi
fi
CXXFLAGS="$SAVED_CXXFLAGS"
fi
#############################################################################
## Fix AR on iOS and OS X
## AR and ARFLAGS usage is currently broke under Autotools. Also see
## http://lists.gnu.org/archive/html/bug-autoconf/2017-11/msg00002.html
#if test "$IS_APPLE_OS" != "0"; then
# AC_SUBST([AR], ["/usr/bin/libtool"])
# AC_SUBST([ARFLAGS], ["-static -o"])
# AC_SUBST([ac_ct_AR], ["/usr/bin/libtool"])
#fi
#############################################################################
## Dead code stripping for compilers. Linkers are towards the end of script.
## We have to use XXX_LINK_IFELSE because some compilers don't reject
## -fdata-sections or -ffunction-sections like they should.
if true; then
## Save FLAGS
SAVED_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="-fdata-sections"
AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS])
XXX_LINK_IFELSE(
[AC_LANG_SOURCE([[int main() { return 0; }]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]
)
if test "$retval" = "0"; then
AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
fi
CXXFLAGS="-ffunction-sections"
AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS])
XXX_LINK_IFELSE(
[AC_LANG_SOURCE([[int main() { return 0; }]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]
)
if test "$retval" = "0"; then
AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
fi
## Restore FLAGS
CXXFLAGS="$SAVED_CXXFLAGS"
fi
#############################################################################
## Solaris, GCC and -Wa,--divide
if test "$IS_SUN_OS" != "0"; then
## Save CXXFLAGS
SAVED_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="-Wa,--divide"
AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS])
XXX_LINK_IFELSE(
[AC_LANG_SOURCE([[int main() { return 0; }]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]
)
if test "$retval" = "0"; then
AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
fi
## Restore CXXFLAGS
CXXFLAGS="$SAVED_CXXFLAGS"
fi
#############################################################################
## Solaris, SunCC compiler options
if test "$IS_SUN_OS" != "0"; then
## Save CXXFLAGS
SAVED_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="-template=no%extdef"
AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS])
XXX_COMPILE_IFELSE(
[AC_LANG_SOURCE([[int main() { return 0; }]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]
)
if test "$retval" = "0"; then
AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
fi
# https://docs.oracle.com/cd/E18659_01/html/821-1383/bkamt.html
CXXFLAGS="-xregs=no%appl"
AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS])
XXX_COMPILE_IFELSE(
[AC_LANG_SOURCE([[int main() { return 0; }]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]
)
if test "$retval" = "0"; then
AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
fi
## Restore CXXFLAGS
CXXFLAGS="$SAVED_CXXFLAGS"
fi
#############################################################################
## AIX and -qpic=large or -bbigtoc
if test "$IS_AIX" != "0"; then
## Save LDFLAGS
SAVED_LDFLAGS="$LDFLAGS"
# https://www.ibm.com/developerworks/rational/library/overview-toc-aix/index.html
LDFLAGS="-bbigtoc"
AC_MSG_CHECKING([if $LDNAME supports $LDFLAGS])
XXX_LINK_IFELSE(
[AC_LANG_SOURCE([[int main() { return 0; }]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]
)
if test "$retval" = "0"; then
AM_LDFLAGS="$AM_LDFLAGS $LDFLAGS"
fi
## Restore LDFLAGS
LDFLAGS="$SAVED_LDFLAGS"
fi
#############################################################################
## MacPorts GCC using Clang integrated assembler
## Modern GCC must use Clang as the assembler. The old Apple
## assembler cannot handle much more than SSE4 or so. We need
## to use -Wa,-q in subsequent tests, if available.
if test "$IS_APPLE_OS" != "0"; then
if test "$IS_GCC_COMPILER" != "0" && test "$IS_PORTS_COMPILER" != "0"; then
HAVE_OPT=`echo $CXXFLAGS | $EGREP -i -c '\-Wa,-q'`
if test "$HAVE_OPT" = "0"; then
## Save CXXFLAGS
SAVED_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="-Wa,-q"
AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS])
XXX_COMPILE_IFELSE(
[AC_LANG_SOURCE([[int main() { return 0; }]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]
)
# We can add -Wa,-q to all files, if needed
if test "$retval" = "0"; then
# AM_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
WAQ_FLAG="-Wa,-q"
fi
## Restore CXXFLAGS
CXXFLAGS="$SAVED_CXXFLAGS"
fi
fi
fi
#############################################################################
## Clang integrated assembler and SunCC.
## Also see https://bugs.llvm.org/show_bug.cgi?id=39895.
if test "$IS_X86" = "1" && test "x$enable_asm" != "xno"; then
## Save CXXFLAGS
SAVED_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="-msse2 $WAQ_FLAG"
AC_MSG_CHECKING([if $CXXNAME supports mixed ASM])
XXX_COMPILE_IFELSE(
[AC_LANG_SOURCE([`cat TestPrograms/test_asm_mixed.cpp`])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]
)
if test "$retval" != "0"; then
AC_DEFINE([CRYPTOPP_DISABLE_MIXED_ASM], [1], [Disable mixed asm])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_MIXED_ASM"
fi
## Restore CXXFLAGS
CXXFLAGS="$SAVED_CXXFLAGS"
fi
#############################################################################
## IA-32, i386, i586, i686, x86_64, etc.
## This block handles GCC and friends, including -Wa,-q if needed.
## i86pc and SunCC is handled after this block.
if test "$IS_X86" = "1" && test "$IS_GNUC_COMPILER" = "1"; then
## Save CXXFLAGS
SAVED_CXXFLAGS="$CXXFLAGS"
##### SSE2 #####
if test x"$WAQ_FLAG" != "x"; then
CXXFLAGS="-msse2 $WAQ_FLAG"
else
CXXFLAGS="-msse2"
fi
AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS])
XXX_COMPILE_IFELSE(
[AC_LANG_SOURCE([`cat TestPrograms/test_x86_sse2.cpp`])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]
)
if test "$retval" = "0"; then
AC_SUBST([CRYPTOPP_SSE2_FLAG], [$CXXFLAGS])
AC_SUBST([CRYPTOPP_CHACHA_FLAG], [$CXXFLAGS])
AC_SUBST([CRYPTOPP_DONNA_FLAG], [$CXXFLAGS])
AC_DEFINE([CRYPTOPP_SSE2_AVAILABLE], [1], [Enable SSE2])
else
AC_DEFINE([CRYPTOPP_DISABLE_ASM], [1], [Disable SSE2])
AM_CPPFLAGS="$AM_CPPFLAGS -DCRYPTOPP_DISABLE_ASM"
fi
##### SSE3 #####
if test x"$WAQ_FLAG" != "x"; then
CXXFLAGS="-msse3 $WAQ_FLAG"
else
CXXFLAGS="-msse3"
fi
AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS])
XXX_COMPILE_IFELSE(
[AC_LANG_SOURCE([`cat TestPrograms/test_x86_sse3.cpp`])],