forked from apache/trafficserver
-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure.ac
2000 lines (1767 loc) · 59.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
# Process this file with `autoreconf -i` to create a 'configure' file.
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Table of Contents
# 1. INITIALIZATION
# 2. SITE CONFIGURATION
# 3. CHECK FOR PROGRAMS
# 4. CHECK FOR LIBRARIES
# 5. CHECK FOR HEADERS
# 6. OUTPUT FILES
# 7. autoheader TEMPLATES
# -----------------------------------------------------------------------------
# 1. INITIALIZATION
# These first two version numbers are updated automatically on each release.
# Version number is calculated as MAJOR * 1000000 + MINOR * 1000 + MICRO
# Version string is in the form of MAJOR.MINOR.MICRO[sufix]
#
m4_define([TS_VERSION_S],[7.0.0])
m4_define([TS_VERSION_N],[7000000])
AC_INIT([Apache Traffic Server], TS_VERSION_S(), [dev@trafficserver.apache.org], [trafficserver],[http://trafficserver.apache.org])
AC_PREREQ([2.59])
AC_CONFIG_AUX_DIR([build/_aux])
AC_CONFIG_SRCDIR([proxy/Main.cc])
AC_CONFIG_MACRO_DIR([build])
# NOTE: we turn off portability warnings because the clang-tidy targets use
# GNU make extensions to filter the sources list.
AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability tar-ustar foreign no-installinfo no-installman subdir-objects 1.9.2])
# See discussion at https://autotools.io/automake/maintainer.html.
AM_MAINTAINER_MODE([enable])
# Enable a recursive "tidy" rule for clang-tidy.
AM_EXTRA_RECURSIVE_TARGETS([tidy])
AC_CONFIG_HEADERS([lib/ink_autoconf.h])
# Configure with --disable-silent-rules to get verbose output. For more info, see
# http://www.gnu.org/software/automake/manual/html_node/Automake-silent_002drules-Option.html
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
# Libtool versioning uses different conventions on different
# platforms. At least on FreeBSD, libtool uses an overly complex
# convention that attempts to solve problems that most people just
# don't have and which just causes confusion for most end users.
#
TS_VERSION_MAJOR=$((TS_VERSION_N() / 1000000 ))
TS_VERSION_MINOR=$(((TS_VERSION_N() / 1000) % 1000 ))
TS_VERSION_MICRO=$((TS_VERSION_N() % 1000 ))
TS_LIBTOOL_MAJOR=`echo $((${TS_VERSION_MAJOR} + ${TS_VERSION_MINOR}))`
TS_LIBTOOL_VERSION=$TS_LIBTOOL_MAJOR:$TS_VERSION_MICRO:$TS_VERSION_MINOR
TS_VERSION_STRING=TS_VERSION_S()
TS_VERSION_NUMBER=TS_VERSION_N()
#
# Substitute the above version numbers into the various files below.
#
AC_SUBST(TS_LIBTOOL_VERSION)
AC_SUBST(TS_VERSION_STRING)
AC_SUBST(TS_VERSION_NUMBER)
AC_SUBST(TS_VERSION_MAJOR)
AC_SUBST(TS_VERSION_MINOR)
AC_SUBST(TS_VERSION_MICRO)
dnl Hard-coded top of ink_autoconf.h:
AH_TOP([
#ifndef _ink_autoconf_h
#define _ink_autoconf_h
])
dnl Hard-coded inclusion at the tail end of ink_autoconf.h:
AH_BOTTOM([
#endif /* _ink_autoconf_h */
])
#
# Generate ./config.nice for reproducing runs of configure
#
TS_CONFIG_NICE([config.nice])
# XXX we can't just use AC_PREFIX_DEFAULT because that isn't subbed in
# by configure until it is too late. Is that how it should be or not?
# Something seems broken here.
AC_PREFIX_DEFAULT([/usr/local/trafficserver])
# Get the layout here, so we can pass the required variables to Trafficserver
TS_ENABLE_LAYOUT(TrafficServer, [cachedir docdir])
# Reparse the configure arguments so we can override the layout.
TS_PARSE_ARGUMENTS
#
# Host detection
#
AC_CANONICAL_HOST
HOST_GUESS="$host"
AC_SUBST(HOST_GUESS)
AC_ARG_WITH([user],
[AS_HELP_STRING([--with-user],[specify the system user [default=nobody]])],
[
with_user="$withval"
],[
with_user="nobody"
]
)
default_group="`id -ng $with_user`"
AC_ARG_WITH([group],
[AS_HELP_STRING([--with-group],[specify the system group [default=nobody]])],
[
with_group="$withval"
],[
with_group=${default_group:-nobody}
]
)
AC_SUBST([pkgsysuser],[$with_user])
AC_SUBST([pkgsysgroup],[$with_group])
AC_ARG_WITH([build-number],
[AS_HELP_STRING([--with-build-number],[specify a version string for this build])],
[ build_number="$withval" ]
)
#
# Build environment
#
build_person="`id -nu | sed -e 's/\\\\/\\\\\\\\/g'`"
build_group="`id -ng | sed -e 's/\\\\/\\\\\\\\/g'`"
build_machine="`uname -n | sed -e 's/\\\\/\\\\\\\\/g'`"
AC_SUBST([build_machine])
AC_SUBST([build_person])
AC_SUBST([build_group])
AC_SUBST([build_number])
# -----------------------------------------------------------------------------
# 2. SITE CONFIGURATION
#
# Debug
#
AC_MSG_CHECKING([whether to enable debugging])
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],[turn on debugging])],
[],
[enable_debug=no]
)
AC_MSG_RESULT([$enable_debug])
# Enable code coverage instrumentation only if requested by the user.
AC_MSG_CHECKING([whether to code coverage])
AC_ARG_ENABLE([coverage],
[AS_HELP_STRING([--enable-coverage],[generate code coverage instrumentation])],
[],
[enable_coverage=no]
)
AC_MSG_RESULT([$enable_coverage])
#
# Enable -Werror. We want this enabled by default for developers, but disabled by default
# for end users (because we don't want released versions to suffer from compiler warning hell).
#
AC_MSG_CHECKING([whether to enable -Werror])
AC_ARG_ENABLE([werror],
[AS_HELP_STRING([--enable-werror],[turn compiler warnings into errors])],
[],
[enable_werror=no]
)
AC_MSG_RESULT([$enable_werror])
#
# Fast SDK APIs, this disables the parameter checks (assert)
# on all APIs.
#
AC_MSG_CHECKING([whether to enable fast SDK APIs])
AC_ARG_ENABLE([fast-sdk],
[AS_HELP_STRING([--enable-fast-sdk],[enable fast SDK APIs (no input parameter sanity checks)])],
[],
[enable_fast_sdk=no]
)
AC_MSG_RESULT([$enable_fast_sdk])
TS_ARG_ENABLE_VAR([use], [fast-sdk])
#
# Diags
#
AC_MSG_CHECKING([whether to enable diags])
AC_ARG_ENABLE([diags],
[AS_HELP_STRING([--disable-diags],[turn off diags])],
[],
[enable_diags=yes]
)
AC_MSG_RESULT([$enable_diags])
TS_ARG_ENABLE_VAR([use], [diags])
#
# Build regression tests?
#
AC_MSG_CHECKING([whether to enable regression tests])
AC_ARG_ENABLE([tests],
[AS_HELP_STRING([--disable-tests],[turn off regression tests])],
[],
[enable_tests=yes]
)
AC_MSG_RESULT([$enable_tests])
TS_ARG_ENABLE_VAR([has], [tests])
AM_CONDITIONAL([BUILD_TESTS], [test 0 -ne $has_tests])
#
# Force some static linkage (for testing / development only)
#
AC_MSG_CHECKING([whether to build a static traffic_server binary])
AC_ARG_ENABLE([static-proxy], [AS_HELP_STRING([--enable-static-proxy],[build a static traffic_server binary])], [
AC_ENABLE_STATIC
], [
AC_DISABLE_STATIC
enable_static_proxy=no
]
)
AC_MSG_RESULT([$enable_static_proxy])
TS_ARG_ENABLE_VAR([has],[static-proxy])
AM_CONDITIONAL([BUILD_STATIC_PROXY], [test 0 -ne $has_static_proxy])
#
# Remote Coverity Prevent commit
#
AC_MSG_CHECKING([whether to commit cov defects to remote host])
AC_ARG_ENABLE([remote-cov-commit],
[AS_HELP_STRING([--enable-remote-cov-commit[=HOST]], [commit cov defects to remote host [HOST=localhost]])],
[],
[enable_remote_cov_commit=localhost]
)
AC_MSG_RESULT([$enable_remote_cov_commit])
AC_SUBST([enable_remote_cov_commit])
#
# WCCP
#
AC_MSG_CHECKING([whether to enable WCCP v2 support])
AC_ARG_ENABLE([wccp],
[AS_HELP_STRING([--enable-wccp],[enable WCCP v2])],
[],
[enable_wccp=no]
)
AC_MSG_RESULT([$enable_wccp])
TS_ARG_ENABLE_VAR([has],[wccp])
AM_CONDITIONAL([BUILD_WCCP], [test 0 -ne $has_wccp])
# Google profiler
AC_MSG_CHECKING([whether to enable profiler])
AC_ARG_WITH([profiler],
[AS_HELP_STRING([--with-profiler],[enable support for profiler [default=no]])],
[with_profiler=$withval],
[with_profiler=no]
)
AC_MSG_RESULT([$with_profiler])
#
# use eventfd() or pipes
# Found that ec2 is using an older kernel causing eventfd errors.
# Disable eventfd when using ATS on EC2 Fedora.
#
AC_MSG_CHECKING([whether to enable eventfd()])
AC_ARG_ENABLE([eventfd],
[AS_HELP_STRING([--disable-eventfd],[turn off eventfd and use pipes])],
[],
[enable_eventfd="yes"]
)
AC_MSG_RESULT([$enable_eventfd])
#
# use POSIX capabilities instead of user ID switching.
#
AC_MSG_CHECKING([whether to use POSIX capabilities])
AC_ARG_ENABLE([posix-cap],
[AS_HELP_STRING([--disable-posix-cap],[Use user id switching instead of POSIX capabilities])],
[],
[enable_posix_cap="auto"]
)
AC_MSG_RESULT([$enable_posix_cap])
#
# use hwloc library when possible (can be disabled)
#
AC_MSG_CHECKING([whether to use hwloc library])
AC_ARG_ENABLE([hwloc],
[AS_HELP_STRING([--disable-hwloc],[Don't use the hwloc library])],
[],
[enable_hwloc="yes"]
)
AC_MSG_RESULT([$enable_hwloc])
#
# Enble ccache explicitly (it's disabled by default, because of build problems in some cases)
#
AC_MSG_CHECKING([whether to enable ccache])
AC_ARG_ENABLE([ccache],
[AS_HELP_STRING([--enable-ccache],[Enable ccache (for developers)])],
[],
[enable_ccache="no"]
)
AC_MSG_RESULT([$enable_ccache])
#
# Enble hardening of the executables
#
AC_MSG_CHECKING([whether to enable hardening of the executables])
AC_ARG_ENABLE([hardening],
[AS_HELP_STRING([--enable-hardening],[Enable hardening of executables])],
[],
[enable_hardening="no"]
)
AC_MSG_RESULT([$enable_hardening])
#
# Enable SSLv3 to origin
#
AC_MSG_CHECKING([whether to enable SSLv3 config for origin connections])
AC_ARG_ENABLE([sslv3-client],
[AS_HELP_STRING([--enable-sslv3-client],[Enable SSLv3 config for origin connections (Only do this if you understand the risks)])],
[],
[enable_sslv3_client="no"]
)
AC_MSG_RESULT([$enable_sslv3_client])
TS_ARG_ENABLE_VAR([use], [sslv3-client])
#
# Use TPROXY for connection transparency.
#
AC_MSG_CHECKING([whether to enable TPROXY based transparency])
AC_ARG_ENABLE([tproxy],
[AS_HELP_STRING([--enable-tproxy[[=ARG]]],
[Use TPROXY to enable connection transparency.
'auto' or omitted for local system default,
'no' to disable,
'force' to use built in default,
number to use as IP_TRANSPARENT sockopt.
[default=auto]
])
],
[],
[enable_tproxy="auto"]
)
AC_MSG_RESULT([$enable_tproxy])
#
# Configure how many stats to allocate for plugins. Default is 512.
#
AC_ARG_WITH([max-api-stats],
[AS_HELP_STRING([--with-max-api-stats],[max number of plugin stats [default=512]])],
[max_api_stats=$withval],
[max_api_stats=512]
)
AC_SUBST(max_api_stats)
#
# Max host name length that we deal with in URLs.
#
AC_ARG_WITH([max-host-name-len],
[AS_HELP_STRING([--with-max-host-name-len],[max host name length [default=256]])],
[max_host_name_len=$withval],
[max_host_name_len=256]
)
AC_SUBST(max_host_name_len)
#
# EventProcessor thread configurations
#
AC_ARG_WITH([max-event-threads],
[AS_HELP_STRING([--with-max-event-threads],[max number of event threads [default=4096]])],
[max_event_threads=$withval],
[max_event_threads=4096]
)
AC_SUBST(max_event_threads)
AC_ARG_WITH([max-threads-per-type],
[AS_HELP_STRING([--with-max-threads-per-type],[max number of threads per event type [default=3072]])],
[max_threads_per_type=$withval],
[max_threads_per_type=3072]
)
AC_SUBST(max_threads_per_type)
#
# Experimental plugins
#
AC_MSG_CHECKING([whether to enable experimental plugins])
AC_ARG_ENABLE([experimental-plugins],
[AS_HELP_STRING([--enable-experimental-plugins],[build experimental plugins])],
[],
[enable_experimental_plugins=no]
)
AC_MSG_RESULT([$enable_experimental_plugins])
AM_CONDITIONAL([BUILD_EXPERIMENTAL_PLUGINS], [ test "x${enable_experimental_plugins}" = "xyes" ])
#
# Enable experimental/memcached_remap plugin
#
PKG_CHECK_MODULES([LIBMEMCACHED], [libmemcached >= 1.0], [have_libmemcached=yes], [have_libmemcached=no])
AM_CONDITIONAL([BUILD_MEMCACHED_REMAP_PLUGIN], [test "x${have_libmemcached}" = "xyes"])
#
# Check Magick++ is available. Enable experimental/webp_transform plugin
#
PKG_CHECK_MODULES([LIBMAGICKCPP],[Magick++], [
have_libmagickcpp=yes
AS_IF([test "x$enable_experimental_plugins" = "xyes"], [
enable_webp_transform_plugin=yes
])
],
[
have_libmagickcpp=no
])
AM_CONDITIONAL([BUILD_WEBP_TRANSFORM_PLUGIN], [test "x${enable_webp_transform_plugin}" = "xyes"])
#
# Example plugins. The example plugins are always built, but not always installed. Installing
# them is useful for QA, but not useful for most users, so we default this to disabled.
#
AC_MSG_CHECKING([whether to install example plugins])
AC_ARG_ENABLE([example-plugins],
[AS_HELP_STRING([--enable-example-plugins],[install example plugins])],
[],
[enable_example_plugins=no]
)
AC_MSG_RESULT([$enable_example_plugins])
AM_CONDITIONAL([BUILD_EXAMPLE_PLUGINS], [ test "x${enable_example_plugins}" = "xyes" ])
#
# Test tools. The test tools are always built, but not always installed. Installing
# them is useful for QA, but not useful for most users, so we default this to disabled.
#
AC_MSG_CHECKING([whether to install testing tools])
AC_ARG_ENABLE([test-tools],
[AS_HELP_STRING([--enable-test-tools],[install testing tools])],
[],
[enable_test_tools=no]
)
AC_MSG_RESULT([$enable_test_tools])
AM_CONDITIONAL([BUILD_TEST_TOOLS], [ test "x${enable_test_tools}" = "xyes" ])
#
# Check if we should allow builds on 32-bit platforms
#
AC_MSG_CHECKING([whether to allow 32-bit builds])
AC_ARG_ENABLE([32bit-build],
[AS_HELP_STRING([--enable-32bit-build],[allow 32bit builds])],
[],
[enable_32bit=no]
)
AC_MSG_RESULT([$enable_32bit])
#
# Installation directories
# For each var the following is evaluated
# foo Standard variable eg. ${prefix}/foo
# rel_foo Relative to prefix eg. foo
#
TS_SUBST_LAYOUT_PATH([prefix])
TS_SUBST_LAYOUT_PATH([exec_prefix])
TS_SUBST_LAYOUT_PATH([bindir])
TS_SUBST_LAYOUT_PATH([sbindir])
TS_SUBST_LAYOUT_PATH([libdir])
TS_SUBST_LAYOUT_PATH([libexecdir])
TS_SUBST_LAYOUT_PATH([infodir])
TS_SUBST_LAYOUT_PATH([mandir])
TS_SUBST_LAYOUT_PATH([sysconfdir])
TS_SUBST_LAYOUT_PATH([datadir])
TS_SUBST_LAYOUT_PATH([installbuilddir])
TS_SUBST_LAYOUT_PATH([includedir])
TS_SUBST_LAYOUT_PATH([localstatedir])
TS_SUBST_LAYOUT_PATH([runtimedir])
TS_SUBST_LAYOUT_PATH([logdir])
TS_SUBST_LAYOUT_PATH([cachedir])
TS_SUBST_LAYOUT_PATH([docdir])
TS_SUBST([pkgbindir])
TS_SUBST([pkgsbindir])
TS_SUBST([pkglibdir])
TS_SUBST([pkglibexecdir])
TS_SUBST([pkgsysconfdir])
TS_SUBST([pkgdatadir])
TS_SUBST([pkglocalstatedir])
TS_SUBST([pkgruntimedir])
TS_SUBST([pkglogdir])
TS_SUBST([pkgcachedir])
TS_SUBST([pkgdocdir])
# -----------------------------------------------------------------------------
# 3. CHECK FOR PROGRAMS
# Compiler selection:
#
# Implementation note (toc)
# 1) Get default compiler settings (case statement.)
# 2) Check for over-rides of default compiler.
# 3) Set standard CFLAGS, SHARED_CFLAGS, etc.
# 4) (in first kludge mode block...) obtain any further CFLAG-type additions.
# 5) Test compilers with all flags set.
# AC_PROG can sometimes mangle CFLAGS etc.
# in particular, on Linux they insert -g -O2, here we preserve any user CFLAGS
_ts_saved_CFLAGS="${CFLAGS}"
_ts_saved_CXXFLAGS="${CXXFLAGS}"
# We force the compiler search list because the default GCC on Darwin cannot build
# Traffic Server. On most (all?) platforms, cc and c++ should be the preferred default
# compiler.
AC_PROG_CC([cc gcc clang icc])
AC_PROG_CXX([c++ g++ clang++ icpc])
AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_CXXCPP
AM_PROG_AS
AX_COMPILER_VENDOR
CFLAGS="${_ts_saved_CFLAGS}"
CXXFLAGS="${_ts_saved_CXXFLAGS}"
# All compilers we support have 'gnu99' as an available C standard
TS_ADDTO(CFLAGS, [-std=gnu99])
TS_ADDTO(CXXFLAGS, [-std=c++11])
dnl AC_PROG_SED is only available from version 2.6 (released in 2003). CentosOS
dnl 5.9 still has an ancient version, but we have macros that require
dnl AC_PROG_SED. The actual AC_PROG_SED macro does functional checks, but here
dnl we define a trivial local version for times when we are running on
dnl obsoldete autoconf.
ifdef([AC_PROG_SED], [], [
AC_DEFUN([AC_PROG_SED], [
AC_CHECK_PROG(SED, sed, sed)
])
])
# Various OS specific setup. Note that on Solaris, 32-bit is always the
# default, even on a box that with 64-bit architecture.
# This also sets up a "normalized" variable and define $host_os_def.
defer_accept=1
case $host_os in
linux*)
host_os_def="linux"
defer_accept=45
EXTRA_CXX_LDFLAGS="-rdynamic"
;;
darwin*)
host_os_def="darwin"
;;
freebsd*)
host_os_def="freebsd"
EXTRA_CXX_LDFLAGS="-rdynamic"
TS_ADDTO(CPPFLAGS, [-I/usr/local/include])
;;
kfreebsd*)
host_os_def="freebsd"
EXTRA_CXX_LDFLAGS="-rdynamic"
TS_ADDTO(CPPFLAGS, [-I/usr/local/include])
TS_ADDTO(CPPFLAGS, [-Dkfreebsd])
;;
openbsd*)
host_os_def="openbsd"
;;
solaris*)
host_os_def="solaris"
case "`isalist`" in
*amd64*)
TS_ADDTO(CFLAGS, -m64)
TS_ADDTO(CXXFLAGS, -m64)
TS_ADDTO(LUA_LDFLAGS, -m64)
;;
esac
;;
*)
EXTRA_CXX_LDFLAGS="-rdynamic"
host_os_def=unknown
;;
esac
TS_ADDTO(CPPFLAGS, [-D$host_os_def])
AC_SUBST(defer_accept)
dnl AM_PROG_AR is not always available, but it doesn't seem to be needed in older versions.
ifdef([AM_PROG_AR],
[AM_PROG_AR])
AC_PROG_AWK
AC_PROG_SED
AC_PROG_LN_S
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_CHECK_PROG(RM, rm, rm)
AC_CHECK_PROG(ASCPP, cpp, cpp)
AC_CHECK_TOOL(AR, ar, ar)
AC_ISC_POSIX
AM_PATH_PYTHON([2.4], [
dnl action-if-found
TS_MAN1_MANPAGES=`cd $srcdir/doc && $PYTHON manpages.py --section=1 | $AWK '{print "$(BUILDDIR)/man/" $0 }' | tr '\n' ' '`
TS_MAN3_MANPAGES=`cd $srcdir/doc && $PYTHON manpages.py --section=3 | $AWK '{print "$(BUILDDIR)/man/" $0 }' | tr '\n' ' '`
TS_MAN5_MANPAGES=`cd $srcdir/doc && $PYTHON manpages.py --section=5 | $AWK '{print "$(BUILDDIR)/man/" $0 }' | tr '\n' ' '`
TS_MAN8_MANPAGES=`cd $srcdir/doc && $PYTHON manpages.py --section=8 | $AWK '{print "$(BUILDDIR)/man/" $0 }' | tr '\n' ' '`
# If we have python, check if the Sphinx version looks OK.
AS_IF(["$PYTHON" "$srcdir/doc/checkvers.py" --check-version], [
sphinx_version_check=yes
])
], [
dnl action-if-not-found
:
])
AC_ARG_VAR(RPATH, [path to be added to rpath])
AC_ARG_VAR(SPHINXBUILD, [the sphinx-build documentation generator])
AC_ARG_VAR(SPHINXOPTS, [additional sphinx-build options])
AC_CHECK_PROG([SPHINXBUILD], [sphinx-build], [sphinx-build], [false])
AC_ARG_VAR([CLANG_TIDY], [clang-tidy command])
# Default CLANG_TIDY to "clang-tidy", or "false" if it is not present.
AC_PATH_PROG([CLANG_TIDY], [clang-tidy],[false])
AC_SUBST(TS_MAN1_MANPAGES)
AC_SUBST(TS_MAN3_MANPAGES)
AC_SUBST(TS_MAN5_MANPAGES)
AC_SUBST(TS_MAN8_MANPAGES)
AC_MSG_CHECKING([whether to build man pages])
AS_IF([test "x$sphinx_version_check" = "xyes" -a "x$SPHINXBUILD" != "xfalse"], [
AM_CONDITIONAL([BUILD_MANPAGES], [true])
AC_MSG_RESULT([yes])
], [
AM_CONDITIONAL([BUILD_MANPAGES], [false])
AC_MSG_RESULT([no])
])
# Do bison check by hand because we must do a version check.
# Use YACC because it makes autotools shut up.
BISON_MAJOR=2
BISON_MINOR=4
BISON_POINT=1
AC_CHECK_PROG([YACC],[bison],[bison])
AS_IF([test -n "$YACC"],
[ bison_version_check=`$YACC --version 2>&1 | \
$SED -n '/bison/s/^[[^0-9]]*\([[0-9]][[0-9.]]*\).*$/\1/p' | \
$AWK "{ if (\\$1 > $BISON_MAJOR || (\\$1 == $BISON_MAJOR && (\\$2 > $BISON_MINOR || (\\$2 == $BISON_MINOR && (NR == 2 || \\$3 >= $BISON_POINT))))) print \"yes\"; else printf(\"version %d.%d.%d\",\\$1,\\$2,\\$3); }" FS=. \
`
AS_IF([test "x$bison_version_check" != "xyes"],
[ YACC=''
AS_IF([test -z "$bison_version_check"],
[bison_version_check='no version data']
)
]
)
],
[ YACC=''
bison_version_check="nothing"
]
)
# Check lex/flex by hand because we need flex of a sufficient version.
FLEX_MAJOR=2
FLEX_MINOR=5
FLEX_POINT=33
dnl ylwrap requires the lexer executable to be an absolute path or in the srcdir.
dnl but we need various other LEX values.
AC_PROG_LEX
AS_IF([test -n "$LEX"],
[ flex_version_check=`$LEX --version 2>&1 | \
$SED -n '/flex/s/^[[^0-9]]*\([[0-9]][[0-9.]]*\)[[^0-9]]*.*$/\1/p' | \
$AWK "{ if (\\$1 > $FLEX_MAJOR || (\\$1 == $FLEX_MAJOR && (\\$2 > $FLEX_MINOR || (\\$2 == $FLEX_MINOR && (NR == 2 || \\$3 >= $FLEX_POINT))))) print \"yes\"; else printf(\"version %d.%d.%d\",\\$1,\\$2,\\$3); }" FS=. \
`
AS_IF([test "x$flex_version_check" != "xyes"],
[ LEX=''
AS_IF([test -z "$flex_version_check"],
[flex_version_check='no version data']
)
]
)
],
[ LEX=''
flex_version_check="nothing"
]
)
# Generated files checked in, only build them if the local OS has the necessary support.
# Otherwise just use the checked in version.
AM_CONDITIONAL([BUILD_TSCONFIG_GRAMMAR], [ test -n "$LEX" && test -n "$YACC" ])
# Check for Perl and Doxygen
AC_PATH_PROG([DOXYGEN], [doxygen]) # needed for Doxygen
AC_PATH_PROG([PERL], [perl],[not found])
AS_IF([test "x$PERL" = "xnot found"],
[AC_MSG_ERROR([check for perl failed. Have you installed perl?])]
)
AC_ARG_VAR([DOXYGEN], [full path of Doxygen executable])
AC_ARG_VAR([PERL], [full path of Perl executable])
# Check if MakeMaker is available
AX_PROG_PERL_MODULES([ExtUtils::MakeMaker], AM_CONDITIONAL([BUILD_PERL_LIB], [true]),
AM_CONDITIONAL([BUILD_PERL_LIB], [false])
)
# Check for GNU-style -On optimization flags
AC_MSG_CHECKING([checking whether to auto-set compiler optimization flags])
has_optimizer_flags=`echo "$CFLAGS $CXXFLAGS" | ${AWK} '$0 !~ /-O.?/{print "no"}'`
AS_IF([test "x${has_optimizer_flags}" = "xno"],
[
optimizing_flags='-O3'
AC_MSG_RESULT([yes ${optimizing_flags}])
],
[
has_optimizer_flags='yes'
optimizing_flags=''
AC_MSG_RESULT([no])
]
)
case $host_os_def in
linux)
AS_IF([test "x$ax_cv_c_compiler_vendor" = "xintel"], [
# -Wall goes crazy, so turned these specific checks off for now:
#
# 111 is "statement is unreachable"
# 279 is "controlling expression is constant", triggered by our asserts
# 383 is "value copied to temporary, reference to temporary used"
# 444 is "destructor for base class is not virtual"
# 522 is "function "xyz" redeclared "inline" after being called
# 873 is "has no corresponding operator delete". ToDo: we should fix.
# 981 is "operands are evaluated in unspecified order"
# 1418 is "external function definition with no prior declaration"
# 1419 is "external declaration in primary source file"
# 1572 is "floating-point equality and inequality comparisons are unreliable"
# 1720 is "operator new" has no corresponding member operator delete"
# 2256 is "non-pointer conversion from "int" to "unsigned char" "
# 2259 is "non-pointer conversion from "int" to "unsigned char" "
#
# TODO: We should try to eliminate more of these -wd exclusions.
common_opt="-pipe -Wall -wd111 -wd279 -wd383 -wd522 -wd444 -wd873 -wd981 -wd1418 -wd1419 -wd1572 -wd1720 -wd2256 -wd2259"
debug_opt="-ggdb3 $common_opt"
release_opt="-g $common_opt $optimization_flags -axsse4.2 -fno-strict-aliasing"
cxx_opt="-Wno-invalid-offsetof"
])
AS_IF([test "x$ax_cv_c_compiler_vendor" = "xclang"], [
common_opt="-pipe -Wall -Wno-deprecated-declarations -Qunused-arguments"
debug_opt="-ggdb3 $common_opt -Qunused-arguments"
release_opt="-g $common_opt $optimizing_flags -fno-strict-aliasing -Qunused-arguments"
cxx_opt="-Wno-invalid-offsetof"
lua_cflags="-Wno-parentheses-equality -Wno-tautological-compare -analyzer-disable-all-checks"
])
AS_IF([test "x$ax_cv_c_compiler_vendor" = "xgnu"], [
# This is useful for finding odd conversions
# common_opt="-pipe -Wall -Wconversion -Wno-sign-conversion"
common_opt="-pipe -Wall"
debug_opt="-ggdb3 $common_opt"
release_opt="-g $common_opt $optimizing_flags -feliminate-unused-debug-symbols -fno-strict-aliasing"
cxx_opt="-Wno-invalid-offsetof"
# Special options for flex generated .c files
flex_cflags="-Wno-unused-parameter"
])
;; # linux)
darwin)
AS_IF([test "x$ax_cv_c_compiler_vendor" = "xclang"], [
common_opt="-pipe -Wall -Wno-deprecated-declarations -Qunused-arguments"
debug_opt="-g $common_opt"
release_opt="-g $common_opt $optimizing_flags -fno-strict-aliasing"
cxx_opt="-Wno-invalid-offsetof"
lua_cflags="-Wno-parentheses-equality -Wno-tautological-compare"
], [
AC_MSG_WARN([clang is the only supported compiler on Darwin])
])
# NOTE: This seems semi-kludgy, but useful for MacPorts I think.
AS_IF([test -d /opt/local/include], [
TS_ADDTO(CPPFLAGS, [-I/opt/local/include])
])
AS_IF([test -d /opt/local/lib], [
TS_ADDTO(LDFLAGS, [-L/opt/local/lib])
])
;; # darwin)
freebsd|kfreebsd)
AS_IF([test "x$ax_cv_c_compiler_vendor" = "xclang"], [
common_opt="-pipe -Wall -Wno-deprecated-declarations -Qunused-arguments"
debug_opt="-ggdb3 $common_opt"
release_opt="-g $common_opt $optimizing_flags -fno-strict-aliasing"
cxx_opt="-Wno-invalid-offsetof"
lua_cflags="-Wno-parentheses-equality -Wno-tautological-compare"
])
AS_IF([test "x$ax_cv_c_compiler_vendor" = "xgnu"], [
common_opt="-pipe -Wall"
debug_opt="-ggdb3 $common_opt"
release_opt="-g $common_opt $optimizing_flags -feliminate-unused-debug-symbols -fno-strict-aliasing"
cxx_opt="-Wno-invalid-offsetof"
])
AS_IF([test -d /usr/local/lib], [
TS_ADDTO(LDFLAGS, [-L/usr/local/lib])
])
;; # freebsd|kfreebsd)
solaris)
AS_IF([test "x$ax_cv_c_compiler_vendor" = "xgnu"], [
common_opt="-pipe -Wall"
debug_opt="-ggdb3 $common_opt"
release_opt="-g $common_opt $optimizing_flags -feliminate-unused-debug-symbols -fno-strict-aliasing"
cxx_opt="-Wno-invalid-offsetof"
])
;; # solaris)
*)
# Not sure what platform this is, but take a stab at some general GCC options ...
AS_IF([test "x$ax_cv_c_compiler_vendor" = "xgnu"], [
common_opt="-pipe -Wall"
debug_opt="-ggdb3 $common_opt"
release_opt="-g $common_opt $optimizing_flags -feliminate-unused-debug-symbols -fno-strict-aliasing"
cxx_opt="-Wno-invalid-offsetof"
])
esac
AS_IF([test x"$enable_coverage" = "xyes"], [
# Map per-compiler code coverage instrumentation flags. Note that
# we don't test whether the compiler actually support these options
# (we don't do that in general). The user is expected to use a modern,
# supported compiler to test coverage.
AS_CASE("$ax_cv_c_compiler_vendor",
[clang], [
TS_ADDTO(CXXFLAGS, "-fprofile-instr-generate")
TS_ADDTO(CXXFLAGS, "-fcoverage-mapping")
TS_ADDTO(CFLAGS, "-fprofile-instr-generate")
TS_ADDTO(CFLAGS, "-fcoverage-mapping")
], [gnu], [
TS_ADDTO(CXXFLAGS, "--coverage")
TS_ADDTO(CFLAGS, "--coverage")
TS_ADDTO(LIBS, "-lgcov")
])
])
# Only add -Werror if the user has requested it. We enable this by default for
# development, disable it by default for release.
AS_IF([test x"$enable_werror" = "xyes"], [
TS_ADDTO(release_opt, -Werror)
TS_ADDTO(debug_opt, -Werror)
])
cc_oflag_opt=$release_opt
cc_oflag_dbg=$debug_opt
cxx_oflag_opt="$release_opt $cxx_opt $cxx_rel"
cxx_oflag_dbg="$debug_opt $cxx_opt $cxx_dbg"
AM_CFLAGS="$ts_am_common_flags"
AM_CXXFLAGS="$ts_am_common_flags"
AC_SUBST(AM_CFLAGS)
AC_SUBST(AM_CXXFLAGS)
# Special compiler flag hacks for various pieces of the code
AC_SUBST([FLEX_CFLAGS], $flex_cflags)
SHARED_CFLAGS=-fPIC
SHARED_LDFLAGS=-shared
SHARED_CXXFLAGS=-fPIC
SHARED_CXXLINKFLAGS=-shared
#
# _Here_ is where we go ahead and add the _optimizations_ to already
# existing CFLAGS/CXXFLAGS if some special values had been set.
#
if test "x${enable_debug}" = "xyes"; then
TS_ADDTO(CFLAGS, [${cc_oflag_dbg}])
TS_ADDTO(CXXFLAGS, [${cxx_oflag_dbg}])
TS_ADDTO(CPPFLAGS, [-DDEBUG -D_DEBUG])
else
TS_ADDTO(CFLAGS, [${cc_oflag_opt}])
TS_ADDTO(CXXFLAGS, [${cxx_oflag_opt}])
fi
# Checks for pointer size.
# TODO: Later this is irrelevant, and we should just bail on 32-bit platforms always
AC_CHECK_SIZEOF([void*])
if test "x$ac_cv_sizeof_voidp" == "x"; then
AC_ERROR([Cannot determine size of void*])
fi
AC_SUBST(ac_cv_sizeof_voidp)
# Right now, 32-bit platform is a build error, unless we've forced it with --enable-32bit-build
if test "${ac_cv_sizeof_voidp}" = "4"; then
AS_IF([test x"$enable_32bit_build" = "xyes"], [
AC_MSG_NOTICE([Explicitly building on a 32-bit platform, this might be unsupported soon!])
], [
AC_ERROR([You are trying to build on a 32-bit platform, which is unsupported.])
])
fi
#
# Here are all the extra linux-specific C(XX)FLAGS additions and
# so forth.
# TODO cpu architecture settings separate from operating system settings
#
cpu_architecture=""
# GCC: add a default march if there is not one set
if test "x${GCC}" = "xyes"; then
if test "${ac_cv_sizeof_voidp}" = "4"; then
case "$host_cpu" in
i?86* | k[5-8]* | pentium* | athlon)
cpu_architecture="-march=i586"
;;
esac
else
case "$host_cpu" in
x86_64 | amd64)
# XXX: Any need for 64-bit arch flags?
# cpu_architecture="-march=native"
;;
esac
fi
fi
# Overrride detected architecture with the user suplied one
#
AC_ARG_WITH(architecture, [AC_HELP_STRING([--with-architecture=ARCH],[use a specific CPU architecture])],
[
if test "x$withval" != "xyes" && test "x$withval" != "xno"; then
case "$withval" in
-*)
# TODO: In case we are cross compiling some of the provided flags
# should be added to the LDFLAGS
cpu_architecture="$withval"
;;
*)
cpu_architecture="-march=$withval"
;;
esac
elif test "x$withval" = "x"; then
AC_MSG_ERROR([--with-architecture requires an param])
fi
])
if test "x$cpu_architecture" != "x"; then
TS_ADDTO(CFLAGS, [$cpu_architecture])
TS_ADDTO(CXXFLAGS, [$cpu_architecture])
fi
# 64-bit LFS support
#
TS_ADDTO(CPPFLAGS, [-D_LARGEFILE64_SOURCE=1])
if test "${ac_cv_sizeof_voidp}" = "8"; then
TS_ADDTO(CPPFLAGS, [-D_COMPILE64BIT_SOURCE=1])
else
TS_ADDTO(CPPFLAGS, [-D_FILE_OFFSET_BITS=64])
fi
TS_ADDTO(CPPFLAGS, [-D_GNU_SOURCE])
TS_ADDTO(CPPFLAGS, [-D_REENTRANT])
TS_ADDTO(CPPFLAGS, [-D__STDC_LIMIT_MACROS=1])
TS_ADDTO(CPPFLAGS, [-D__STDC_FORMAT_MACROS=1])
AC_MSG_NOTICE([Build for host OS: $host_os, arch: $host_cpu, optimization: $host_os_def])
# Add hardening options to flags