forked from matrix-construct/construct
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
1954 lines (1652 loc) · 51.8 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
AC_PREREQ(2.63)
AUTOMAKE_OPTIONS = 1.11
AC_INIT([construct], [1.0-dev])
AC_GNU_SOURCE
AC_USE_SYSTEM_EXTENSIONS
AC_PREFIX_DEFAULT([/])
AC_CONFIG_MACRO_DIR([tools/m4])
AC_PATH_PROG(AUTOMAKE, automake)
AC_PATH_PROG(ACLOCAL, aclocal)
AC_PATH_PROG(AUTOHEADER, autoheader)
AC_PATH_PROG(AS, as)
AC_PATH_PROG(RM, rm)
AC_PATH_PROG(CP, cp)
AC_PATH_PROG(MV, mv)
AC_PATH_PROG(LN, ln)
AC_PATH_PROG(TOUCH, touch)
LT_INIT([dlopen shared disable-static])
LT_LANG([C++])
CXXFLAGS="-pipe"
AC_PROG_CXX
AC_PROG_CXX_C_O
AC_PROG_LIBTOOL
AC_PROG_MAKE_SET
AC_LANG(C++)
AC_CONFIG_HEADER(include/ircd/config.h)
AX_CXX_COMPILE_STDCXX([17], [gnu], [mandatory], 201703)
dnl ***************************************************************************
dnl
dnl Makefile tree
dnl
dnl These (and Makefile.in) are generated from a Makefile.am in the same dir.
dnl
AC_CONFIG_FILES(\
Makefile \
include/ircd/Makefile \
construct/Makefile \
ircd/Makefile \
modules/Makefile \
share/Makefile \
)
AM_INIT_AUTOMAKE([subdir-objects])
dnl
dnl Initialization of variables exported to Makefile.am.
dnl These will be further composed throughout this file...
dnl
AC_SUBST(CC)
AC_SUBST(CXX)
AC_SUBST(CPPFLAGS)
AC_SUBST(CXXFLAGS)
AC_SUBST(LD)
AC_SUBST(LDFLAGS)
AC_SUBST(LIBS)
dnl
dnl Preprocessor define macros
dnl
dnl Use RB_DEFINE() et al to generate defines in config.h
dnl Use CPPDEFINE() to generate defines on the command line if required
dnl
AC_DEFUN([RB_DEFINE],
[
AC_DEFINE([RB_$1], [$2], [$3])
])
AC_DEFUN([RB_DEFINE_UNQUOTED],
[
AC_DEFINE_UNQUOTED([RB_$1], [$2], [$3])
])
AC_DEFUN([IRCD_DEFINE],
[
AC_DEFINE([IRCD_$1], [$2], [$3])
])
AC_DEFUN([IRCD_DEFINE_UNQUOTED],
[
AC_DEFINE_UNQUOTED([IRCD_$1], [$2], [$3])
])
AC_DEFUN([CPPDEFINE],
[
if [[ -z "$2" ]]; then
CPPFLAGS="-D$1 $CPPFLAGS"
else
CPPFLAGS="-D$1=$2 $CPPFLAGS"
fi
])
dnl ***************************************************************************
dnl
dnl Platform
dnl
dnl
dnl Recursive local targets (clean-local is implied)
dnl
#AM_EXTRA_RECURSIVE_TARGETS([
# mrproper
#])
dnl
dnl Coarse compiler test macros
dnl
AM_CONDITIONAL([GCC], [[[[ $CXX = g\+\+* ]]]])
AM_CONDITIONAL([CLANG], [[[[ $CXX = clang* ]]]])
RB_DEFINE_UNQUOTED([CXX], ["$CXX"], [CXX Compiler])
dnl
dnl Coarse operating system test macros
dnl
AM_CONDITIONAL([LINUX], [[[[ $host_os = *linux* ]]]])
AM_CONDITIONAL([NETBSD], [[[[ $host_os = *netbsd* ]]]])
AM_CONDITIONAL([FREEBSD], [[[[ $host_os = *freebsd* ]]]])
AM_CONDITIONAL([MINGW], [[[[ $host_os = *mingw* ]] || [[ $host_os = *msys* ]]]])
AM_CONDITIONAL([CYGWIN], [[[[ $host_os = *cygwin* ]]]])
AM_CONDITIONAL([INTERIX], [[[[ $host_os = *interix* ]]]])
AM_CONDITIONAL([SOLARIS], [[[[ $host_os = *solaris* ]]]])
RB_DEFINE_UNQUOTED([OS], ["$host_os"], [Host operating system])
dnl ***************************************************************************
dnl
dnl Developer options
dnl
dnl
dnl Debugging mode
dnl
AC_MSG_CHECKING(whether to enable debugging)
AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging suite for development.]),
[
AC_MSG_RESULT([yes])
AC_SUBST(DEBUG, 1)
RB_DEFINE_UNQUOTED([DEBUG], [1], [Not configured for release when lit.])
RB_DEFINE_UNQUOTED([DEBUG_LEVEL], [1], [Defined to 0 for release; or > 0 otherwise])
], [
AC_MSG_RESULT([no])
RB_DEFINE_UNQUOTED([DEBUG_LEVEL], [0], [Defined to 0 for release])
])
AM_CONDITIONAL([DEBUG], [[[[ "$DEBUG" = "1" ]]]])
dnl
dnl Compactness
dnl
AC_MSG_CHECKING(Optimize for size; strip symbols; force no debugging)
AC_ARG_ENABLE(compact, AC_HELP_STRING([--enable-compact], [Optimize for size and compactness]),
[
AC_MSG_RESULT([yes])
AC_SUBST(COMPACT, 1)
RB_DEFINE_UNQUOTED([COMPACT], [1], [Not configured for compactness when lit.])
], [
AC_MSG_RESULT([no])
])
AM_CONDITIONAL([COMPACT], [[[[ "$COMPACT" = "1" ]]]])
dnl
dnl Explicit assert switch for still using assert() without --enable-debug
dnl
AC_MSG_CHECKING(whether to explicitly enable assertions)
AC_ARG_ENABLE(assert, AC_HELP_STRING([--enable-assert], [Enable assertions without --enable-debug]),
[
AC_MSG_RESULT([yes])
AC_SUBST(ASSERT, 1)
], [
AM_COND_IF(DEBUG,
[
AC_MSG_RESULT([no, but assertions are enabled anyway])
AC_SUBST(ASSERT, 1)
], [
AC_MSG_RESULT([no])
])
])
AM_CONDITIONAL([ASSERT], [[[[ "$ASSERT" = "1" ]]]])
AM_COND_IF(ASSERT,
[
assert="yes"
], [
assert="no"
CPPDEFINE([NDEBUG])
])
dnl
dnl Switch to control the action of assert()
dnl
AC_MSG_CHECKING(whether to change the behavior of assertions)
AC_ARG_WITH(assert, AC_HELP_STRING([--with-assert[[[=trap]]]], [Soften assertion behavior]),
[
assert_type=$withval
AC_MSG_RESULT([yes])
AC_SUBST(ASSERT_TYPE, $assert_type)
], [
AM_COND_IF(DEBUG,
[
assert_type="trap"
AC_MSG_RESULT([no, defaulting to "$assert_type"])
AC_SUBST(ASSERT_TYPE, $assert_type)
], [
AC_MSG_RESULT([no])
])
])
AM_COND_IF(ASSERT,
[
if [[ ! -z "$assert_type" ]]; then
RB_DEFINE_UNQUOTED([ASSERT], ["$assert_type"], [Assertion behavior])
fi
if [ "$assert_type" == "trap" ]; then
RB_DEFINE([ASSERT_INTRINSIC], [1], [Intrinsic assertion behavior])
fi
])
dnl
dnl Explicit optimize switch for enabling optimization when using --enable-debug
dnl
AC_MSG_CHECKING(whether to explicitly enable optimized build)
AC_ARG_ENABLE(optimize, AC_HELP_STRING([--enable-optimize], [Enable optimization even with --enable-debug]),
[
AC_MSG_RESULT([yes])
AC_SUBST(OPTIMIZE, 1)
], [
AM_COND_IF(DEBUG,
[
AC_MSG_RESULT([no])
], [
AC_MSG_RESULT([no, but optimized build is enabled anyway])
AC_SUBST(OPTIMIZE, 1)
])
])
AM_CONDITIONAL([OPTIMIZE], [[[[ "$OPTIMIZE" = "1" ]]]])
dnl
dnl Explicit link-time-optimization switch
dnl
AC_MSG_CHECKING(whether to enable link-time optimization)
AC_ARG_ENABLE(lto, AC_HELP_STRING([--enable-lto], [Enable link-time optimization]),
[
AC_MSG_RESULT([yes])
AC_SUBST(LTO, 1)
], [
AM_COND_IF(DEBUG,
[
AC_MSG_RESULT([no])
], [
AC_MSG_RESULT([no, link-time optimization is explicit-only at this time])
])
])
AM_CONDITIONAL([LTO], [[[[ "$LTO" = "1" ]]]])
dnl
dnl Explicit optimization level switch
dnl
AC_MSG_CHECKING(whether to explicitly set the optimization level)
AC_ARG_WITH(optimize-level, AC_HELP_STRING([--with-optimize-level[[[=3]]]], [Explicitly set the optimize level]),
[
optimize_level=$withval
AC_MSG_RESULT([yes, enabling optimization level -O$optimize_level])
AC_SUBST(OPTMIZE_LEVEL, $optimize_level)
RB_DEFINE_UNQUOTED([OPTIMIZE_LEVEL], [$optimize_level], [User configured optimization level])
], [
AM_COND_IF(OPTIMIZE,
[
AM_COND_IF(COMPACT,
[
optimize_level="s"
AC_MSG_RESULT([no, but --enable-optimize and --enable-compact means -O$optimize_level])
AC_SUBST(OPTIMIZE_LEVEL, $optimize_level)
RB_DEFINE_UNQUOTED([OPTIMIZE_LEVEL], [$optimize_level], [Implicitly set release mode optimization])
], [
optimize_level="3"
AC_MSG_RESULT([no, but --enable-optimize has implied level -O$optimize_level])
AC_SUBST(OPTIMIZE_LEVEL, $optimize_level)
RB_DEFINE_UNQUOTED([OPTIMIZE_LEVEL], [$optimize_level], [Explicitly set release mode optimization])
])
], [
AM_COND_IF(DEBUG,
[
optimize_level="g"
AC_MSG_RESULT([no, but --enable-debug has implied level -O$optimize_level])
AC_SUBST(OPTIMIZE_LEVEL, $optimize_level)
RB_DEFINE_UNQUOTED([OPTIMIZE_LEVEL], ['$optimize_level'], [Debug mode optimization level])
], [
optimize_level="3"
AC_MSG_RESULT([no, but release mode has implied level -O$optimize_level])
AC_SUBST(OPTIMIZE_LEVEL, $optimize_level)
RB_DEFINE_UNQUOTED([OPTIMIZE_LEVEL], [$optimize_level], [Release mode optimization])
])
])
])
dnl
dnl Explicit log level
dnl
dnl NOTE: Log levels here must be manually sync'ed with ircd/logger.h
dnl
AC_MSG_CHECKING(whether to explicitly set the logging level ceiling)
AC_ARG_WITH(log-level, AC_HELP_STRING([--with-log-level[[[=INFO]]]], [Explicitly set the log level ceiling]),
[
AC_MSG_RESULT([yes, enabling log level $withval and below])
level=4
if [[ $withval = "DEBUG" ]]; then
level=7
elif [[ $withval = "DWARNING" ]]; then
level=6
elif [[ $withval = "DERROR" ]]; then
level=5
elif [[ $withval = "INFO" ]]; then
level=4
elif [[ $withval = "NOTICE" ]]; then
level=3
elif [[ $withval = "WARNING" ]]; then
level=2
elif [[ $withval = "ERROR" ]]; then
level=1
elif [[ $withval = "CRITICAL" ]]; then
level=0
elif [[ $withval = "-1" ]]; then
level=-1
fi
AC_SUBST(LOG_LEVEL, $level)
RB_DEFINE_UNQUOTED([LOG_LEVEL], [$level], [Log messages for user configured level and below.])
], [
AM_COND_IF(DEBUG,
[
AC_MSG_RESULT([no, but debug mode enables all log levels through DEBUG])
AC_SUBST(LOG_LEVEL, 7)
RB_DEFINE_UNQUOTED([LOG_LEVEL], [7], [Log message level default for DEBUG mode])
], [
AC_MSG_RESULT([no])
AC_SUBST(LOG_LEVEL, 4)
RB_DEFINE_UNQUOTED([LOG_LEVEL], [4], [Log message level default for release mode])
])
])
dnl
dnl Profiling mode
dnl
AC_MSG_CHECKING(whether to do a profile build)
AC_ARG_ENABLE(profile, AC_HELP_STRING([--enable-profile], [Enable profiling]),
[
if test "$ac_cv_c_compiler_gnu" = yes; then
AC_MSG_RESULT([yes, adding -pg])
CXXFLAGS+=" -pg"
AC_DEFINE(CHARYBDIS_PROFILE, 1, [Define this if you are profiling.])
else
AC_MSG_RESULT([no, profile builds only work with gcc])
fi
], [
])
dnl
dnl Precompiled headers
dnl
AC_MSG_CHECKING(whether to disable precompiled headers)
AC_ARG_ENABLE(pch, AC_HELP_STRING([--disable-pch], [Disable precompiled header generation]),
[
build_pch="no"
AC_MSG_RESULT([no])
], [
build_pch="yes"
CPPDEFINE([PCH])
AC_MSG_RESULT([yes])
])
AM_CONDITIONAL([BUILD_PCH], [[[[ "$build_pch" = "yes" ]]]])
dnl
dnl Generic Mode compilation
dnl
AC_MSG_CHECKING(whether to enable generic mode or tune for this host)
AC_ARG_ENABLE(generic, AC_HELP_STRING([--enable-generic], [Emit more generic code for pkg binaries.]),
[
enable_generic="yes"
AC_MSG_RESULT([yes])
RB_DEFINE([GENERIC], [1], [Building binary tuned for generic architectures])
], [
enable_generic="no"
AC_MSG_RESULT([no])
])
AM_CONDITIONAL([GENERIC], [[[[ "$enable_generic" = "yes" ]]]])
AM_COND_IF([GENERIC],
[
CXXFLAGS+=" -mtune=generic"
], [
CXXFLAGS+=" -march=native"
])
dnl
dnl Untuned Mode compilation
dnl
AC_MSG_CHECKING(whether to enable fully untuned mode)
AC_ARG_ENABLE(untuned, AC_HELP_STRING([--enable-untuned], [Emit no special feature instructions.]),
[
enable_untuned="yes"
AC_MSG_RESULT([yes])
RB_DEFINE([UNTUNED], [1], [Building binary without extended-feature cpu instructions.])
], [
enable_untuned="no"
AC_MSG_RESULT([no])
])
AM_CONDITIONAL([UNTUNED], [[[[ "$enable_untuned" = "yes" ]]]])
AM_COND_IF([UNTUNED],
[
CXXFLAGS+=" -mno-default"
], [
CXXFLAGS+=""
])
dnl
dnl Disable third-party allocators
dnl
AC_MSG_CHECKING(whether to prevent available third-party allocator libraries from being used)
AC_ARG_ENABLE(malloc-libs, AC_HELP_STRING([--disable-malloc-libs], [Disable third-party dynamic memory libraries (jemalloc/tcmalloc/etc)]),
[
use_malloc_libs="no"
AC_MSG_RESULT([yes])
], [
use_malloc_libs="yes"
AC_MSG_RESULT([no])
])
AM_CONDITIONAL([MALLOC_LIBS], [[[[ "$use_malloc_libs" = "yes" ]]]])
dnl !!! Experimental !!!
dnl
dnl Allows a signal handler to throw a C++ exception if the signal is from
dnl a CPU trap on an instruction (ex. SIGFPE from a floating point divide
dnl by zero). This allows the signal handler to transfer control to the
dnl catch block wrapping the area which errored, thereby aborting any further
dnl execution after the signal was received which would have to manually check
dnl for such an error after each floating point operation and throw.
AC_ARG_ENABLE(asyncexcept, AC_HELP_STRING([--enable-asyncexcept], [Enable experimental asynchronous exceptions]),
[
asyncexcept="yes"
], [
asyncexcept="no"
])
dnl CHARYBDIS_C_GCC_TRY_FLAGS([-fnon-call-exceptions], charybdis_cv_c_gcc_f_non_call_exceptions)
if test "$asyncexcept" = "yes"; then
IRCD_DEFINE(USE_ASYNC_EXCEPTIONS, [1], [Experimental asynchronous exceptions are supported])
CXXFLAGS+=" -fasynchronous-unwind-tables"
CXXFLAGS+=" -fnon-call-exceptions"
fi
AM_CONDITIONAL([ASYNCEXCEPT], [[[[ $asyncexcept = "yes" ]]]])
dnl
dnl Low memory compilation mode
dnl
AC_ARG_ENABLE(lowmem-compile, AC_HELP_STRING([--enable-lowmem-compile], [Enable low-memory compilation options]),
[
lowmem_compile="yes"
], [
lowmem_compile="no"
])
AM_CONDITIONAL([LOWMEM_COMPILE], [[[[ $lowmem_compile = "yes" ]]]])
dnl
dnl Optimization
dnl
CXXFLAGS+=" -O$optimize_level"
AM_COND_IF([LTO],
[
lto="yes"
CXXFLAGS+=" -flto=`nproc`"
], [
lto="no"
])
AM_COND_IF([OPTIMIZE],
[
optimize="yes"
CXXFLAGS+=" -fdata-sections"
CXXFLAGS+=" -ffunction-sections"
CXXFLAGS+=" -ftree-vectorize"
AM_COND_IF([GCC],
[
CXXFLAGS+=" -fweb"
CXXFLAGS+=" -fgcse-sm"
CXXFLAGS+=" -fgcse-las"
CXXFLAGS+=" -fgcse-after-reload"
CXXFLAGS+=" -frename-registers"
CXXFLAGS+=" -fsched-stalled-insns=0"
CXXFLAGS+=" -fira-hoist-pressure"
CXXFLAGS+=" -fbranch-target-load-optimize"
CXXFLAGS+=" -frerun-loop-opt"
CXXFLAGS+=" -fdevirtualize-at-ltrans"
])
], [
optimize="no"
CXXFLAGS+=" -falign-functions"
])
dnl
dnl Compiler intrumentation
dnl
AM_COND_IF([DEBUG],
[
CXXFLAGS+=" -g"
CXXFLAGS+=" -ggdb"
AM_COND_IF([GCC],
[
CXXFLAGS+=" -fvar-tracking"
CXXFLAGS+=" -fvar-tracking-assignments"
])
], [
AM_COND_IF([COMPACT],
[
], [
dnl Note these flags are unreliable with LTO
CXXFLAGS+=" -g"
CXXFLAGS+=" -ggdb"
])
])
dnl Creates an ELF section in the output which contains a list of
dnl the command line arguments used for compilation.
AM_COND_IF([GCC],
[
CXXFLAGS+=" -frecord-gcc-switches"
])
AM_COND_IF([CLANG],
[
CXXFLAGS+=" -grecord-gcc-switches"
])
dnl CXXFLAGS+=" -mmpx"
dnl CXXFLAGS+=" -fcheck-pointer-bounds"
AM_COND_IF([GCC],
[
CXXFLAGS+=" -fstack-protector-explicit"
])
dnl -fvisibility-inlines-hidden - for optimization; note the address of inline
dnl functions won't be the same between translation units
CXXFLAGS+=" -fvisibility-inlines-hidden"
dnl see gcc(1)
AM_COND_IF([GCC],
[
CXXFLAGS+=" -fnothrow-opt"
])
dnl This disables thread-safety for static variable initialization
dnl (specifically local static variables inside functions) which reduces
dnl generated code size and complexity. This is alright since construct is
dnl primarily single threaded. Even if other threads are spawned for special
dnl tasks we consider the likelyhood of a static initialization race to either
dnl be sufficiently low or simply immaterial for our uses of them.
dnl
CXXFLAGS+=" -fno-threadsafe-statics"
dnl
AM_COND_IF([GCC],
[
CXXFLAGS+=" -fverbose-asm"
])
dnl
dnl Compiler warnings
dnl
STACK_USAGE_WARNING=16384
FRAME_SIZE_WARNING=8192
CWARNS=""
AC_MSG_CHECKING(whether to disable warnings)
AC_ARG_ENABLE(warnings,
AC_HELP_STRING([--disable-warnings],[Disable all sorts of warnings like a rockstar]),
[],
[
CHARYBDIS_C_GCC_TRY_FLAGS([-Wall], charybdis_cv_c_gcc_w_all)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wextra], charybdis_cv_c_gcc_w_extra)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wpointer-arith], charybdis_cv_c_gcc_w_pointer_arith)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wcast-align], charybdis_cv_c_gcc_w_cast_align)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wcast-qual], charybdis_cv_c_gcc_w_cast_qual)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wfloat-equal], charybdis_cv_c_gcc_w_float_equal)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wwrite-strings], charybdis_cv_c_gcc_w_write_strings)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wparentheses], charybdis_cv_c_gcc_parentheses)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wmissing-noreturn], charybdis_cv_c_gcc_w_missing_noreturn)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wundef], charybdis_cv_c_gcc_w_undef)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wpacked], charybdis_cv_c_gcc_w_packed)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wformat -Wformat-y2k -Wformat-nonliteral], charybdis_cv_c_gcc_w_format)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wstrict-aliasing=2 -Wstrict-overflow=5], charybdis_cv_c_gcc_w_strict)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wdisabled-optimization], charybdis_cv_c_gcc_w_disabled_optimization)
CHARYBDIS_C_GCC_TRY_FLAGS([-Winvalid-pch], charybdis_cv_c_gcc_w_invalid_pch)
CHARYBDIS_C_GCC_TRY_FLAGS([-Winit-self], charybdis_cv_c_gcc_w_init_self)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wuninitialized], charybdis_cv_c_gcc_w_uninitialized)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wunreachable-code], charybdis_cv_c_gcc_w_unreachable_code)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wno-overloaded-virtual], charybdis_cv_c_gcc_w_overloaded_virtual)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wnon-virtual-dtor], charybdis_cv_c_gcc_w_non_virtual_dtor)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wnoexcept], charybdis_cv_c_gcc_w_noexcept)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wsized-deallocation], charybdis_cv_c_gcc_w_sized_deallocation)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wctor-dtor-privacy], charybdis_cv_c_gcc_w_ctor_dtor_privacy)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wsign-promo], charybdis_cv_c_gcc_w_sign_promo)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wsuggest-final-types], charybdis_cv_c_gcc_w_suggest_final_types)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wsuggest-final-methods], charybdis_cv_c_gcc_w_suggest_final_methods)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wsuggest-override], charybdis_cv_c_gcc_w_suggest_override)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wtrampolines], charybdis_cv_c_gcc_w_trampolines)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wduplicate-cond], charybdis_cv_c_gcc_w_duplicate_cond)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wduplicate-branches], charybdis_cv_c_gcc_w_duplicate_branches)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wrestrict], charybdis_cv_c_gcc_w_restrict)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wnull-dereference], charybdis_cv_c_gcc_w_null_dereference)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wplacement-new=2], charybdis_cv_c_gcc_w_placement_new)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wundef], charybdis_cv_c_gcc_w_undef)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wodr], charybdis_cv_c_gcc_w_odr)
dnl
dnl List of warnings treated as errors
dnl
dnl Uninitialized return values are not useful in this project; forgetting
dnl to return from a function is always a developer mistake here.
AM_COND_IF([GCC],
[
CHARYBDIS_C_GCC_TRY_FLAGS([-Werror=return-type], charybdis_cv_c_gcc_w_error_return_type)
])
dnl
dnl List of warnings we suppress:
dnl
dnl Missing field initializers should have default init or some zero-extension as per std, this
dnl warning is only useful if you want to gauge where that's happening for a specific reason
CHARYBDIS_C_GCC_TRY_FLAGS([-Wno-missing-field-initializers], charybdis_cv_c_gcc_w_missing_field_initializers)
dnl Unused variables, functions, labels, etc are just fine as long as they get optimized
dnl away. These warnings can be re-enabled during a code cleanup, otherwise shut up.
CHARYBDIS_C_GCC_TRY_FLAGS([-Wno-unused], charybdis_cv_c_gcc_w_unused)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wno-unused-function], charybdis_cv_c_gcc_w_unused_function)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wno-unused-label], charybdis_cv_c_gcc_w_unused_label)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wno-unused-value], charybdis_cv_c_gcc_w_unused_value)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wno-unused-variable], charybdis_cv_c_gcc_w_unused_variable)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wno-unused-parameter], charybdis_cv_c_gcc_w_unused_parameter)
dnl This warning is disabled to allow preprocessor statements like #endif to
dnl contain text on the same line. This is used for example to write the
dnl identifier in the matching prior #ifdef, which has no actual effect except
dnl clarity.
CHARYBDIS_C_GCC_TRY_FLAGS([-Wno-endif-labels], charybdis_cv_c_gcc_w_endif_labels)
dnl
dnl List of compiler-specific / incompatible warning options
dnl
AM_COND_IF([GCC],
[
CHARYBDIS_C_GCC_TRY_FLAGS([-Wlogical-op], charybdis_cv_c_gcc_w_logical_op)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wformat-security], charybdis_cv_c_gcc_w_format_security)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wstack-usage=$STACK_USAGE_WARNING], charybdis_cv_c_gcc_w_stack_usage)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wframe-larger-than=$FRAME_SIZE_WARNING], charybdis_cv_c_gcc_w_frame_larger_than)
CHARYBDIS_C_GCC_TRY_FLAGS([-Walloca], charybdis_cv_c_gcc_w_alloca)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wsuggest-attribute=format], charybdis_cv_c_gcc_w_suggest_attribute_format)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wsuggest-attribute=noreturn], charybdis_cv_c_gcc_w_suggest_attribute_noreturn)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wsuggest-attribute=malloc], charybdis_cv_c_gcc_w_suggest_attribute_malloc)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wsuggest-attribute=cold], charybdis_cv_c_gcc_w_suggest_attribute_cold)
dnl CHARYBDIS_C_GCC_TRY_FLAGS([-Wsuggest-attribute=pure], charybdis_cv_c_gcc_w_suggest_attribute_pure)
dnl CHARYBDIS_C_GCC_TRY_FLAGS([-Wsuggest-attribute=const], charybdis_cv_c_gcc_w_suggest_attribute_const)
],[])
AM_COND_IF([CLANG],
[
CHARYBDIS_C_GCC_TRY_FLAGS([-Wno-mismatched-tags], charybdis_cv_c_gcc_w_mismatched_tags)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wno-format-security], charybdis_cv_c_gcc_w_format_security)
CHARYBDIS_C_GCC_TRY_FLAGS([-Wno-unknown-warning-option], charybdis_cv_c_gcc_w_unknown_warning_option)
],[])
])
CPPFLAGS+="$CWARNS"
dnl ***************************************************************************
dnl
dnl Philology checks
dnl
AC_ISC_POSIX
AC_C_CONST
AC_C_INLINE
if test "$ac_cv_header_machine_endian_h" = "no" ; then
AC_C_BIGENDIAN
fi
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UID_T
AC_TYPE_PID_T
AC_CHECK_TYPES([intptr_t])
AC_CHECK_TYPES([uintptr_t])
AC_CHECK_TYPES([int128_t])
AC_CHECK_TYPES([uint128_t])
AC_CHECK_TYPES([__int128])
AC_CHECK_TYPES([__int128_t])
AC_CHECK_TYPES([__uint128_t])
AC_CHECK_TYPES([long double])
AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF(float)
AC_CHECK_SIZEOF(double)
AC_CHECK_SIZEOF(long double)
AC_CHECK_SIZEOF(int128_t)
AC_CHECK_SIZEOF(uint128_t)
AC_CHECK_SIZEOF(__int128)
AC_CHECK_SIZEOF(__int128_t)
AC_CHECK_SIZEOF(__uint128_t)
dnl -fsigned-char ensures 'char' is signed on all platforms
CXXFLAGS+=" -fsigned-char"
dnl
dnl Header files
dnl
AC_DEFUN([RB_CHK_SYSHEADER],
[
if test -z "$rb_have_sysheader_$2"; then
AC_CHECK_HEADER([$1],
[
rb_have_sysheader_$2=1;
AC_DEFINE([HAVE_$2], [1], [ Indication $1 is available. ])
RB_DEFINE_UNQUOTED([INC_$2], [$1>], [ The computed-include location of $1. ])
], [
RB_DEFINE_UNQUOTED([INC_$2], [stddef.h>], [ The dead-header in place of $1. ])
])
fi
])
AC_HEADER_STDBOOL
dnl AC_HEADER_STDC
dnl libc
RB_CHK_SYSHEADER(assert.h, [ASSERT_H])
RB_CHK_SYSHEADER(stdarg.h, [STDARG_H])
dnl libc++
RB_CHK_SYSHEADER(cstddef, [CSTDDEF])
RB_CHK_SYSHEADER(cstdint, [CSTDINT])
RB_CHK_SYSHEADER(cstdlib, [CSTDLIB])
RB_CHK_SYSHEADER(limits, [LIMITS])
RB_CHK_SYSHEADER(type_traits, [TYPE_TRAITS])
RB_CHK_SYSHEADER(typeindex, [TYPEINDEX])
RB_CHK_SYSHEADER(variant, [VARIANT])
RB_CHK_SYSHEADER(utility, [UTILITY])
RB_CHK_SYSHEADER(functional, [FUNCTIONAL])
RB_CHK_SYSHEADER(algorithm, [ALGORITHM])
RB_CHK_SYSHEADER(numeric, [NUMERIC])
RB_CHK_SYSHEADER(cmath, [CMATH])
RB_CHK_SYSHEADER(cfenv, [CFENV])
RB_CHK_SYSHEADER(memory, [MEMORY])
RB_CHK_SYSHEADER(exception, [EXCEPTION])
RB_CHK_SYSHEADER(cerrno, [CERRNO])
RB_CHK_SYSHEADER(system_error, [SYSTEM_ERROR])
RB_CHK_SYSHEADER(map, [MAP])
RB_CHK_SYSHEADER(set, [SET])
RB_CHK_SYSHEADER(list, [LIST])
RB_CHK_SYSHEADER(stack, [STACK])
RB_CHK_SYSHEADER(queue, [QUEUE])
RB_CHK_SYSHEADER(deque, [DEQUE])
RB_CHK_SYSHEADER(array, [ARRAY])
RB_CHK_SYSHEADER(vector, [VECTOR])
RB_CHK_SYSHEADER(forward_list, [FORWARD_LIST])
RB_CHK_SYSHEADER(unordered_map, [UNORDERED_MAP])
RB_CHK_SYSHEADER(string, [STRING])
RB_CHK_SYSHEADER(cstring, [CSTRING])
RB_CHK_SYSHEADER(locale, [LOCALE])
RB_CHK_SYSHEADER(codecvt, [CODECVT])
RB_CHK_SYSHEADER(sstream, [SSTREAM])
RB_CHK_SYSHEADER(fstream, [FSTREAM])
RB_CHK_SYSHEADER(iostream, [IOSTREAM])
RB_CHK_SYSHEADER(iosfwd, [IOSFWD])
RB_CHK_SYSHEADER(iomanip, [IOMANIP])
RB_CHK_SYSHEADER(cstdio, [CSTDIO])
RB_CHK_SYSHEADER(chrono, [CHRONO])
RB_CHK_SYSHEADER(ctime, [CTIME])
RB_CHK_SYSHEADER(atomic, [ATOMIC])
RB_CHK_SYSHEADER(thread, [THREAD])
RB_CHK_SYSHEADER(mutex, [MUTEX])
RB_CHK_SYSHEADER(shared_mutex, [SHARED_MUTEX])
RB_CHK_SYSHEADER(condition_variable, [CONDITION_VARIABLE])
RB_CHK_SYSHEADER(random, [RANDOM])
RB_CHK_SYSHEADER(bitset, [BITSET])
RB_CHK_SYSHEADER(string_view, [STRING_VIEW])
RB_CHK_SYSHEADER(optional, [OPTIONAL])
RB_CHK_SYSHEADER(new, [NEW])
RB_CHK_SYSHEADER(regex, [REGEX])
RB_CHK_SYSHEADER(memory_resource, [MEMORY_RESOURCE])
RB_CHK_SYSHEADER(filesystem, [FILESYSTEM])
RB_CHK_SYSHEADER(cxxabi.h, [CXXABI_H])
dnl unix platform
RB_CHK_SYSHEADER(unistd.h, [UNISTD_H])
RB_CHK_SYSHEADER(signal.h, [SIGNAL_H])
RB_CHK_SYSHEADER(ifaddrs.h, [IFADDRS_H])
RB_CHK_SYSHEADER(fcntl.h, [FCNTL_H])
RB_CHK_SYSHEADER(elf.h, [ELF_H])
RB_CHK_SYSHEADER(link.h, [LINK_H])
RB_CHK_SYSHEADER(dlfcn.h, [DLFCN_H])
RB_CHK_SYSHEADER(execinfo.h, [EXECINFO_H])
RB_CHK_SYSHEADER(sys/types.h, [SYS_TYPES_H])
RB_CHK_SYSHEADER(sys/time.h, [SYS_TIME_H])
RB_CHK_SYSHEADER(sys/stat.h, [SYS_STAT_H])
RB_CHK_SYSHEADER(sys/statfs.h, [SYS_STATFS_H])
RB_CHK_SYSHEADER(sys/statvfs.h, [SYS_STATVFS_H])
RB_CHK_SYSHEADER(sys/resource.h, [SYS_RESOURCE_H])
RB_CHK_SYSHEADER(sys/syscall.h, [SYS_SYSCALL_H])
RB_CHK_SYSHEADER(sys/utsname.h, [SYS_UTSNAME_H])
RB_CHK_SYSHEADER(sys/ioctl.h, [SYS_IOCTL_H])
RB_CHK_SYSHEADER(sys/mman.h, [SYS_MMAN_H])
RB_CHK_SYSHEADER(gnu/libc-version.h, [GNU_LIBC_VERSION_H])
dnl linux platform
RB_CHK_SYSHEADER(sys/auxv.h, [SYS_AUXV_H])
RB_CHK_SYSHEADER(sys/eventfd.h, [SYS_EVENTFD_H])
RB_CHK_SYSHEADER(sys/inotify.h, [SYS_INOTIFY_H])
RB_CHK_SYSHEADER(sys/sysmacros.h, [SYS_SYSMACROS_H])
RB_CHK_SYSHEADER(linux/aio_abi.h, [LINUX_AIO_ABI_H])
RB_CHK_SYSHEADER(linux/magic.h, [LINUX_MAGIC_H])
RB_CHK_SYSHEADER(linux/perf_event.h, [LINUX_PERF_EVENT_H])
RB_CHK_SYSHEADER(linux/hw_breakpoint.h, [LINUX_HW_BREAKPOINT_H])
RB_CHK_SYSHEADER(linux/io_uring.h, [LINUX_IO_URING_H])
RB_CHK_SYSHEADER(linux/icmp.h, [LINUX_ICMP_H])
dnl windows platform
RB_CHK_SYSHEADER(windows.h, [WINDOWS_H])
RB_CHK_SYSHEADER(winsock2.h, [WINSOCK2_H])
RB_CHK_SYSHEADER(ws2tcpip.h, [WS2TCPIP_H])
RB_CHK_SYSHEADER(iphlpapi.h, [IPHLPAPI_H])
dnl x86 platform
RB_CHK_SYSHEADER(x86intrin.h, [X86INTRIN_H])
RB_CHK_SYSHEADER(cpuid.h, [CPUID_H])
dnl instrumentation
RB_CHK_SYSHEADER(malloc.h, [MALLOC_H])
RB_CHK_SYSHEADER(valgrind/valgrind.h, [VALGRIND_VALGRIND_H])
RB_CHK_SYSHEADER(valgrind/memcheck.h, [VALGRIND_MEMCHECK_H])
RB_CHK_SYSHEADER(valgrind/callgrind.h, [VALGRIND_CALLGRIND_H])
dnl experimental
RB_CHK_SYSHEADER(experimental/string_view, [EXPERIMENTAL_STRING_VIEW])
RB_CHK_SYSHEADER(experimental/optional, [EXPERIMENTAL_OPTIONAL])
RB_CHK_SYSHEADER(experimental/memory_resource, [EXPERIMENTAL_MEMORY_RESOURCE])
dnl
dnl Specific function checks
dnl
AC_CHECK_FUNCS([ \
backtrace \
gettimeofday \
posix_fadvise \
preadv2 \
pwritev2 \
snprintf \
strlcat \
strlcpy \
strnlen \
strncpy \
strcpy \
vsnprintf \
])
AC_SEARCH_LIBS(dlinfo, dl, AC_DEFINE(HAVE_DLINFO, 1, [Define if you have dlinfo]))
AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP, 1, [Define if you have nanosleep]))
dnl
dnl Networking Functions
dnl
AC_ARG_ENABLE(ipv6, AC_HELP_STRING([--disable-ipv6], [Disable IPv6 support]),
[
ipv6="no"
], [
ipv6="yes"
])
AM_CONDITIONAL([HAVE_IPV6], [[[[ "$ipv6" = "yes" ]]]])
AM_COND_IF(HAVE_IPV6,
[
AC_DEFINE([HAVE_IPV6], [1], [IPv6 is supported])
],[])
dnl ***************************************************************************
dnl
dnl Miscellaneous operating system specific
dnl
AM_COND_IF(MINGW,
[
AC_DEFINE(HAVE_WIN32, [1], [Define to 1 if you are on windows])
LIBS="$LIBS -lws2_32 -liphlpapi"
],[])
AM_COND_IF(INTERIX,
[
CPPDEFINE([_ALL_SOURCE])
CPPDEFINE([_XOPEN_SOURCE], [500])
CPPDEFINE([_POSIX_PTHREAD_SEMANTICS])
CPPDEFINE([_XPG4_2])
],[])
dnl
dnl Linux AIO support
dnl
AM_COND_IF(LINUX,
[
AC_ARG_ENABLE(aio, AC_HELP_STRING([--disable-aio], [Disable kernel AIO support]),
[
aio=$enableval
], [
aio=yes
])
], [])
if test "$aio" = "yes"; then
IRCD_DEFINE(USE_AIO, [1], [Linux AIO is supported and will be used])
fi
AM_CONDITIONAL([AIO], [[[[ $aio = yes ]]]])
dnl
dnl Linux io_uring support
dnl
AM_COND_IF(LINUX,
[
AC_ARG_ENABLE(io_uring, AC_HELP_STRING([--disable-io_uring], [Disable kernel io_uring support]),
[
io_uring=$enableval
], [
io_uring="$ac_cv_header_linux_io_uring_h"
])
])
AM_CONDITIONAL([IOU], [[[[ $io_uring = yes ]]]])
AM_COND_IF([IOU],