-
Notifications
You must be signed in to change notification settings - Fork 14
/
configure.ac
2057 lines (1922 loc) · 61.5 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
# This file is part of the eix project and distributed under the
# terms of the GNU General Public License v2.
#
# Copyright (c)
# Wolfgang Frisch <[email protected]>
# Emil Beinroth <[email protected]>
# Martin V\"ath <[email protected]>
dnl The formatting convention used in this file is the following:
dnl
dnl After/before braces no space/newline is added (exception is for C++-code
dnl which always starts and ends with a newline and indent level 0;
dnl also an exception is of course where the space is needed, e.g. in
dnl AC_DEFINE* to get proper comments).
dnl Indents are done by tabs: Each indent level is one tab.
dnl
dnl Macro calls always start with an opening brace; possibly we just use ().
dnl All macro arguments are quoted, no matter whether it is necessary or not.
dnl (Local)/global sh variables are (non-)/capital.
dnl All strings are quoted in " " (even if ' ' could be used or is easier).
dnl
dnl We use M4SH instead of sh, i.e. no "if", "case", "&&", "||" from the sh
dnl but only the M4SH equivalents - this avoids some unexpected troubles.
dnl
dnl After the first macro arg, we start a new line and increase the
dnl indent level; all further args also start in a new line after the comma.
dnl Exception is the AS_CASE macro where value and action are on the same line,
dnl separated only with a space (and the indent level is increased for the
dnl action if it needs more than one line).
dnl Similar exceptions are macros where the arguments are closely connected
dnl (like calls of most MV_* macros).
dnl
dnl Commas and closing braces are appended without leading space or newlines;
dnl in particular, no extra space is used even if several indent levels are
dnl closed. Of course, closing braces influence the indent level appropriately.
dnl In other words: For closing braces, we use lisp-type conventions.
dnl
dnl There are two exceptions of these rules:
dnl 1. If an argument has many items (like AC_CONFIG_FILES),
dnl each item is listed in a separate line with indent level increased;
dnl in such a case the opening/closing braces are isolated.
dnl 2. The AC_INIT macro must be in one line since it is parsed by
dnl primitive scripts.
AC_INIT([eix], [0.36.9], [https://github.com/vaeth/eix/issues/], [eix], [https://github.com/vaeth/eix/])
AC_PREREQ([2.64])
m4_ifdef([AC_CONFIG_MACRO_DIR],
[AC_CONFIG_MACRO_DIR([m4])])
m4_ifdef([AC_CONFIG_MACRO_DIRS],
[AC_CONFIG_MACRO_DIRS([m4 martinm4])])
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_FILES([
Makefile
manpage/Makefile
src/Makefile
doc/Makefile
po/Makefile.in
zsh/Makefile
])
AC_CONFIG_HEADERS([config.h])
AC_CANONICAL_TARGET()
AM_MAINTAINER_MODE()
AM_INIT_AUTOMAKE([no-dependencies])
# disable --disable-silent-rules to omit useless output with Gentoo's EAPI=5:
# AS_VAR_SET([enable_silent_rules], [yes])
AM_SILENT_RULES([yes])
AC_LANG([C++])
AC_PROG_CXX()
# jumbo build?
AC_MSG_CHECKING([whether jumbo build should be used])
AC_ARG_ENABLE([jumbo_build],
[AS_HELP_STRING([--disable-jumbo-build],
[disable jumbo build for low memory systems])],
[MV_ENABLE([jumbo-build])],
[AS_VAR_SET([jumbo_build], [true])])
AM_CONDITIONAL([JUMBO_BUILD],
[$jumbo_build])
AS_IF([$jumbo_build],
[AC_DEFINE([JUMBO_BUILD],
[1],
[Define if jumbo build is wanted])])
MV_MSG_RESULT_BIN([$jumbo_build])
# Now our flag mangling options:
AC_ARG_ENABLE([debugging],
[AS_HELP_STRING([--enable-debugging],
[activate paranoic asserts and flags for debugging])],
[MV_ENABLE([debugging])
AS_VAR_SET([cmt_debugging], ["on request"])],
[AS_VAR_SET([debugging], [false])
AS_VAR_SET([cmt_debugging], ["default"])])
AC_ARG_ENABLE([paranoic-asserts],
[AS_HELP_STRING([--enable-paranoic-asserts],
[activate paranoic asserts])],
[MV_ENABLE([paranoic_asserts])],
[AS_VAR_SET([paranoic_asserts], [false])])
AS_IF([$debugging],
[AS_VAR_SET([paranoic_asserts], [true])])
AC_ARG_ENABLE([debug-format],
[AS_HELP_STRING([--enable-debug-format],
[activate string format runtime tests])],
[MV_ENABLE([debug_format])
AS_VAR_SET([cmt_debug_format], ["on request"])],
[AS_IF([$debugging],
[AS_VAR_SET([debug_format], [true])
AS_VAR_SET([cmt_debug_format], ["default due to debugging"])],
[AS_VAR_SET([debug_format], [true])
AS_VAR_SET([cmt_debug_format], ["default"])])])
AC_ARG_ENABLE([new-dialect],
[AS_HELP_STRING([--enable-new-dialect],
[enable most current C++ dialect; provides optimizations])],
[MV_ENABLE([new_dialect])
AS_VAR_SET([cmt_new_dialect], ["on request"])],
[AS_VAR_SET([new_dialect], [:])
AS_VAR_SET([cmt_new_dialect], ["default"])])
AC_ARG_ENABLE([dead-code],
[AS_HELP_STRING([--disable-dead-code-eliminitation],
[disable dead code elimination options; disable this only if compilation fails])],
[MV_ENABLE([dead_code])
AS_VAR_SET([cmt_dead_code], ["on request"])],
[AS_VAR_SET([dead_code], [:])
AS_VAR_SET([cmt_dead_code], ["default"])])
AC_ARG_ENABLE([security],
[AS_HELP_STRING([--enable-security],
[append security relevant options to flags])],
[MV_ENABLE([security])
AS_VAR_SET([cmt_security], ["on request"])],
[AS_VAR_SET([security], [false])
AS_VAR_SET([cmt_security], ["default"])])
AC_ARG_ENABLE([strong-security],
[AS_HELP_STRING([--enable-strong-security],
[append paranoic security options to flags; slowdown])],
[MV_ENABLE([strong-security])
AS_VAR_SET([cmt_strong_security], ["on request"])],
[AS_VAR_SET([strong_security], [false])
AS_VAR_SET([cmt_strong_security], ["default"])])
AC_ARG_ENABLE([nopie-security],
[AS_HELP_STRING([--enable-nopie-security],
[as --enable-strong-security but avoid pie to make sanitizer work])],
[MV_ENABLE([nopie-security])
AS_VAR_SET([cmt_nopie_security], ["on request"])],
[AS_VAR_SET([nopie_security], [false])
AS_VAR_SET([cmt_nopie_security], ["default"])])
AC_ARG_ENABLE([optimization],
[AS_HELP_STRING([--enable-optimization],
[append optimization flags])],
[MV_ENABLE([optimization])
AS_VAR_SET([cmt_optimization], ["on request"])],
[AS_VAR_SET([optimization], [false])
AS_VAR_SET([cmt_optimization], ["default"])])
AC_ARG_ENABLE([strong_optimization],
[AS_HELP_STRING([--enable-strong-optimization],
[use also optimization flags which might not work on broken compilers])],
[MV_ENABLE([strong-optimization])
AS_VAR_SET([cmt_strong_optimization], ["on request"])],
[AS_VAR_SET([strong_optimization], [false])
AS_VAR_SET([cmt_strong_optimization], ["default"])])
AC_ARG_ENABLE([warnings],
[AS_HELP_STRING([--enable-warnings],
[append warning/testing flags; might produce worse code])],
[MV_ENABLE([warnings])
AS_VAR_SET([cmt_warnings], ["on request"])],
[AS_VAR_SET([warnings], [false])
AS_VAR_SET([cmt_warnings], ["default"])])
AC_ARG_ENABLE([strong_warnings],
[AS_HELP_STRING([--enable-strong-warnings],
[append flags to get lots of mostly unimportant warnings])],
[MV_ENABLE([strong-warnings])
AS_VAR_SET([cmt_strong_warnings], ["on request"])],
[AS_VAR_SET([strong_warnings], [false])
AS_VAR_SET([cmt_strong_warnings], ["default"])])
# Some implicit dependencies of these options.
# We do this here explicitly and output the results
AC_MSG_CHECKING([whether debugging asserts/flags should be used])
MV_MSG_RESULT_BIN([$debugging], [$cmt_debugging])
AC_MSG_CHECKING([whether strong optimization options should be used])
AS_IF([$paranoic_asserts],
[AS_VAR_SET([strong_optimization], [false])
AS_VAR_SET([cmt_strong_optimization], ["disabled by paranoic asserts"])])
MV_MSG_RESULT_BIN([$strong_optimization], [$cmt_strong_optimization])
AC_MSG_CHECKING([whether optimization options should be used])
AS_IF([$strong_optimization],
[AS_VAR_SET([optimization], [:])
AS_VAR_SET([cmt_optimization], ["forced by strong optimization"])])
AS_IF([$debugging],
[AS_VAR_SET([optimization], [false])
AS_VAR_SET([cmt_optimization], ["disabled by debugging"])])
MV_MSG_RESULT_BIN([$optimization], [$cmt_optimization])
AC_MSG_CHECKING([whether dead code elimination options should be used])
AS_IF([$debugging],
[AS_VAR_SET([dead_code], [false])
AS_VAR_SET([cmt_dead_code], ["disabled by debugging"])])
MV_MSG_RESULT_BIN([$dead_code], [$cmt_dead_code])
AC_MSG_CHECKING([whether most current C++ dialect options should be used])
AS_IF([$optimization],
[AS_VAR_SET([new_dialect], [:])
AS_VAR_SET([cmt_new_dialect], ["forced by optimization"])])
MV_MSG_RESULT_BIN([$new_dialect], [$cmt_new_dialect])
AC_MSG_CHECKING([whether strong warning options should be used])
MV_MSG_RESULT_BIN([$strong_warnings], [$cmt_strong_warnings])
AC_MSG_CHECKING([whether warning options should be used])
AS_IF([$strong_warnings],
[AS_VAR_SET([warnings], [:])
AS_VAR_SET([cmt_warnings], ["forced by strong warnings"])])
MV_MSG_RESULT_BIN([$warnings], [$cmt_warnings])
AC_MSG_CHECKING([whether nopie security options should be used])
MV_MSG_RESULT_BIN([$nopie_security], [$cmt_nopie_security])
AC_MSG_CHECKING([whether strong security options should be used])
AS_IF([$nopie_security],
[AS_VAR_SET([strong_security], [:])
AS_VAR_SET([cmt_strong_security], ["forced by nopie security"])])
MV_MSG_RESULT_BIN([$strong_security], [$cmt_strong_security])
AC_MSG_CHECKING([whether security options should be used])
AS_IF([$strong_security],
[AS_VAR_SET([security], [:])
AS_VAR_SET([cmt_security], ["forced by strong security"])])
MV_MSG_RESULT_BIN([$security], [$cmt_security])
# Now start the flag mangling:
AS_IF([$debugging],
[AS_VAR_SET([CFLAGS], [])
AS_VAR_SET([CXXFLAGS], [])
AS_VAR_SET([LDFLAGS], [])])
AS_VAR_COPY([oricxxflags], [CXXFLAGS])
AS_VAR_COPY([orildflags], [LDFLAGS])
# Note that the (potential) resetting of the flags was necessary *before*
# (potentially) modifying flags for system extensions.
# On the other hand, we must check for system extensions before we compile
# test programs to find out the other flags.
AC_USE_SYSTEM_EXTENSIONS()
# Only now the flag mangling can continue:
#
# At first, we must calculate our [fatal-flags] and [mode] arguments
AS_VAR_SET([my_cxxfatal], [])
AS_VAR_SET([my_ldfatal], [])
MV_ADDFLAGS([my_cxxfatal], [CXXFLAGS], [AC_COMPILE_IFELSE], [ \
-Werror \
-Werror=unknown-warning-option \
-Wunknown-warning-option \
])
MV_ADDFLAGS([my_ldfatal], [LDFLAGS], [AC_LINK_IFELSE], [ \
$my_cxxfatal \
-Wl,--fatal-warnings \
])
# Now the actual testing:
AS_VAR_SET([my_cxxadd], [])
AS_VAR_SET([my_ldadd], [])
# Prefer the newest available most fancy C++ dialect to detect problems early
AS_IF([$new_dialect],
[AS_CASE([" $CXXFLAGS $my_cxxadd"],
[*" -std="*], [],
[MV_ADDFLAGS([my_cxxadd], [CXXFLAGS], [MV_RUN_IFELSE_LINK], [ \
-std=gnu++23 \
-std=c++23 \
-std=gnu++2b \
-std=c++2b \
-std=gnu++20 \
-std=c++20 \
-std=gnu++2a \
-std=c++2a \
-std=gnu++17 \
-std=c++17 \
-std=gnu++1z \
-std=c++1z \
-std=gnu++14 \
-std=c++14 \
-std=gnu++1y \
-std=c++1y \
-std=gnu++11 \
-std=c++11 \
], [$my_cxxfatal], [], [break])])])
AS_VAR_COPY([my_cxxdialect], [my_cxxadd])
m4_if([dnl The following turned out not to be useful currently, so it is
dnl commented out. Note that this needs a second part at the end of this file
dnl (also commented out) which modifies the CXXFLAGS correspodingly.
# Use -include config.h if possible to get more hits with ccache
AS_VAR_SET([add_incopt], ["-include config.h"])
AC_MSG_CHECKING([whether CXXFLAGS=$add_incopt can be used])
AS_VAR_COPY([my_cxxflags], [CXXFLAGS])
MV_APPEND([CXXFLAGS], [$my_cxxfatal])
MV_APPEND([CXXFLAGS], [$add_incopt.in])
export CXXFLAGS
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AS_VAR_SET([add_incopt], [])])
AS_VAR_COPY([CXXFLAGS], [my_cxxflags])])
AS_IF([$dead_code],
[AS_VAR_SET([dead_code], [false])
MV_ADDFLAGS([my_ldadd], [LDFLAGS], [MV_RUN_IFELSE_LINK], [ \
-Wl,--gc-sections \
], [$my_ldfatal], [], [AS_VAR_SET([dead_code], [:])])])
AS_IF([$dead_code],
[MV_ADDFLAGS([my_cxxadd], [CXXFLAGS], [MV_RUN_IFELSE_LINK], [ \
-fdata-sections \
-ffunction-sections \
], [$my_cxxfatal], [], [:])])
AS_IF([$debugging],
[MV_ADDFLAGS([my_ldadd], [LDFLAGS], [MV_RUN_IFELSE_LINK], [ \
-g \
-ggdb3 \
], [$my_ldfatal], [], [:])
MV_ADDFLAGS([my_cxxadd], [CXXFLAGS], [MV_RUN_IFELSE_LINK], [ \
-g \
-ggdb3 \
], [$my_cxxfatal], [], [:])])
AS_IF([$optimization],
[MV_ADDFLAGS([my_cxxadd], [CXXFLAGS], [MV_RUN_IFELSE_LINK], [ \
-O2 \
-fomit-frame-pointer \
-fno-common \
-fstrict-aliasing \
-fstrict-enums \
-fmerge-all-constants \
-finline-functions \
-fvisibility=hidden \
-fvisibility-inlines-hidden \
-ftree-pre \
-ftree-partial-pre \
-fnothrow-opt \
-fno-unwind-tables \
-fno-asynchronous-unwind-tables \
-ffast-math \
-fno-math-errno \
-frename-registers \
-funsafe-loop-optimizations \
-fgcse-sm \
-fgcse-las \
-fgcse-after-reload \
-fpredictive-commoning \
-ftree-switch-conversion \
-fno-ident \
-freorder-functions \
-fdevirtualize-speculatively \
-fdevirtualize-at-ltrans \
-fno-semantic-interposition \
-fira-loop-pressure \
-ftree-loop-distribution \
-ftree-loop-distribute-patterns \
-ftree-loop-im \
-fivopts \
-fdelete-null-pointer-checks \
], [$my_cxxfatal], [], [:])
MV_ADDFLAGS([my_ldadd], [LDFLAGS], [MV_RUN_IFELSE_FALSE], [ \
-Wl,-O1 \
-Wl,--relax \
-Wl,--as-needed \
-Wl,--sort-common \
-Wl,-z,combreloc \
-Wl,--build-id=none \
], [$my_ldfatal], [], [:])])
AS_IF([$strong_optimization],
[AS_VAR_SET([flto], ["
-flto \
-flto-partition=none \
-flto-odr-type-merging \
"])
# -use-linker-plugin \
# -emit-llvm \
# We first modify the LDFLAGS: This is important because of -flto:
# Without -flto in LDFLAGS, -flto in CXXFLAGS might not fail even if it
# should produce broken code.
MV_ADDFLAGS([my_ldadd], [LDFLAGS], [MV_RUN_IFELSE_FALSE], [ \
-Wl,-O9 \
$flto \
-fwhole-program \
-Wl,-z,noexecstack \
], [$my_ldfatal], [], [:])
dnl The following is never tried, since the run can succeed but the result
dnl may fail for some unknown reason on non-GNU systems, see
dnl https://bugs.gentoo.org/show_bug.cgi?id=293263
dnl -Wl,--hash-style=gnu \
dnl -Wl,--enable-new-dtags \
MV_ADDFLAGS([my_cxxadd], [CXXFLAGS], [MV_RUN_IFELSE_FALSE], [ \
$flto \
], [$my_cxxfatal], [], [:])])
# If -flto is used during compilation, we can also use -fwhole-program and
# -fno-fat-lto-objects during compilation and should specify -flto during
# linking.
# However, -Wl,--warn-common will then give lots of warnings, so we
# do not add the latter unless we use strong_warnings.
AS_VAR_SET([fwhole_program], [])
AS_VAR_SET([warn_common], [-Wl,--warn-common])
AS_CASE([" $CXXFLAGS $my_cxxadd "],
[*" -flto "*],
[AS_VAR_SET([fwhole_program], ["
-fwhole-program
-fno-fat-lto-objects
"])
AS_IF([$strong_warnings],
[],
[AS_VAR_SET([warn_common], [])])])
AS_IF([$strong_optimization],
[MV_ADDFLAGS([my_cxxadd], [CXXFLAGS], [MV_RUN_IFELSE_FALSE], [ \
-fweb \
-fno-enforce-eh-specs \
$fwhole_program \
-ftree-vectorize \
-fvect-cost-model \
-fno-threadsafe-statics \
], [$my_cxxfatal], [$CPPFLAGS], [:])
dnl We do not use graphite flags since they breaks in too many compilers:
dnl -fgraphite \
dnl -fgraphite-identity \
dnl -floop-interchange \
dnl -floop-strip-mine \
dnl -floop-block \
dnl -floop-next-optimize \
dnl -floop-unroll-and-jam \
dnl -fno-rtti is incompatible with protobuf:
dnl -fno-rtti \
AS_IF([$strong_security],
[],
[MV_ADDFLAGS([my_cxxadd], [CXXFLAGS], [MV_RUN_IFELSE_LINK], [ \
-DNDEBUG \
-DNO_DEBUG \
-DG_DISABLE_ASSERT \
], [$my_cxxfatal], [$CPPFLAGS], [:])])])
dnl We do not use:
dnl Too much memory/time for compilation:
dnl -fipa-pta
dnl Default (e.g. with -O2):
dnl -fipa-icf
dnl -fipa-ra
AS_IF([$warnings],
dnl -Wzero-as-null-pointer-constant makes sense only with new dialects
[AS_VAR_SET([zero_as_null_pointer], [-Wzero-as-null-pointer-constant])
AS_CASE([" $CXXFLAGS "],
[*" -std=c++"??" "*], [],
[*" -std=gnu++"??" "*], [],
[AS_VAR_SET([zero_as_null_pointer], [])])
MV_ADDFLAGS([my_cxxadd], [CXXFLAGS], [AC_COMPILE_IFELSE], [ \
-fno-common \
-funsigned-char \
-ftracer \
-fconcepts \
], [$my_cxxfatal], [$CPPFLAGS], [:])
MV_ADDFLAGS([my_cxxadd], [CXXFLAGS], [AC_COMPILE_IFELSE], [ \
-Wpedantic \
-pedantic \
-Wall \
-Wextra \
-Wformat=2 \
-Wunused \
-Wunused-variable \
-Wunused-parameter \
-Winit-self \
-Wmissing-include-dirs \
-Wswitch-default \
-Wstrict-aliasing=1 \
-Wstrict-overflow \
-Wfloat-equal \
-Wundef \
-Wshadow \
-Wpointer-arith \
-Wcast-qual \
-Wwrite-strings \
-Wsign-compare \
-Wmissing-field-initializers \
-Wnormalized=nfkc \
-Wpacked \
-Wredundant-decls \
-Winvalid-pch \
-Wvolatile-register-var \
-Wdisabled-optimization \
-Wlogical-op \
-Wvla \
-Wabi \
-Wctor-dtor-privacy \
-Wstrict-null-sentinel \
-Wstring-plus-int \
-Woverloaded-virtual \
-Wsign-promo \
-Wnoexcept \
-Wmissing-declarations \
-Wmissing-format-attribute \
-Wunused-but-set-variable \
-Wunused-but-set-parameter \
-Wsuggest-attribute=pure \
-Wsuggest-attribute=const \
-Wsuggest-attribute=noreturn \
-Wsuggest-attribute=malloc \
-Wsuggest-attribute=cold \
-Wsuggest-final-type \
-Wsuggest-final-methods \
-Wsuggest-override \
-Wdelete-non-virtual-dtor \
$zero_as_null_pointer \
-Wint-to-pointer-cast \
-Wcomment \
-WNSObject-attribute \
-fdiagnostic-color=always \
-Wswitch-bool \
-Wlogical-not-parantheses \
-Wsizeof-array-argument \
-Walloc-zero \
-Wbool-compare \
-Wbool-operation \
-Wodr-type-mismatch \
-Wshift-negative-value \
-Wshift-overflow \
-Wshift-overflow=2 \
-Wnull-dereference \
-Wduplicated-branches \
-Wduplicated-cond \
-Wstringop-truncation \
-Wctad-maybe-unsupported \
], [$my_cxxfatal], [], [:])
MV_ADDFLAGS([my_cxxadd], [CXXFLAGS], [AC_COMPILE_IFELSE], [ \
-Wcast-align=strict \
-Wcast-align \
], [$my_cxxfatal], [$CPPFLAGS], [break])
dnl We do not use:
dnl Not needed anymore with current clang:
dnl -Wno-unknown-warning-option \
dnl Output is too confusing:
dnl -fmem-report \
dnl Too many useless warnings or only for C:
dnl -Weverything \
dnl -Wtraditional \
dnl -Wc++-compat \
dnl -Wstrict-prototypes \
dnl -Wold-style-definition \
dnl -Wmissing-prototypes \
dnl -Wnested-externs \
dnl -Wpointer-sign \
dnl Included in -Wall (in gcc-6; not available earlier, anyway)
dnl -Wtautological-compare \
dnl -Wmisleading-indentation \
dnl
MV_ADDFLAGS([my_ldadd], [LDFLAGS], [MV_RUN_IFELSE_FALSE], [ \
-Wl,-z,defs \
-Wl,--no-undefined \
-Wl,--no-allow-shlib-undefined \
-Wl,--no-undefined-version \
$warn_common \
], [$my_cxxfatal], [], [:])])
AS_IF([$strong_warnings],
[MV_ADDFLAGS([my_cxxadd], [CXXFLAGS], [AC_COMPILE_IFELSE], [ \
-Wsign-conversion \
-Wold-style-cast \
-Wmissing-noreturn \
], [], [], [:])])
dnl We do not use (since it gives too many useless warnings or is only for C):
dnl -Wconversion \
dnl -Wswitch-enum \
dnl -Wunsafe-loop-optimizations \
dnl -Wpadded \
dnl -Wunreachable-code \
dnl -Waggregate-return \
dnl -Winline \
dnl -Weffc++ \
AS_IF([$strong_security],
[AS_VAR_SET([my_stackprotector], ["
-fstack-protector-all
-fstack-protector-strong
-fstack-protector
"])],
[AS_VAR_SET([my_stackprotector], ["
-fstack-protector-strong
-fstack-protector
-fstack-protector-all
"])])
AS_IF([$security],
# We try to add -fstack-protector to LDFLAGS before adding to CXXFLAGS
# since on some systems it requires also linking with a library.
[AS_IF([$nopie_security], [],
[MV_ADDFLAGS([my_cxxadd], [CXXFLAGS], [AC_COMPILE_IFELSE], [ \
-fPIE \
], [$my_cxxfatal], [$CPPFLAGS], [:])
MV_ADDFLAGS([my_ldadd], [LDFLAGS], [MV_RUN_IFELSE_LINK], [ \
-fPIE \
], [$my_ldfatal], [], [:])
MV_ADDFLAGS([my_cxxadd], [CXXFLAGS], [AC_COMPILE_IFELSE], [ \
-pie \
], [$my_cxxfatal], [$CPPFLAGS], [:])
MV_ADDFLAGS([my_ldadd], [LDFLAGS], [MV_RUN_IFELSE_LINK], [ \
-pie \
], [$my_ldfatal], [], [:])])
MV_ADDFLAGS([my_ldadd], [LDFLAGS], [MV_RUN_IFELSE_LINK], [ \
-Wl,-z,retpolineplt \
-Wl,-z,now \
-Wl,-z,relro \
-Wl,-z,noexecstack \
], [$my_ldfatal], [], [:])
MV_ADDFLAGS([my_ldadd], [LDFLAGS], [MV_RUN_IFELSE_LINK], [ \
$my_stackprotector \
], [$my_ldfatal], [], [break])
AS_VAR_SET([my_stackclash], ["
-fstack-clash-protection
-fstack-check=specific
-fstack-check
"])
MV_ADDFLAGS([my_ldadd], [LDFLAGS], [MV_RUN_IFELSE_LINK], [ \
$my_stackclash \
], [$my_ldfatal], [], [break])
MV_ADDFLAGS([my_cxxadd], [CXXFLAGS], [MV_RUN_IFELSE_LINK], [ \
$my_stackclash \
], [$my_cxxfatal], [$CPPFLAGS], [break])
MV_ADDFLAGS([my_cxxadd], [CXXFLAGS], [MV_RUN_IFELSE_LINK], [ \
-mretpoline \
-mcet \
-fcf-protection=full \
-fstack-clash-protection \
-D_FORTIFY_SOURCE=2 \
], [$my_cxxfatal], [$CPPFLAGS], [:])])
# -fno-plt # breaks with clang; no proper check known
# -mindirect-branch=thunk # breaks with cygwin; no proper check known
# -mfunction-return=thunk # breaks with cygwin; no proper check known
AS_IF([$strong_security],
# We try to add -fsanitize=... to LDFLAGS before adding to CXXFLAGS
# since on some systems it requires also linking with a library.
[AS_VAR_SET([my_sanitize], ["
-faddress-sanitizer
-fsanitize=undefined
-fsanitize=vla-bound
-fsanitize=unreachable
-fsanitize=null
-fsanitize=return
-fsanitize=float-divide-by-zero
-fsanitize=bounds
-fsanitize=bounds-strict
-fsanitize=alignment
-fsanitize=pointer-compare
-fsanitize=pointer-subtract
"])
# The following -fsanitize do not work properly
# -fsanitize=address
# -fsanitize=leak
# -fsanitize=shift
# -fsanitize=signed-integer-overflow
# -fsanitize=integer-divide-by-zero
# -fsanitize=float-cast-overflow
# -fsanitize=object-size
# -fsanitize=threads
# -fsanitize=vptr
# The following are no longer supported with gcc-9.0
# -mmpx
# -fcheck-pointer-bounds
# -Wchkp
MV_ADDFLAGS([my_ldadd], [LDFLAGS], [MV_RUN_IFELSE_LINK], [ \
$my_sanitize \
], [$my_ldfatal], [], [:])
MV_ADDFLAGS([my_cxxadd], [CXXFLAGS], [MV_RUN_IFELSE_LINK], [ \
$my_sanitize \
], [$my_cxxfatal], [$CPPFLAGS], [:])])
# We are done with testing, the real flag mangling takes place:
AS_VAR_COPY([CXXFLAGS], [oricxxflags])
MV_PREPEND([CXXFLAGS], [$my_cxxadd])
AS_VAR_COPY([LDFLAGS], [orildflags])
AS_CASE([" $LDFLAGS $my_ldadd "],
[*" -flto "*], [MV_APPEND([my_ldadd], [$CXXFLAGS])])
MV_PREPEND([LDFLAGS], [$my_ldadd])
AS_VAR_COPY([my_cxxflags], [CXXFLAGS])
AS_VAR_COPY([my_ldflags], [LDFLAGS])
# Provide external tools
AC_PROG_LN_S()
AC_PROG_MKDIR_P()
AC_PROG_SED()
# Add the libintl support if needed.
dnl LT_INIT()
AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.6])
AM_GNU_GETTEXT([external])
AS_CASE([$USE_NLS],
[yes],
[AS_VAR_SET([using_nls], [:])
AS_VAR_SET([INST_MAN_LINGUAS], [${LINGUAS-*}])],
[AS_VAR_SET([using_nls], [false])
AS_VAR_SET([INST_MAN_LINGUAS], [])])
AM_CONDITIONAL([USING_NLS],
[$using_nls])
AC_SUBST([INST_MAN_LINGUAS])
# This must be an early test, since we need the null device later in this file:
AC_MSG_CHECKING([for null-device])
AC_ARG_WITH([dev-null],
[AS_HELP_STRING([--with-dev-null=STR],
[null device of the system, usually /dev/null])],
[AS_VAR_COPY([DEV_NULL], [withval])],
[AS_VAR_SET([DEV_NULL], [])])
AS_VAR_IF([DEV_NULL], [],
[AS_VAR_SET([DEV_NULL], [/dev/null])])
MV_MSG_RESULT_VAR([DEV_NULL])
AC_DEFINE_UNQUOTED([DEV_NULL],
["$DEV_NULL"],
[Null device of the system])
AC_SUBST([DEV_NULL])
# Separate binaries?
AC_ARG_ENABLE([separate_binaries],
[AS_HELP_STRING([--enable-separate-binaries],
[create a separate binary for each of eix, eix-update, eix-diff])],
[MV_ENABLE([separate_binaries])],
[AS_VAR_SET([separate_binaries], [false])])
AM_CONDITIONAL([SEPARATE_BINARIES],
[$separate_binaries])
# Separate eix-update?
AC_ARG_ENABLE([separate_update],
[AS_HELP_STRING([--enable-separate-update],
[create a separate eix-update binary])],
[MV_ENABLE([separate-update])],
[AS_VAR_SET([separate_update], [false])])
AS_IF([$separate_binaries],
[AS_VAR_SET([separate_update], [:])])
AM_CONDITIONAL([SEPARATE_UPDATE],
[$separate_update])
# Separate tools?
AC_ARG_ENABLE([separate_tools],
[AS_HELP_STRING([--enable-separate-tools],
[create separate binaries for versionsort, eix-drop-permissions])],
[MV_ENABLE([separate-tools])],
[AS_VAR_SET([separate_tools], [false])])
AM_CONDITIONAL([SEPARATE_TOOLS],
[$separate_tools])
# Look for basic functions:
AC_SYS_LARGEFILE()
AC_FUNC_FSEEKO()
AC_CHECK_FUNCS([regcomp strchr strerror strrchr fnmatch memset],
[],
[AC_MSG_ERROR([We really need this function ..])])
# We need at least one of the following, the former the better
AC_CHECK_FUNCS([strtoull strtoul],
[break],
[:])
AC_CHECK_FUNCS([strtoll strtol atoi],
[break],
[AC_MSG_ERROR([At least one of stroll/strtol/atoi is needed ..])])
# Optional header files:
AC_CHECK_HEADERS([sys/param.h \
termios.h \
stropts.h \
sys/file.h \
sys/ioctl.h \
sys/stream.h \
sys/ptem.h \
sys/tty.h \
sys/pty.h \
grp.h \
interix/security.h \
])
# We use these optionally:
# Workarounds are used if they are not available
AC_CHECK_FUNCS([ \
fileno \
flock \
sigaction \
canonicalize_file_name \
realpath \
vfork \
setenv \
setuid \
setgid \
seteuid \
setegid \
setuser \
setgroups \
initgroups \
])
AC_DEFUN([SETGETXPROGRAM], [AC_LANG_PROGRAM([[
#include <unistd.h>
#include <sys/types.h>
#ifdef HAVE_INTERIX_SECURITY_H
#include <interix/security.h>
#endif
#ifdef HAVE_GRP_H
#include <grp.h>
#endif
$1
]], [[
$2
]])])
AC_DEFUN([PROTO_SETGETX],
[AC_MSG_CHECKING([whether $1 prototype works])
AC_LINK_IFELSE([SETGETXPROGRAM([], [$2;])],
[MV_MSG_RESULT([yes])],
[AC_LINK_IFELSE([SETGETXPROGRAM([$3], [$2;])],
[MV_MSG_RESULT([no, but can be provided])
$4],
[MV_MSG_RESULT([no and cannot be provided])
$5])])])
AC_DEFUN([PROTO_SETX],
[PROTO_SETGETX([$1], [$1(0)], [$2], [$3], [$4])])
AC_DEFUN([PROTO_GETX],
[PROTO_SETGETX([$1], [return($1() == 0)], [$2], [$3], [$4])])
PROTO_SETX([setuid], [
int setuid(uid_t uid);
],
[AC_DEFINE([NEED_SETUID_PROTO],
[1],
[Define if setuid needs a prototype])],
[AC_DEFINE([BROKEN_SETUID],
[1],
[Define if setuid is broken])])
PROTO_SETX([seteuid], [
int seteuid(uid_t uid);
],
[AC_DEFINE([NEED_SETEUID_PROTO],
[1],
[Define if seteuid needs a prototype])],
[AC_DEFINE([BROKEN_SETEUID],
[1],
[Define if seteuid is broken])])
PROTO_SETX([setgid], [
int setgid(gid_t gid);
],
[AC_DEFINE([NEED_SETGID_PROTO],
[1],
[Define if setgid needs a prototype])],
[AC_DEFINE([BROKEN_SETGID],
[1],
[Define if setgid is broken])])
PROTO_SETX([setegid], [
int setegid(gid_t gid);
],
[AC_DEFINE([NEED_SETEGID_PROTO],
[1],
[Define if setegid needs a prototype])],
[AC_DEFINE([BROKEN_SETEGID],
[1],
[Define if setegid is broken])])
PROTO_GETX([getuid], [
uid_t getuid();
],
[AC_DEFINE([NEED_GETUID_PROTO],
[1],
[Define if getuid needs a prototype])],
[AC_DEFINE([BROKEN_GETUID],
[1],
[Define if getuid is broken])])
PROTO_GETX([geteuid], [
uid_t geteuid();
],
[AC_DEFINE([NEED_GETEUID_PROTO],
[1],
[Define if geteuid needs a prototype])],
[AC_DEFINE([BROKEN_GETEUID],
[1],
[Define if geteuid is broken])])
PROTO_GETX([getgid], [
gid_t getgid();
],
[AC_DEFINE([NEED_GETGID_PROTO],
[1],
[Define if getgid needs a prototype])],
[AC_DEFINE([BROKEN_GETGID],
[1],
[Define if getgid is broken])])
PROTO_GETX([getegid], [
git_t getegid();
],
[AC_DEFINE([NEED_GETEGID_PROTO],
[1],
[Define if getegid needs a prototype])],
[AC_DEFINE([BROKEN_GETEGID],
[1],
[Define if getegid is broken])])
# If climits exists, we need not check for limits.h
AC_CHECK_HEADERS([climits limits.h],
[break])
# If tr1/cstdint exists we need not check for stdint.h.
AC_CHECK_HEADERS([tr1/cstdint cstdint stdint.h],
[break])
# Use extra-doc?
AC_ARG_WITH([extra-doc],
[AS_HELP_STRING([--with-extra-doc],
[install developer documentation. Might need rst2html.py from docutils])],
[AS_CASE(["$withval"],
[no], [AS_VAR_SET([extra_doc], [false])],
[AS_VAR_SET([extra_doc], [:])])],
[AS_VAR_SET([extra_doc], [false])])
AM_CONDITIONAL([EXTRA_DOC], [$extra_doc])
# Use paranoic asserts?
AC_MSG_CHECKING([whether paranoic asserts are used])
AS_IF([$paranoicassert],
[MV_MSG_RESULT([yes])
AC_DEFINE([EIX_PARANOIC_ASSERT],
[1],
[Define if paranoic asserts should be used])
AC_DEFINE([EIX_STATIC_ASSERT],
[1],
[Define if asserts for static initializers should be used])],
[MV_MSG_RESULT([no])])
# Use string format runtime tests?
AC_MSG_CHECKING([whether string format runtime tests are used])
AS_IF([$debug_format],
[MV_MSG_RESULT([yes], [$cmt_debug_format])
AC_DEFINE([EIX_DEBUG_FORMAT],
[1],
[Define if string format runtime tests should be used])],
[MV_MSG_RESULT([no], [$cmt_debug_format])])
# Check if __builtin_expect works
AC_MSG_CHECKING([whether __builtin_expect can be used])
MV_RUN_IFELSE_LINK([AC_LANG_PROGRAM([[]], [[
int zero = 0;
int one = 1;
if(!((__builtin_expect(one, 0)) && (__builtin_expect(one, 1)) &&
(!__builtin_expect(zero, 0)) && (!__builtin_expect(zero, 1))))
return 1;
]])],
[MV_MSG_RESULT([yes])
AS_VAR_SET([bi_expect_works], [:])],
[MV_MSG_RESULT([no])
AS_VAR_SET([bi_expect_works], [false])])
AS_IF([$bi_expect_works],
[AC_DEFINE([HAVE___BUILTIN_EXPECT],
[1],
[Define if __builtin_expect can be used])])
# The __attribute__ tests are special: They should even break on warnings:
AS_VAR_COPY([CXXFLAGS], [oricxxflags])
AS_VAR_COPY([LDFLAGS], [orildflags])
MV_PREPEND([CXXFLAGS], [$my_cxxdialect])
MV_APPEND([CXXFLAGS], [$my_cxxfatal])
MV_APPEND([LDFLAGS], [$my_ldfatal])
# We even switch on explicitly -Wattribute although this should be default:
MV_ADDFLAGS([CXXFLAGS], [CXXFLAGS], [AC_COMPILE_IFELSE], [ \
-Wattributes \
])
# Check if _Pragma("GCC diagnostic ...") can be used inside functions
AC_MSG_CHECKING([whether pragma GCC diagnostic can be used everywhere])
MV_RUN_IFELSE_LINK([AC_LANG_PROGRAM([[
#define GCC_DIAG_STR(s) #s
#define GCC_DIAG_JOINSTR(x, y) GCC_DIAG_STR(x ## y)
#define GCC_DIAG_DO_PRAGMA(x) _Pragma (#x)
#define GCC_DIAG_PRAGMA(x) GCC_DIAG_DO_PRAGMA(GCC diagnostic x)
#define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(push) \
GCC_DIAG_PRAGMA(ignored GCC_DIAG_JOINSTR(-W, x))
#define GCC_DIAG_ON(x) GCC_DIAG_PRAGMA(pop)
]], [[
signed char j(0);
unsigned char i;
GCC_DIAG_OFF(sign-conversion)
i = j;
GCC_DIAG_ON(sign-conversion)
GCC_DIAG_OFF(old-style-cast)
return ((int)i);
GCC_DIAG_ON(old-style-cast)
]])],
[MV_MSG_RESULT([yes])