1# Process this file with `autoreconf -i` to create a 'configure' file.
2
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#      http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing, software
14#  distributed under the License is distributed on an "AS IS" BASIS,
15#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16#  See the License for the specific language governing permissions and
17#  limitations under the License.
18
19# Table of Contents
20# 1. INITIALIZATION
21# 2. SITE CONFIGURATION
22# 3. CHECK FOR PROGRAMS
23# 4. CHECK FOR LIBRARIES
24# 5. CHECK FOR HEADERS
25# 6. OUTPUT FILES
26# 7. autoheader TEMPLATES
27
28# -----------------------------------------------------------------------------
29# 1. INITIALIZATION
30
31# These first two version numbers are updated automatically on each release.
32# Version number is calculated as MAJOR * 1000000 + MINOR * 1000 + MICRO
33# Version string is in the form of MAJOR.MINOR.MICRO[sufix]
34#
35m4_define([TS_VERSION_S],[9.1.1])
36m4_define([TS_VERSION_N],[9001001])
37
38AC_INIT([Apache Traffic Server], TS_VERSION_S(), [dev@trafficserver.apache.org], [trafficserver], [https://trafficserver.apache.org])
39AC_PREREQ([2.59])
40AC_CONFIG_AUX_DIR([build/_aux])
41AC_CONFIG_SRCDIR([src/traffic_server/traffic_server.cc])
42AC_CONFIG_MACRO_DIR([build])
43
44# NOTE: we turn off portability warnings because the clang-tidy targets use
45# GNU make extensions to filter the sources list.
46AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability tar-ustar foreign no-installinfo no-installman subdir-objects 1.9.2])
47
48# See discussion at https://autotools.io/automake/maintainer.html.
49AM_MAINTAINER_MODE([enable])
50
51# Enable a recursive "tidy" rule for clang-tidy.
52m4_ifdef([AM_EXTRA_RECURSIVE_TARGETS], [AM_EXTRA_RECURSIVE_TARGETS([clang-tidy])])
53
54AC_CONFIG_HEADERS([include/ink_autoconf.h])
55
56# Configure with --disable-silent-rules to get verbose output. For more info, see
57# http://www.gnu.org/software/automake/manual/html_node/Automake-silent_002drules-Option.html
58m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
59
60# Libtool versioning uses different conventions on different
61# platforms.  At least on FreeBSD, libtool uses an overly complex
62# convention that attempts to solve problems that most people just
63# don't have and which just causes confusion for most end users.
64#
65TS_VERSION_MAJOR=$((TS_VERSION_N() / 1000000 ))
66TS_VERSION_MINOR=$(((TS_VERSION_N() / 1000) % 1000 ))
67TS_VERSION_MICRO=$((TS_VERSION_N() % 1000 ))
68TS_LIBTOOL_MAJOR=`echo $((${TS_VERSION_MAJOR} + ${TS_VERSION_MINOR}))`
69TS_LIBTOOL_VERSION=$TS_LIBTOOL_MAJOR:$TS_VERSION_MICRO:$TS_VERSION_MINOR
70TS_VERSION_STRING=TS_VERSION_S()
71TS_VERSION_NUMBER=TS_VERSION_N()
72
73#
74# Substitute the above version numbers into the various files below.
75#
76AC_SUBST(TS_LIBTOOL_VERSION)
77AC_SUBST(TS_VERSION_STRING)
78AC_SUBST(TS_VERSION_NUMBER)
79AC_SUBST(TS_VERSION_MAJOR)
80AC_SUBST(TS_VERSION_MINOR)
81AC_SUBST(TS_VERSION_MICRO)
82
83dnl Hard-coded top of ink_autoconf.h:
84AH_TOP([
85#pragma once
86])
87
88#
89# Generate ./config.nice for reproducing runs of configure
90#
91TS_CONFIG_NICE([config.nice])
92
93# XXX we can't just use AC_PREFIX_DEFAULT because that isn't subbed in
94# by configure until it is too late.  Is that how it should be or not?
95# Something seems broken here.
96AC_PREFIX_DEFAULT([/usr/local/trafficserver])
97
98# Get the layout here, so we can pass the required variables to Trafficserver
99TS_ENABLE_LAYOUT(TrafficServer, [cachedir docdir])
100
101# Reparse the configure arguments so we can override the layout.
102TS_PARSE_ARGUMENTS
103
104#
105# Host detection
106#
107AC_CANONICAL_HOST
108HOST_GUESS="$host"
109AC_SUBST(HOST_GUESS)
110
111AC_ARG_WITH([user],
112  [AS_HELP_STRING([--with-user],[specify the system user [default=nobody]])],
113  [
114  with_user="$withval"
115  ],[
116  with_user="nobody"
117  ]
118)
119
120default_group="`id -ng $with_user`"
121AC_ARG_WITH([group],
122  [AS_HELP_STRING([--with-group],[specify the system group [default=nobody]])],
123  [
124  with_group="$withval"
125  ],[
126  with_group=${default_group:-nobody}
127  ]
128)
129AC_SUBST([pkgsysuser],[$with_user])
130AC_SUBST([pkgsysgroup],[$with_group])
131
132AC_ARG_WITH([build-number],
133  [AS_HELP_STRING([--with-build-number],[specify a version string for this build])],
134  [ build_number="$withval" ]
135)
136
137#
138# Build environment
139#
140build_person="`id -nu | sed -e 's/\\\\/\\\\\\\\/g'`"
141build_group="`id -ng | sed -e 's/\\\\/\\\\\\\\/g'`"
142build_machine="`uname -n | sed -e 's/\\\\/\\\\\\\\/g'`"
143AC_SUBST([build_machine])
144AC_SUBST([build_person])
145AC_SUBST([build_group])
146AC_SUBST([build_number])
147
148# -----------------------------------------------------------------------------
149# 2. SITE CONFIGURATION
150
151#
152# Debug
153#
154AC_MSG_CHECKING([whether to enable debugging])
155AC_ARG_ENABLE([debug],
156  [AS_HELP_STRING([--enable-debug],[turn on debugging])],
157  [],
158  [enable_debug=no]
159)
160AC_MSG_RESULT([$enable_debug])
161
162AC_MSG_CHECKING([whether to enable mime sanity check])
163AC_ARG_ENABLE([mime-sanity-check],
164  [AS_HELP_STRING([--enable-mime-sanity-check],[turn on mime sanity check])],
165  [],
166  [enable_mime_sanity_check=no]
167)
168AC_MSG_RESULT([$enable_mime_sanity_check])
169
170AC_MSG_CHECKING([whether to enable all asserts, a cheaper debug])
171AC_ARG_ENABLE([all-asserts],
172  [AS_HELP_STRING([--enable-all-asserts],[turn on all code asserts, both debug and release])],
173  [],
174  [enable_all_asserts=no]
175)
176AC_MSG_RESULT([$enable_all_asserts])
177
178
179# Enable code coverage instrumentation only if requested by the user.
180AC_MSG_CHECKING([whether to code coverage])
181AC_ARG_ENABLE([coverage],
182  [AS_HELP_STRING([--enable-coverage],[generate code coverage instrumentation])],
183  [],
184  [enable_coverage=no]
185)
186AC_MSG_RESULT([$enable_coverage])
187
188#
189# Enable -Werror. We want this enabled by default for developers, but disabled by default
190# for end users (because we don't want released versions to suffer from compiler warning hell).
191#
192AC_MSG_CHECKING([whether to enable -Werror])
193AC_ARG_ENABLE([werror],
194  [AS_HELP_STRING([--enable-werror],[turn compiler warnings into errors])],
195  [],
196  [enable_werror=no]
197)
198AC_MSG_RESULT([$enable_werror])
199
200# Enable ASAN for the builds
201AC_MSG_CHECKING([whether to enable asan])
202AC_ARG_ENABLE([asan],
203  [AS_HELP_STRING([--enable-asan],[enable Address Sanitizer])],
204  [],
205  [enable_asan=no]
206)
207AC_MSG_RESULT([$enable_asan])
208
209# Enable LSAN in stand-alone mode for the builds
210AC_MSG_CHECKING([whether to enable lsan])
211AC_ARG_ENABLE([lsan],
212  [AS_HELP_STRING([--enable-lsan],[enable stand-alone Leak Sanitizer])],
213  [],
214  [enable_lsan=no]
215)
216AC_MSG_RESULT([$enable_lsan])
217
218# Enable TSAN for the builds
219AC_MSG_CHECKING([whether to enable tsan])
220AC_ARG_ENABLE([tsan],
221  [AS_HELP_STRING([--enable-tsan],[turn on Thread Sanitizer])],
222  [],
223  [enable_tsan=no]
224)
225AC_MSG_RESULT([$enable_tsan])
226
227#
228# Fast SDK APIs, this disables the parameter checks (assert)
229# on all APIs.
230#
231
232AC_MSG_CHECKING([whether to enable fast SDK APIs])
233AC_ARG_ENABLE([fast-sdk],
234  [AS_HELP_STRING([--enable-fast-sdk],[enable fast SDK APIs (no input parameter sanity checks)])],
235  [],
236  [enable_fast_sdk=no]
237)
238AC_MSG_RESULT([$enable_fast_sdk])
239TS_ARG_ENABLE_VAR([use], [fast-sdk])
240
241# Curl support for traffic_top
242AC_MSG_CHECKING([whether to enable CURL])
243AC_ARG_ENABLE([curl],
244  [AS_HELP_STRING([--disable-curl],[turn off CURL support for traffic_top])],
245  [],
246  [enable_curl=yes]
247)
248AC_MSG_RESULT([$enable_curl])
249
250if test "x${enable_curl}" = "xyes"; then
251AX_LIB_CURL([7.19], [AC_DEFINE([HAS_CURL], [1], [Define if libcurl >= 7.19.])])
252fi
253
254#
255# Diags
256#
257
258AC_MSG_CHECKING([whether to enable diags])
259AC_ARG_ENABLE([diags],
260  [AS_HELP_STRING([--disable-diags],[turn off diags])],
261  [],
262  [enable_diags=yes]
263)
264AC_MSG_RESULT([$enable_diags])
265TS_ARG_ENABLE_VAR([use], [diags])
266
267#
268# FIPS
269#
270
271AC_MSG_CHECKING([whether to enable fips])
272AC_ARG_ENABLE([fips],
273  [AS_HELP_STRING([--enable-fips],[turn on FIPS compliance])],
274  [],
275  [enable_fips=no]
276)
277AC_MSG_RESULT([$enable_fips])
278TS_ARG_ENABLE_VAR([enable], [fips])
279
280#
281# Build regression tests?
282#
283
284AC_MSG_CHECKING([whether to enable regression tests])
285AC_ARG_ENABLE([tests],
286  [AS_HELP_STRING([--disable-tests],[turn off regression tests])],
287  [],
288  [enable_tests=yes]
289)
290AC_MSG_RESULT([$enable_tests])
291TS_ARG_ENABLE_VAR([has], [tests])
292AM_CONDITIONAL([BUILD_TESTS], [test 0 -ne $has_tests])
293
294#
295# Build expensive unit tests ?
296#
297
298AC_MSG_CHECKING([whether to enable expensive unit tests])
299AC_ARG_ENABLE([expensive-tests],
300  [AS_HELP_STRING([--enable-expensive-tests],[turn on expensive unit tests])],
301  [],
302  [enable_expensive_tests=no]
303)
304AC_MSG_RESULT([$enable_expensive_tests])
305TS_ARG_ENABLE_VAR([has], [expensive_tests])
306AM_CONDITIONAL([EXPENSIVE_TESTS], [test 0 -ne $has_expensive_tests])
307
308#
309# Build documentation?
310#
311
312# Java needed only for documentation building, but making it conditional
313# makes the diagnostic output ugly and hard to follow.
314AC_ARG_VAR(JAVA, [path to java executor])
315AC_CHECK_PROG(JAVA, java, java)
316AC_MSG_RESULT([Checking whether to build documentation:])
317AC_ARG_ENABLE([docs],
318  [AS_HELP_STRING([--enable-docs],[enable documentation building])],
319  [
320    enable_doc_build=yes
321    AM_PATH_PYTHON([3.4], [
322      TS_MAN1_MANPAGES=`cd $srcdir/doc && $PYTHON manpages.py --section=1 | $AWK '{print "$(BUILDDIR)/man/" $0 }' | tr '\n' ' '`
323      TS_MAN3_MANPAGES=`cd $srcdir/doc && $PYTHON manpages.py --section=3 | $AWK '{print "$(BUILDDIR)/man/" $0 }' | tr '\n' ' '`
324      TS_MAN5_MANPAGES=`cd $srcdir/doc && $PYTHON manpages.py --section=5 | $AWK '{print "$(BUILDDIR)/man/" $0 }' | tr '\n' ' '`
325      TS_MAN8_MANPAGES=`cd $srcdir/doc && $PYTHON manpages.py --section=8 | $AWK '{print "$(BUILDDIR)/man/" $0 }' | tr '\n' ' '`
326    ], [
327      enable_doc_build=no
328      AC_ERROR([Doc building disabled, python 3.4 or better required])
329    ])
330
331    AS_IF([test -z "$JAVA"],
332      [
333        enable_doc_build=no
334        AC_ERROR([Doc building disabled, java required but not found])
335      ])
336    AC_ARG_VAR(SPHINXBUILD, [the sphinx-build documentation generator])
337    AC_ARG_VAR(SPHINXOPTS, [additional sphinx-build options])
338    AC_PATH_PROG([SPHINXBUILD], [$SPHINXBUILD], [$PYTHON -m sphinx])
339    AS_IF(["$PYTHON" "$srcdir/doc/checkvers.py" --check-version],
340      [
341        sphinx_version_check=yes
342      ],[
343        sphinx_version_check=no
344        enable_doc_build=no
345        AC_ERROR([Doc building disabled, check sphinx installation])
346      ])
347
348
349    AC_SUBST(TS_MAN1_MANPAGES)
350    AC_SUBST(TS_MAN3_MANPAGES)
351    AC_SUBST(TS_MAN5_MANPAGES)
352    AC_SUBST(TS_MAN8_MANPAGES)
353
354    AC_MSG_CHECKING([whether to build man pages])
355    AS_IF([test "x$sphinx_version_check" = "xyes" -a "x$SPHINXBUILD" != "xfalse"], [
356      build_manpages=true
357      AC_MSG_RESULT([yes])
358    ], [
359      build_manpages=false
360      AC_MSG_RESULT([no])
361    ])
362
363  ],
364  [enable_doc_build=no]
365)
366AC_MSG_RESULT([Will build documentation: $enable_doc_build])
367AM_CONDITIONAL([BUILD_DOCS], [test "xyes" = "x$enable_doc_build"])
368AM_CONDITIONAL([BUILD_MANPAGES], [test "xtrue" = "x$build_manpages"])
369
370#
371# Remote Coverity Prevent commit
372#
373AC_MSG_CHECKING([whether to commit cov defects to remote host])
374AC_ARG_ENABLE([remote-cov-commit],
375  [AS_HELP_STRING([--enable-remote-cov-commit[=HOST]], [commit cov defects to remote host [HOST=localhost]])],
376  [],
377  [enable_remote_cov_commit=localhost]
378)
379AC_MSG_RESULT([$enable_remote_cov_commit])
380AC_SUBST([enable_remote_cov_commit])
381
382#
383# WCCP
384#
385AC_MSG_CHECKING([whether to enable WCCP v2 support])
386AC_ARG_ENABLE([wccp],
387  [AS_HELP_STRING([--enable-wccp],[enable WCCP v2])],
388  [],
389  [enable_wccp=no]
390)
391AC_MSG_RESULT([$enable_wccp])
392TS_ARG_ENABLE_VAR([has],[wccp])
393AM_CONDITIONAL([BUILD_WCCP], [test 0 -ne $has_wccp])
394
395# Google profiler
396AC_MSG_CHECKING([whether to enable profiler])
397AC_ARG_WITH([profiler],
398  [AS_HELP_STRING([--with-profiler],[enable support for profiler [default=no]])],
399  [with_profiler=$withval],
400  [with_profiler=no]
401)
402AC_MSG_RESULT([$with_profiler])
403
404# Disable all static library builds
405AC_DISABLE_STATIC
406
407#
408# use eventfd() or pipes
409# Found that ec2 is using an older kernel causing eventfd errors.
410# Disable eventfd when using ATS on EC2 Fedora.
411#
412AC_MSG_CHECKING([whether to enable eventfd()])
413AC_ARG_ENABLE([eventfd],
414  [AS_HELP_STRING([--disable-eventfd],[turn off eventfd and use pipes])],
415  [],
416  [enable_eventfd="yes"]
417)
418AC_MSG_RESULT([$enable_eventfd])
419
420#
421# use POSIX capabilities instead of user ID switching.
422#
423AC_MSG_CHECKING([whether to use POSIX capabilities])
424AC_ARG_ENABLE([posix-cap],
425  [AS_HELP_STRING([--disable-posix-cap],[Use user id switching instead of POSIX capabilities])],
426  [],
427  [enable_posix_cap="auto"]
428)
429AC_MSG_RESULT([$enable_posix_cap])
430
431#
432# use hwloc library when possible (can be disabled)
433#
434AC_MSG_CHECKING([whether to use hwloc library])
435AC_ARG_ENABLE([hwloc],
436  [AS_HELP_STRING([--disable-hwloc],[Don't use the hwloc library])],
437  [],
438  [enable_hwloc="yes"]
439)
440AC_MSG_RESULT([$enable_hwloc])
441
442#
443# Enable ccache explicitly (it's disabled by default, because of build problems in some cases)
444#
445AC_MSG_CHECKING([whether to enable ccache])
446AC_ARG_ENABLE([ccache],
447  [AS_HELP_STRING([--enable-ccache],[Enable ccache (for developers)])],
448  [],
449  [enable_ccache="no"]
450)
451AC_MSG_RESULT([$enable_ccache])
452
453#
454# Enable hardening of the executables
455#
456AC_MSG_CHECKING([whether to enable hardening of the executables])
457AC_ARG_ENABLE([hardening],
458  [AS_HELP_STRING([--enable-hardening],[Enable hardening of executables])],
459  [],
460  [enable_hardening="no"]
461)
462AC_MSG_RESULT([$enable_hardening])
463
464#
465# Use TPROXY for connection transparency.
466#
467AC_MSG_CHECKING([whether to enable TPROXY based transparency])
468AC_ARG_ENABLE([tproxy],
469  [AS_HELP_STRING([--enable-tproxy[[=ARG]]],
470                  [Use TPROXY to enable connection transparency.
471                   'auto' or omitted for local system default,
472                   'no' to disable,
473                   'force' to use built in default,
474                   number to use as IP_TRANSPARENT sockopt.
475                   [default=auto]
476                  ])
477  ],
478  [],
479  [enable_tproxy="auto"]
480)
481AC_MSG_RESULT([$enable_tproxy])
482
483#
484# Max host name length that we deal with in URLs.
485#
486AC_ARG_WITH([max-host-name-len],
487  [AS_HELP_STRING([--with-max-host-name-len],[max host name length [default=256]])],
488  [max_host_name_len=$withval],
489  [max_host_name_len=256]
490)
491AC_SUBST(max_host_name_len)
492
493#
494# EventProcessor thread configurations
495#
496
497AC_ARG_WITH([max-event-threads],
498  [AS_HELP_STRING([--with-max-event-threads],[max number of event threads [default=4096]])],
499  [max_event_threads=$withval],
500  [max_event_threads=4096]
501)
502AC_SUBST(max_event_threads)
503
504AC_ARG_WITH([max-threads-per-type],
505  [AS_HELP_STRING([--with-max-threads-per-type],[max number of threads per event type [default=3072]])],
506  [max_threads_per_type=$withval],
507  [max_threads_per_type=3072]
508)
509AC_SUBST(max_threads_per_type)
510
511#
512# Experimental plugins
513#
514
515AC_MSG_CHECKING([whether to enable experimental plugins])
516AC_ARG_ENABLE([experimental-plugins],
517  [AS_HELP_STRING([--enable-experimental-plugins],[build experimental plugins])],
518  [],
519  [enable_experimental_plugins=no]
520)
521AC_MSG_RESULT([$enable_experimental_plugins])
522AM_CONDITIONAL([BUILD_EXPERIMENTAL_PLUGINS], [ test "x${enable_experimental_plugins}" = "xyes" ])
523
524#
525# Check Magick++ is available. Enable experimental/webp_transform plugin
526#
527PKG_CHECK_MODULES([LIBMAGICKCPP],[Magick++ >= 7], [
528  TS_ADDTO(LIBMAGICKCPP_CFLAGS, [-DMAGICK_VERSION=7])
529  have_libmagickcpp=yes
530  AS_IF([test "x$enable_experimental_plugins" = "xyes"], [
531    enable_image_magick_plugins=yes
532  ])
533],
534[
535  PKG_CHECK_MODULES([LIBMAGICKCPP],[Magick++ < 7], [
536    TS_ADDTO(LIBMAGICKCPP_CFLAGS, [-DMAGICK_VERSION=6])
537    have_libmagickcpp=yes
538    AS_IF([test "x$enable_experimental_plugins" = "xyes"], [
539      enable_image_magick_plugins=yes
540    ])
541  ],
542  [
543    have_libmagickcpp=no
544  ])])
545
546AM_CONDITIONAL([BUILD_IMAGE_MAGICK_PLUGINS], [test "x${enable_image_magick_plugins}" = "xyes"])
547
548#
549# Example plugins. The example plugins are only built and installed if this is enabled. Installing
550# them is useful for QA, but not useful for most users, so we default this to disabled.
551#
552
553AC_MSG_CHECKING([whether to install example plugins])
554AC_ARG_ENABLE([example-plugins],
555  [AS_HELP_STRING([--enable-example-plugins],[build and install example plugins])],
556  [],
557  [enable_example_plugins=no]
558)
559AC_MSG_RESULT([$enable_example_plugins])
560AM_CONDITIONAL([BUILD_EXAMPLE_PLUGINS], [ test "x${enable_example_plugins}" = "xyes" ])
561
562
563#
564# Test tools. The test tools are always built, but not always installed. Installing
565# them is useful for QA, but not useful for most users, so we default this to disabled.
566#
567
568AC_MSG_CHECKING([whether to install testing tools])
569AC_ARG_ENABLE([test-tools],
570  [AS_HELP_STRING([--enable-test-tools],[install testing tools])],
571  [],
572  [enable_test_tools=no]
573)
574AC_MSG_RESULT([$enable_test_tools])
575AM_CONDITIONAL([BUILD_TEST_TOOLS], [ test "x${enable_test_tools}" = "xyes" ])
576
577#
578# Check if we should allow builds on 32-bit platforms
579#
580AC_MSG_CHECKING([whether to allow 32-bit builds])
581AC_ARG_ENABLE([32bit-build],
582  [AS_HELP_STRING([--enable-32bit-build],[allow 32bit builds])],
583  [],
584  [enable_32bit=no]
585)
586AC_MSG_RESULT([$enable_32bit])
587
588
589#
590# Installation directories
591# For each var the following is evaluated
592# foo      Standard variable  eg. ${prefix}/foo
593# rel_foo  Relative to prefix eg. foo
594#
595TS_SUBST_LAYOUT_PATH([prefix])
596TS_SUBST_LAYOUT_PATH([exec_prefix])
597TS_SUBST_LAYOUT_PATH([bindir])
598TS_SUBST_LAYOUT_PATH([sbindir])
599TS_SUBST_LAYOUT_PATH([libdir])
600TS_SUBST_LAYOUT_PATH([libexecdir])
601TS_SUBST_LAYOUT_PATH([infodir])
602TS_SUBST_LAYOUT_PATH([mandir])
603TS_SUBST_LAYOUT_PATH([sysconfdir])
604TS_SUBST_LAYOUT_PATH([datadir])
605TS_SUBST_LAYOUT_PATH([installbuilddir])
606TS_SUBST_LAYOUT_PATH([includedir])
607TS_SUBST_LAYOUT_PATH([localstatedir])
608TS_SUBST_LAYOUT_PATH([runtimedir])
609TS_SUBST_LAYOUT_PATH([logdir])
610TS_SUBST_LAYOUT_PATH([cachedir])
611TS_SUBST_LAYOUT_PATH([docdir])
612
613TS_SUBST([pkgbindir])
614TS_SUBST([pkgsbindir])
615TS_SUBST([pkglibdir])
616TS_SUBST([pkglibexecdir])
617TS_SUBST([pkgsysconfdir])
618TS_SUBST([pkgdatadir])
619TS_SUBST([pkglocalstatedir])
620TS_SUBST([pkgruntimedir])
621TS_SUBST([pkglogdir])
622TS_SUBST([pkgcachedir])
623TS_SUBST([pkgdocdir])
624
625
626# -----------------------------------------------------------------------------
627# 3. CHECK FOR PROGRAMS
628
629# Compiler selection:
630#
631# Implementation note (toc)
632# 1) Get default compiler settings (case statement.)
633# 2) Check for over-rides of default compiler.
634# 3) (in first kludge mode block...) obtain any further CFLAG-type additions.
635# 4) Test compilers with all flags set.
636
637# AC_PROG can sometimes mangle CFLAGS etc.
638# in particular, on Linux they insert -g -O2, here we preserve any user CFLAGS
639_ts_saved_CFLAGS="${CFLAGS}"
640_ts_saved_CXXFLAGS="${CXXFLAGS}"
641
642# We force the compiler search list because the default GCC on Darwin cannot build
643# Traffic Server. On most (all?) platforms, cc and c++ should be the preferred default
644# compiler.
645AC_PROG_CC([cc gcc clang icc])
646AC_PROG_CXX([c++ g++ clang++ icpc])
647
648AM_PROG_CC_C_O
649AC_PROG_CPP
650AC_PROG_CXXCPP
651AM_PROG_AS
652
653AX_COMPILER_VENDOR
654
655CFLAGS="${_ts_saved_CFLAGS}"
656CXXFLAGS="${_ts_saved_CXXFLAGS}"
657
658# All compilers we support have 'gnu99' as an available C standard
659TS_ADDTO(AM_CFLAGS, [-std=gnu99])
660
661ac_save_CXX="$CXX"
662CXX="$CXX -std=c++17"
663AC_LANG_PUSH(C++)
664AC_MSG_CHECKING([whether $CXX supports -std=c++17])
665AC_COMPILE_IFELSE([
666    AC_LANG_PROGRAM([
667#if __cplusplus < 201703L
668#error "This is not C++17"
669#endif
670    ], []
671    )], [
672    AC_MSG_RESULT(yes)
673    ], [
674    AC_MSG_RESULT(no)
675    AC_MSG_ERROR([*** A compiler with support for -std=c++17 is required.])
676])
677AC_LANG_POP
678CXX="$ac_save_CXX"
679
680TS_ADDTO(AM_CXXFLAGS, [-std=c++17])
681
682dnl AC_PROG_SED is only available from version 2.6 (released in 2003). CentosOS
683dnl 5.9 still has an ancient version, but we have macros that require
684dnl AC_PROG_SED. The actual AC_PROG_SED macro does functional checks, but here
685dnl we define a trivial local version for times when we are running on
686dnl obsoldete autoconf.
687ifdef([AC_PROG_SED], [], [
688  AC_DEFUN([AC_PROG_SED], [
689    AC_CHECK_PROG(SED, sed, sed)
690  ])
691])
692
693
694# Various OS specific setup. Note that on Solaris, 32-bit is always the
695# default, even on a box that with 64-bit architecture.
696# This also sets up a "normalized" variable and define $host_os_def.
697case $host_os in
698  linux*)
699    host_os_def="linux"
700    AM_LDFLAGS="-rdynamic"
701    ;;
702  darwin*)
703    host_os_def="darwin"
704    ;;
705  freebsd*)
706    host_os_def="freebsd"
707    AM_LDFLAGS="-rdynamic"
708    TS_ADDTO(TS_INCLUDES, [-I/usr/local/include])
709    TS_ADDTO(AM_CPPFLAGS, [-D_GLIBCXX_USE_C99])
710    TS_ADDTO(AM_CPPFLAGS, [-D_GLIBCXX_USE_C99_MATH])
711    TS_ADDTO(AM_CPPFLAGS, [-D_GLIBCXX_USE_C99_MATH_TR1])
712    ;;
713  kfreebsd*)
714    host_os_def="freebsd"
715    AM_LDFLAGS="-rdynamic"
716    TS_ADDTO(TS_INCLUDES, [-I/usr/local/include])
717    TS_ADDTO(AM_CPPFLAGS, [-Dkfreebsd])
718    ;;
719  openbsd*)
720    host_os_def="openbsd"
721    ;;
722  solaris*)
723    host_os_def="solaris"
724    case "`isalist`" in
725      *amd64*)
726        TS_ADDTO(AM_CFLAGS, [-m64])
727        TS_ADDTO(AM_CXXFLAGS, [-m64])
728        TS_ADDTO(LUAJIT_LDFLAGS, [-m64])
729        ;;
730    esac
731    ;;
732  *)
733    AM_LDFLAGS="-rdynamic"
734    host_os_def=unknown
735    ;;
736esac
737
738TS_ADDTO(AM_CPPFLAGS, [-D$host_os_def])
739AM_CONDITIONAL([OS_LINUX], [test "x$host_os_def" = "xlinux"])
740
741dnl AM_PROG_AR is not always available, but it doesn't seem to be needed in older versions.
742ifdef([AM_PROG_AR],
743      [AM_PROG_AR])
744
745AC_PROG_AWK
746AC_PROG_SED
747AC_PROG_LN_S
748AC_PROG_INSTALL
749AC_PROG_LIBTOOL
750AC_CHECK_PROG(RM, rm, rm)
751AC_CHECK_PROG(ASCPP, cpp, cpp)
752AC_CHECK_TOOL(AR, ar, ar)
753AC_ISC_POSIX
754
755AC_ARG_VAR(RPATH, [path to be added to rpath])
756
757AC_ARG_VAR([CLANG_TIDY], [clang-tidy command])
758
759# Default CLANG_TIDY to "clang-tidy", or "false" if it is not present.
760AC_PATH_PROG([CLANG_TIDY], [clang-tidy],[false])
761
762# Do bison check by hand because we must do a version check.
763# Use YACC because it makes autotools shut up.
764BISON_MAJOR=2
765BISON_MINOR=4
766BISON_POINT=1
767AC_CHECK_PROG([YACC],[bison],[bison])
768AS_IF([test -n "$YACC"],
769      [ bison_version_check=`$YACC --version 2>&1 | \
770        $SED -n '/bison/s/^[[^0-9]]*\([[0-9]][[0-9.]]*\).*$/\1/p' | \
771        $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=. \
772        `
773        AS_IF([test "x$bison_version_check" != "xyes"],
774          [ YACC=''
775            AS_IF([test -z "$bison_version_check"],
776              [bison_version_check='no version data']
777            )
778          ]
779        )
780      ],
781      [ YACC=''
782        bison_version_check="nothing"
783      ]
784)
785# Check lex/flex by hand because we need flex of a sufficient version.
786FLEX_MAJOR=2
787FLEX_MINOR=5
788FLEX_POINT=33
789dnl ylwrap requires the lexer executable to be an absolute path or in the srcdir.
790dnl but we need various other LEX values.
791AC_PROG_LEX
792AS_IF([test -n "$LEX"],
793      [ flex_version_check=`$LEX --version 2>&1 | \
794        $SED -n '/flex/s/^[[^0-9]]*\([[0-9]][[0-9.]]*\)[[^0-9]]*.*$/\1/p' | \
795        $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=. \
796        `
797        AS_IF([test "x$flex_version_check" != "xyes"],
798          [ LEX=''
799            AS_IF([test -z "$flex_version_check"],
800              [flex_version_check='no version data']
801            )
802          ]
803        )
804      ],
805      [ LEX=''
806        flex_version_check="nothing"
807      ]
808)
809
810# Generated files checked in, only build them if the local OS has the necessary support.
811# Otherwise just use the checked in version.
812AM_CONDITIONAL([BUILD_TSCONFIG_GRAMMAR], [ test -n "$LEX" && test -n "$YACC" ])
813
814# Check for Perl and Doxygen
815AC_PATH_PROG([DOXYGEN], [doxygen]) # needed for Doxygen
816AC_PATH_PROG([PERL], [perl],[not found])
817AS_IF([test "x$PERL" = "xnot found"],
818  [AC_MSG_ERROR([check for perl failed. Have you installed perl?])]
819)
820AC_ARG_VAR([DOXYGEN], [full path of Doxygen executable])
821AC_ARG_VAR([PERL], [full path of Perl executable])
822
823# Check if MakeMaker is available
824AX_PROG_PERL_MODULES([ExtUtils::MakeMaker], AM_CONDITIONAL([BUILD_PERL_LIB], [true]),
825                                            AM_CONDITIONAL([BUILD_PERL_LIB], [false])
826)
827
828# Check for GNU-style -On optimization flags
829AC_MSG_CHECKING([whether to auto-set compiler optimization flags])
830has_optimizer_flags=`echo "$CFLAGS $CXXFLAGS" | ${AWK} '$0 !~ /-O.?/{print "no"}'`
831AS_IF([test "x${has_optimizer_flags}" = "xno"],
832        [
833                optimizing_flags='-O3'
834                AC_MSG_RESULT([yes ${optimizing_flags}])
835        ],
836        [
837                has_optimizer_flags='yes'
838                optimizing_flags=''
839                AC_MSG_RESULT([no])
840        ]
841)
842
843case $host_os_def in
844  linux)
845    AS_IF([test "x$ax_cv_c_compiler_vendor" = "xintel"], [
846      # -Wall is overzealous for us, so need to turn this off for now:
847      #
848      #  #873 is "has no corresponding operator delete"
849      #  #279 is "controlling expression is constant" (which is e.g. TSReleaseAssert(!"Unexpected Event");
850      common_opt="-pipe -Wall -wd873 -wd279"
851      debug_opt="-g $common_opt"
852      release_opt="-g $common_opt $optimizing_flags -axsse4.2 -fno-strict-aliasing"
853      cxx_opt="-Wno-invalid-offsetof"
854    ])
855
856    AS_IF([test "x$ax_cv_c_compiler_vendor" = "xclang"], [
857      common_opt="-pipe -Wall -Wno-deprecated-declarations -Qunused-arguments -Wextra -Wno-ignored-qualifiers -Wno-unused-parameter"
858      debug_opt="-ggdb3 $common_opt -Qunused-arguments"
859      release_opt="-g $common_opt $optimizing_flags -fno-strict-aliasing -Qunused-arguments"
860      cxx_opt="-Wno-invalid-offsetof"
861    ])
862
863    AS_IF([test "x$ax_cv_c_compiler_vendor" = "xgnu"], [
864      # This is useful for finding odd conversions
865      #    common_opt="-pipe -Wall -Wconversion -Wno-sign-conversion -Wno-format-truncation"
866      common_opt="-pipe -Wall -Wextra -Wno-ignored-qualifiers -Wno-unused-parameter -Wno-format-truncation -Wno-cast-function-type -Wno-stringop-overflow"
867      debug_opt="-ggdb3 $common_opt"
868      release_opt="-g $common_opt $optimizing_flags -feliminate-unused-debug-symbols -fno-strict-aliasing"
869      cxx_opt="-Wno-invalid-offsetof -Wno-noexcept-type"
870      # Special options for flex generated .c files
871      flex_cflags="-Wno-unused-parameter"
872    ])
873
874    TS_ADDTO([AM_LDFLAGS], [-Wl,--as-needed])
875
876    ;; # linux)
877
878  darwin)
879    AS_IF([test "x$ax_cv_c_compiler_vendor" = "xclang"], [
880      common_opt="-pipe -Wall -Wno-deprecated-declarations -Qunused-arguments -Wextra -Wno-ignored-qualifiers -Wno-unused-parameter"
881      debug_opt="-g $common_opt"
882      release_opt="-g $common_opt $optimizing_flags -fno-strict-aliasing"
883      cxx_opt="-Wno-invalid-offsetof"
884    ], [
885      AC_MSG_WARN([clang is the only supported compiler on Darwin])
886    ])
887
888    # NOTE: This seems semi-kludgy, but useful for MacPorts I think.
889    AS_IF([test -d /opt/local/include], [
890      TS_ADDTO(TS_INCLUDES, [-I/opt/local/include])
891    ])
892    AS_IF([test -d /opt/local/lib], [
893      TS_ADDTO(AM_LDFLAGS, [-L/opt/local/lib])
894    ])
895
896    ;; # darwin)
897
898  freebsd|kfreebsd)
899    AS_IF([test "x$ax_cv_c_compiler_vendor" = "xclang"], [
900      common_opt="-pipe -Wall -Wno-deprecated-declarations -Qunused-arguments -Wextra -Wno-ignored-qualifiers -Wno-unused-parameter"
901      debug_opt="-ggdb3 $common_opt"
902      release_opt="-g $common_opt $optimizing_flags -fno-strict-aliasing"
903      cxx_opt="-Wno-invalid-offsetof"
904    ])
905
906    AS_IF([test "x$ax_cv_c_compiler_vendor" = "xgnu"], [
907      common_opt="-pipe -Wall -Wextra -Wno-ignored-qualifiers -Wno-unused-parameter"
908      debug_opt="-ggdb3 $common_opt"
909      release_opt="-g $common_opt $optimizing_flags -feliminate-unused-debug-symbols -fno-strict-aliasing"
910      cxx_opt="-Wno-invalid-offsetof"
911    ])
912
913    AS_IF([test -d /usr/local/lib], [
914      TS_ADDTO(AM_LDFLAGS, [-L/usr/local/lib])
915    ])
916
917    ;; # freebsd|kfreebsd)
918
919  solaris)
920    AS_IF([test "x$ax_cv_c_compiler_vendor" = "xgnu"], [
921      common_opt="-pipe -Wall -Wextra -Wno-ignored-qualifiers -Wno-unused-parameter"
922      debug_opt="-ggdb3 $common_opt"
923      release_opt="-g $common_opt $optimizing_flags -feliminate-unused-debug-symbols -fno-strict-aliasing"
924      cxx_opt="-Wno-invalid-offsetof"
925    ])
926
927    ;; # solaris)
928
929  *)
930    # Not sure what platform this is, but take a stab at some general GCC options ...
931    AS_IF([test "x$ax_cv_c_compiler_vendor" = "xgnu"], [
932      common_opt="-pipe -Wall -Wextra -Wno-ignored-qualifiers -Wno-unused-parameter"
933      debug_opt="-ggdb3 $common_opt"
934      release_opt="-g $common_opt $optimizing_flags -feliminate-unused-debug-symbols -fno-strict-aliasing"
935      cxx_opt="-Wno-invalid-offsetof"
936    ])
937esac
938
939AS_IF([test x"$enable_coverage" = "xyes"], [
940  # Map per-compiler code coverage instrumentation flags.  Note that
941  # we don't test whether the compiler actually support these options
942  # (we don't do that in general). The user is expected to use a modern,
943  # supported compiler to test coverage.
944  AS_CASE("$ax_cv_c_compiler_vendor",
945    [clang], [
946      TS_ADDTO(AM_CXXFLAGS, "-fprofile-instr-generate")
947      TS_ADDTO(AM_CXXFLAGS, "-fcoverage-mapping")
948      TS_ADDTO(AM_CFLAGS, "-fprofile-instr-generate")
949      TS_ADDTO(AM_CFLAGS, "-fcoverage-mapping")
950    ], [gnu], [
951      TS_ADDTO(AM_CXXFLAGS, "--coverage")
952      TS_ADDTO(AM_CFLAGS, "--coverage")
953      TS_ADDTO(LIBS, "-lgcov")
954  ])
955])
956
957# Only add -Werror if the user has requested it. We enable this by default for
958# development, disable it by default for release.
959AS_IF([test x"$enable_werror" = "xyes"], [
960  TS_ADDTO(release_opt, -Werror)
961  TS_ADDTO(debug_opt, -Werror)
962])
963
964cc_oflag_opt=$release_opt
965cc_oflag_dbg=$debug_opt
966cxx_oflag_opt="$release_opt $cxx_opt $cxx_rel"
967cxx_oflag_dbg="$debug_opt $cxx_opt $cxx_dbg"
968
969# Special compiler flag hacks for various pieces of the code
970AC_SUBST([FLEX_CFLAGS], $flex_cflags)
971
972#
973# _Here_ is where we go ahead and add the _optimizations_ to already
974#  existing CFLAGS/CXXFLAGS if some special values had been set.
975#
976if test "x${enable_debug}" = "xyes"; then
977  TS_ADDTO(AM_CFLAGS, [${cc_oflag_dbg}])
978  TS_ADDTO(AM_CXXFLAGS, [${cxx_oflag_dbg}])
979  TS_ADDTO(AM_CPPFLAGS, [-DDEBUG -D_DEBUG])
980else
981  TS_ADDTO(AM_CFLAGS, [${cc_oflag_opt}])
982  TS_ADDTO(AM_CXXFLAGS, [${cxx_oflag_opt}])
983fi
984
985if test "x${enable_mime_sanity_check}" = "xyes"; then
986  TS_ADDTO(AM_CPPFLAGS, [-DENABLE_MIME_SANITY_CHECK])
987fi
988if test "x${enable_all_asserts}" = "xyes"; then
989  TS_ADDTO(AM_CPPFLAGS, [-DENABLE_ALL_ASSERTS])
990fi
991
992# Flags for ASAN
993if test "x${enable_asan}" = "xyes"; then
994  if test "x${enable_tsan}" = "xyes" -o "x${enable_tsan}" = "xstatic"; then
995    AC_ERROR([Cannot have ASAN and TSAN options at the same time, pick one])
996  fi
997  TS_ADDTO(AM_CFLAGS, [-fno-omit-frame-pointer -fsanitize=address])
998  TS_ADDTO(AM_CXXFLAGS, [-fno-omit-frame-pointer -fsanitize=address])
999elif test "x${enable_asan}" = "xstatic"; then
1000  if test "x${enable_tsan}" = "xyes" -o "x${enable_tsan}" = "xstatic"; then
1001    AC_ERROR([Cannot have ASAN and TSAN options at the same time, pick one])
1002  fi
1003  asan_CXXFLAGS="$CXXFLAGS"
1004  CXXFLAGS="$CXXFLAGS -fno-omit-frame-pointer -fsanitize=address -static-libasan"
1005  AC_LANG_PUSH(C++)
1006  AC_MSG_CHECKING([static ASAN library is available])
1007  AC_LINK_IFELSE(
1008    [AC_LANG_PROGRAM([#include <stdlib.h>], [])],
1009    [AC_MSG_RESULT([yes])],
1010    [
1011      AC_MSG_RESULT([no])
1012      AC_ERROR([Cannot find static ASAN library.])
1013    ]
1014  )
1015  AC_LANG_POP
1016  CXXFLAGS="$asan_CXXFLAGS"
1017  TS_ADDTO(AM_CFLAGS, [-fno-omit-frame-pointer -fsanitize=address -static-libasan])
1018  TS_ADDTO(AM_CXXFLAGS, [-fno-omit-frame-pointer -fsanitize=address -static-libasan])
1019fi
1020
1021# Flags for LSAN stand-alone mode
1022if test "x${enable_lsan}" = "xyes"; then
1023  if test "x${enable_asan}" = "xyes" -o "x${enable_asan}" = "xstatic"; then
1024    AC_ERROR([ASAN already specified, --enable-lsan is meant only for lsan stand-alone mode])
1025  fi
1026  if test "x${enable_tsan}" = "xyes" -o "x${enable_tsan}" = "xstatic"; then
1027    AC_ERROR([Cannot have LSAN and TSAN options at the same time, pick one])
1028  fi
1029  TS_ADDTO(AM_CFLAGS, [-fno-omit-frame-pointer -fsanitize=leak])
1030  TS_ADDTO(AM_CXXFLAGS, [-fno-omit-frame-pointer -fsanitize=leak])
1031elif test "x${enable_lsan}" = "xstatic"; then
1032  if test "x${enable_asan}" = "xyes" -o "x${enable_asan}" = "xstatic"; then
1033    AC_ERROR([ASAN already specified, --enable-lsan is meant only for lsan stand-alone mode])
1034  fi
1035  if test "x${enable_tsan}" = "xyes" -o "x${enable_tsan}" = "xstatic"; then
1036    AC_ERROR([Cannot have LSAN and TSAN options at the same time, pick one])
1037  fi
1038  AC_CHECK_LIB(lsan, _init, [lsan_have_libs=yes], [lsan_have_libs=no])
1039  if test "x${lsan_have_libs}" == "xno"; then
1040    AC_ERROR([Cannot find LSAN static library])
1041  fi
1042  lsan_CXXFLAGS="$CXXFLAGS"
1043  CXXFLAGS="$CXXFLAGS -fno-omit-frame-pointer -fsanitize=leak -static-liblsan"
1044  AC_LANG_PUSH(C++)
1045  AC_MSG_CHECKING([static LSAN library is available])
1046  AC_LINK_IFELSE(
1047    [AC_LANG_PROGRAM([#include <stdlib.h>], [])],
1048    [AC_MSG_RESULT([yes])],
1049    [
1050      AC_MSG_RESULT([no])
1051      AC_ERROR([Cannot find static LSAN library.])
1052    ]
1053  )
1054  AC_LANG_POP
1055  CXXFLAGS="$lsan_CXXFLAGS"
1056  TS_ADDTO(AM_CFLAGS, [-fno-omit-frame-pointer -fsanitize=leak -static-liblsan])
1057  TS_ADDTO(AM_CXXFLAGS, [-fno-omit-frame-pointer -fsanitize=leak -static-liblsan])
1058fi
1059
1060# Flags for TSAN
1061if test "x${enable_tsan}" = "xyes"; then
1062  TS_ADDTO(AM_CFLAGS, [-fsanitize=thread])
1063  TS_ADDTO(AM_CXXFLAGS, [-fsanitize=thread])
1064elif test "x${enable_tsan}" = "xstatic"; then
1065  AC_CHECK_LIB(tsan, _init, [tsan_have_libs=yes], [tsan_have_libs=no])
1066  if test "x${tsan_have_libs}" == "xno"; then
1067    AC_ERROR([Cannot find TSAN static library])
1068  fi
1069  tsan_CXXFLAGS="$CXXFLAGS"
1070  CXXFLAGS="$CXXFLAGS -fsanitize=thread -static-libtsan"
1071  AC_LANG_PUSH(C++)
1072  AC_MSG_CHECKING([static TSAN library is available])
1073  AC_LINK_IFELSE(
1074    [AC_LANG_PROGRAM([#include <stdlib.h>], [])],
1075    [AC_MSG_RESULT([yes])],
1076    [
1077      AC_MSG_RESULT([no])
1078      AC_ERROR([Cannot find static TSAN library.])
1079    ]
1080  )
1081  AC_LANG_POP
1082  CXXFLAGS="$tsan_CXXFLAGS"
1083  TS_ADDTO(AM_CFLAGS, [-fsanitize=thread -static-libtsan])
1084  TS_ADDTO(AM_CXXFLAGS, [-fsanitize=thread -static-libtsan])
1085fi
1086
1087# Checks for pointer size.
1088# TODO: Later this is irrelevant, and we should just bail on 32-bit platforms always
1089AC_CHECK_SIZEOF([void*])
1090if test "x$ac_cv_sizeof_voidp" == "x"; then
1091  AC_ERROR([Cannot determine size of void*])
1092fi
1093
1094# Right now, 32-bit platform is a build error, unless we've forced it with --enable-32bit-build
1095if test "${ac_cv_sizeof_voidp}" = "4"; then
1096   AS_IF([test x"$enable_32bit_build" = "xyes"], [
1097     AC_MSG_NOTICE([Explicitly building on a 32-bit platform, this might be unsupported soon!])
1098   ], [
1099     AC_ERROR([You are trying to build on a 32-bit platform, which is unsupported.])
1100   ])
1101fi
1102
1103
1104#
1105# Here are all the extra linux-specific C(XX)FLAGS additions and
1106# so forth.
1107# TODO cpu architecture settings separate from operating system settings
1108#
1109cpu_architecture=""
1110# GCC: add a default march if there is not one set
1111if test "x${GCC}" = "xyes"; then
1112  if test "${ac_cv_sizeof_voidp}" = "4"; then
1113    case "$host_cpu" in
1114      i?86* | k[5-8]* | pentium* | athlon)
1115        cpu_architecture="-march=i586"
1116      ;;
1117    esac
1118  else
1119    case "$host_cpu" in
1120      x86_64 | amd64)
1121        # XXX: Any need for 64-bit arch flags?
1122        # cpu_architecture="-march=native"
1123      ;;
1124    esac
1125  fi
1126fi
1127
1128# Override detected architecture with the user supplied one
1129#
1130AC_ARG_WITH(architecture, [AC_HELP_STRING([--with-architecture=ARCH],[use a specific CPU architecture])],
1131[
1132  if test "x$withval" != "xyes" && test "x$withval" != "xno"; then
1133    case "$withval" in
1134      -*)
1135        # TODO: In case we are cross compiling some of the provided flags
1136        #       should be added to the LDFLAGS
1137        cpu_architecture="$withval"
1138      ;;
1139      *)
1140        cpu_architecture="-march=$withval"
1141      ;;
1142    esac
1143  elif test "x$withval" = "x"; then
1144    AC_MSG_ERROR([--with-architecture requires an param])
1145  fi
1146])
1147
1148if test "x$cpu_architecture" != "x"; then
1149  TS_ADDTO(AM_CFLAGS, [$cpu_architecture])
1150  TS_ADDTO(AM_CXXFLAGS, [$cpu_architecture])
1151fi
1152
1153# 64-bit LFS support
1154#
1155TS_ADDTO(AM_CPPFLAGS, [-D_LARGEFILE64_SOURCE=1])
1156if test "${ac_cv_sizeof_voidp}" = "8"; then
1157  TS_ADDTO(AM_CPPFLAGS, [-D_COMPILE64BIT_SOURCE=1])
1158else
1159  TS_ADDTO(AM_CPPFLAGS, [-D_FILE_OFFSET_BITS=64])
1160fi
1161TS_ADDTO(CPPFLAGS, [-D_GNU_SOURCE])
1162TS_ADDTO(AM_CPPFLAGS, [-D_REENTRANT])
1163TS_ADDTO(AM_CPPFLAGS, [-D__STDC_LIMIT_MACROS=1])
1164TS_ADDTO(AM_CPPFLAGS, [-D__STDC_FORMAT_MACROS=1])
1165
1166AC_MSG_NOTICE([Build for host OS: $host_os, arch: $host_cpu, optimization: $host_os_def])
1167
1168# Add hardening options to flags
1169AS_IF([test "x${enable_hardening}" = "xyes"], [
1170  TS_ADDTO(AM_CPPFLAGS, [-D_FORTIFY_SOURCE=2])
1171  TS_ADDTO(AM_CXXFLAGS, [-fPIE -fstack-protector])
1172  TS_ADDTO(AM_CFLAGS, [-fPIE -fstack-protector])
1173  AS_CASE("$host_os_def",
1174    [linux], [TS_ADDTO(AM_LDFLAGS, [-pie -Wl,-z,relro -Wl,-z,now])]
1175  )
1176])
1177
1178#
1179# Note:  These are site-specific macro's that do various tests
1180#         on the selected compilers.  There was some tuning
1181#         associated with our not wanting to use GNU for _everything_.
1182# Note:  This macro may set certain parameters when run.
1183#
1184
1185# Check for ccache (if explicitly enabled)
1186if test "x$enable_ccache" = "xyes"; then
1187    AC_CHECK_PROG([CCACHE],[ccache],[ccache],[])
1188    if test "x${CCACHE}" = "xccache"; then
1189        CC="$CCACHE $CC"
1190        CXX="$CCACHE $CXX"
1191    fi
1192fi
1193
1194# -----------------------------------------------------------------------------
1195# 4. CHECK FOR LIBRARIES
1196
1197AC_SEARCH_LIBS([socket], [socket], [], [])
1198AC_SEARCH_LIBS([gethostbyname], [nsl], [], [])
1199AC_SEARCH_LIBS([clock_gettime], [rt posix4], [], [])
1200
1201dnl We check for dlsym here instead of e.g. dlopen() because ASAN hijacks the latter.
1202AC_SEARCH_LIBS([dlsym], [dl], [], [])
1203
1204dnl Linux has pthread symbol stubss in both libc and libpthread, so it's important to test
1205dnl specifically for pthread_yield() here. In addition, ASAN hijacks pthread_create() so
1206dnl we can't use that anymore.
1207AC_SEARCH_LIBS([pthread_yield], [pthread], [], [])
1208AC_CHECK_FUNCS([pthread_mutexattr_settype])
1209
1210dnl XXX The following check incorrectly causes the build to succeed
1211dnl on Darwin. We should be using AC_SEARCH_LIBS, but rest_init is
1212dnl actually present in libsystem. We are searching for the library
1213dnl that contains the full Bind 9 API (which is actually libresolv).
1214dnl However, the resolv API uses macros to rename it's APIs to per-version
1215dnl symbols, so standard autoconf macros cannot reasonably be used to
1216dnl check for it. We need to write custom macros to detect it properly.
1217AC_CHECK_LIB([resolv],[res_init],[AC_SUBST([LIBRESOLV],["-lresolv"])])
1218AC_CHECK_LIB([resolv],[__putlong],[AC_SUBST([LIBRESOLV],["-lresolv"])])
1219
1220# Test for ncurses. We need to turn off -Werror because the C code in the
1221# ncurses compile tests does not generate unused variable warnings.
1222__saved_CFLAGS="$CFLAGS"
1223TS_REMOVEFROM(CFLAGS, -Werror)
1224
1225dnl Red Hat 6 requires special flags for curses to work.
1226if test -r /etc/system-release ; then
1227  case `cat /etc/system-release` in
1228    Red\ Hat*release\ 6.*)
1229      TS_ADDTO(CFLAGS, [-Wl,--add-needed])
1230      curses_ldflags="-Wl,--add-needed"
1231    ;;
1232  esac
1233fi
1234
1235AX_WITH_CURSES
1236CFLAGS="$__saved_CFLAGS"
1237AC_SUBST([CURSES_LDFLAGS],[$curses_ldflags])
1238
1239#
1240# Check for -latomic need (at least for mips arch)
1241TS_CHECK_ATOMIC
1242TS_ADDTO([LDFLAGS], [$ATOMIC_LIBS])
1243
1244#
1245# Check for SSL presence and usability
1246#
1247TS_CHECK_CRYPTO
1248
1249# Check for OpenSSL Version
1250TS_CHECK_CRYPTO_VERSION
1251
1252# Check for openssl ASYNC jobs
1253TS_CHECK_CRYPTO_ASYNC
1254
1255# Check for the client hello callback
1256TS_CHECK_CRYPTO_HELLO_CB
1257
1258# Check for SSL_set0_rbio call
1259TS_CHECK_CRYPTO_SET_RBIO
1260
1261# Check for DH_get_2048_256
1262TS_CHECK_CRYPTO_DH_GET_2048_256
1263
1264# Check for HKDF support
1265TS_CHECK_CRYPTO_HKDF
1266AM_CONDITIONAL([HAS_HKDF], [test "x$enable_hkdf" = "xyes"])
1267
1268# Check for TLS 1.3 support
1269TS_CHECK_CRYPTO_TLS13
1270
1271# Check for QUIC support
1272enable_quic=no
1273AC_MSG_CHECKING([whether APIs for QUIC are available])
1274AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]],
1275                                   [[
1276                                     SSL_QUIC_METHOD var;
1277                                   ]])
1278                  ],
1279                  [
1280                    AC_MSG_RESULT([yes])
1281                    enable_quic=yes
1282                    _quic_saved_LIBS=$LIBS
1283                    TS_ADDTO(LIBS, [$OPENSSL_LIBS])
1284                    AC_CHECK_FUNCS(SSL_set_quic_early_data_enabled)
1285                    LIBS=$_quic_saved_LIBS
1286                  ],
1287                  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <openssl/ssl.h>]],
1288                                   [[
1289                                     #ifdef SSL_MODE_QUIC_HACK
1290                                     #else
1291                                     # error no hack for quic
1292                                     #endif
1293                                   ]])
1294                  ],
1295                  [AC_MSG_RESULT([yes]); enable_quic=yes; enable_quic_old_api=yes],
1296                  [AC_MSG_RESULT([no])])
1297                  ])
1298
1299AM_CONDITIONAL([ENABLE_QUIC], [test "x$enable_quic" = "xyes"])
1300AM_CONDITIONAL([ENABLE_QUIC_OLD_API], [test "x$enable_quic_old_api" = "xyes"])
1301TS_ARG_ENABLE_VAR([use], [quic])
1302AC_SUBST(use_quic)
1303
1304# Check for OCSP
1305TS_CHECK_CRYPTO_OCSP
1306
1307# Check for SSL_CTX_set_ciphersuites call
1308TS_CHECK_CRYPTO_SET_CIPHERSUITES
1309
1310# Check for openssl early data support
1311TS_CHECK_EARLY_DATA
1312
1313# Check for openssl session ticket support
1314TS_CHECK_SESSION_TICKET
1315
1316saved_LIBS="$LIBS"
1317TS_ADDTO([LIBS], ["$OPENSSL_LIBS"])
1318
1319AC_CHECK_FUNCS([ \
1320  BIO_meth_new \
1321  BIO_sock_non_fatal_error \
1322  CRYPTO_set_mem_functions \
1323  HMAC_CTX_new \
1324  X509_get0_signature \
1325  ERR_get_error_all \
1326])
1327
1328AC_CHECK_FUNC([ASN1_STRING_get0_data], [],
1329              [AC_DEFINE([ASN1_STRING_get0_data], [ASN1_STRING_data], [Added in OpenSSL 1.1])])
1330
1331AC_CHECK_FUNC([BIO_set_data], [],
1332              [AC_DEFINE([BIO_set_data(a, _ptr)], [((a)->ptr = (_ptr))], [Added in OpenSSL 1.1])])
1333AC_CHECK_FUNC([BIO_get_data], [],
1334              [AC_DEFINE([BIO_get_data(a)], [((a)->ptr)], [Added in OpenSSL 1.1])])
1335AC_CHECK_FUNC([BIO_get_shutdown], [],
1336              [AC_DEFINE([BIO_get_shutdown(a)], [((a)->shutdown)], [Added in OpenSSL 1.1])])
1337AC_CHECK_FUNC([BIO_meth_get_ctrl], [],
1338              [AC_DEFINE([BIO_meth_get_ctrl(biom)], [((biom)->ctrl)], [Added in OpenSSL 1.1])])
1339AC_CHECK_FUNC([BIO_meth_get_create], [],
1340              [AC_DEFINE([BIO_meth_get_create(biom)], [((biom)->create)], [Added in OpenSSL 1.1])])
1341AC_CHECK_FUNC([BIO_meth_get_destroy], [],
1342              [AC_DEFINE([BIO_meth_get_destroy(biom)], [((biom)->destroy)], [Added in OpenSSL 1.1])])
1343
1344AC_CHECK_FUNC([EVP_MD_CTX_new], [],
1345              [AC_DEFINE([EVP_MD_CTX_new], [EVP_MD_CTX_create], [Renamed in OpenSSL 1.1])])
1346AC_CHECK_FUNC([EVP_MD_CTX_reset], [],
1347              [AC_DEFINE([EVP_MD_CTX_reset], [EVP_MD_CTX_cleanup], [Renamed in OpenSSL 1.1])])
1348AC_CHECK_FUNC([EVP_MD_CTX_free], [],
1349              [AC_DEFINE([EVP_MD_CTX_free], [EVP_MD_CTX_destroy], [Renamed in OpenSSL 1.1])])
1350
1351AC_MSG_CHECKING([for OpenSSL is BoringSSL])
1352AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <openssl/base.h>]],
1353                                   [[
1354                                     #ifndef OPENSSL_IS_BORINGSSL
1355                                     # error not boringssl
1356                                     #endif
1357                                   ]])
1358                  ],
1359                  [AC_MSG_RESULT([yes]); openssl_is_boringssl=1],
1360                  [AC_MSG_RESULT([no])])
1361AM_CONDITIONAL([OPENSSL_IS_BORINGSSL], [test -n "$openssl_is_boringssl"])
1362
1363LIBS="$saved_LIBS"
1364
1365#
1366# Check OpenSSL version for JA3 Fingerprint
1367#
1368AC_MSG_CHECKING([for JA3 compatible OpenSSL version])
1369AC_EGREP_CPP(yes, [
1370  #include <openssl/opensslv.h>
1371  #if (OPENSSL_VERSION_NUMBER < 0x010100000L)
1372  yes
1373  #elif (OPENSSL_VERSION_NUMBER >= 0x010101000L)
1374  yes
1375  #endif
1376  ], [
1377    AC_MSG_RESULT(yes)
1378    AS_IF([test "x${enable_experimental_plugins}" = "xyes" && test -z "$openssl_is_boringssl"], [
1379      enable_ja3_plugin=yes
1380    ])
1381  ], [AC_MSG_RESULT(no)])
1382
1383AM_CONDITIONAL([BUILD_JA3_PLUGIN], [test "x${enable_ja3_plugin}" = "xyes"])
1384
1385#
1386# Check for zlib presence and usability
1387TS_CHECK_ZLIB
1388
1389#
1390# Check for lzma presence and usability
1391TS_CHECK_LZMA
1392
1393AC_CHECK_FUNCS([clock_gettime kqueue epoll_ctl posix_fadvise posix_madvise posix_fallocate inotify_init])
1394AC_CHECK_FUNCS([port_create strlcpy strlcat sysconf sysctlbyname getpagesize])
1395AC_CHECK_FUNCS([getreuid getresuid getresgid setreuid setresuid getpeereid getpeerucred])
1396AC_CHECK_FUNCS([strsignal psignal psiginfo accept4])
1397
1398# Check for eventfd() and sys/eventfd.h (both must exist ...)
1399AC_CHECK_HEADERS([sys/eventfd.h], [
1400  AS_IF([test "x$enable_eventfd" = "xyes"], [
1401    AC_CHECK_FUNCS([eventfd])
1402  ]
1403)])
1404
1405AC_CHECK_FUNCS(eventfd)
1406
1407#
1408# Check for mcheck_pedantic(3)
1409#
1410AC_CHECK_HEADERS(mcheck.h)
1411AC_CHECK_FUNCS(mcheck_pedantic)
1412
1413#
1414# Check for malloc_usable_size()
1415#
1416AC_CHECK_FUNCS(malloc_usable_size)
1417
1418#
1419# Check for pcre library
1420#
1421TS_CHECK_PCRE
1422if test "x${enable_pcre}" != "xyes"; then
1423  AC_MSG_ERROR([Cannot find pcre library. Configure --with-pcre=DIR])
1424fi
1425
1426# Check for optional brotli library
1427TS_CHECK_BROTLI
1428
1429# Check for optional luajit library
1430TS_CHECK_LUAJIT
1431
1432#
1433# Enable experimental/uri_signing plugin
1434# This is here, instead of above, because it needs to know if PCRE is available.
1435#
1436
1437#### Check for optional jansson library (uri_signing)
1438TS_CHECK_JANSSON
1439
1440AC_CHECK_LIB([crypto],[HMAC],[has_libcrypto=1],[has_libcrypto=0])
1441
1442#### Check for optional cjose library (uri_signing)
1443TS_CHECK_CJOSE
1444
1445AM_CONDITIONAL([BUILD_URI_SIGNING_PLUGIN], [test ! -z "${LIBCJOSE}" -a ! -z "${LIBJANSSON}" -a "x${enable_pcre}" = "xyes" -a "x${has_libcrypto}" = "x1"])
1446AC_SUBST([LIBCJOSE])
1447AC_SUBST([LIBJANSSON])
1448
1449# Check for yaml-cpp library
1450#
1451TS_CHECK_YAML_CPP
1452AM_CONDITIONAL([BUILD_YAML_CPP], [test x"$has_yaml_cpp" = x"no"])
1453
1454TS_CHECK_YAML_HEADERS_EXPORT
1455AM_CONDITIONAL([EXPORT_YAML_HEADERS], [test x"$enable_yaml_headers" = x"yes"])
1456
1457# Check for optional boringocsp library
1458TS_CHECK_BORINGOCSP
1459
1460# Check for optional hiredis library
1461TS_CHECK_HIREDIS
1462
1463AM_CONDITIONAL([BUILD_SSL_SESSION_REUSE_PLUGIN], [test ! -z "${LIB_HIREDIS}" -a "x${has_hiredis}" = "x1" ])
1464
1465# Check for backtrace() support
1466has_backtrace=0
1467AC_CHECK_HEADERS([execinfo.h], [has_backtrace=1],[])
1468if test "${has_backtrace}" = "1"; then
1469  # FreeBSD requires '/usr/ports/devel/libexecinfo' for gdb style backtrace() support
1470  AC_SEARCH_LIBS([backtrace], [execinfo], [have_backtrace_lib=yes])
1471else
1472  AC_MSG_WARN([No backtrace() support found])
1473fi
1474AC_SUBST(has_backtrace)
1475
1476#
1477# use unwind library when possible (can be disabled)
1478#
1479AC_MSG_CHECKING([whether to use unwind library])
1480AC_ARG_ENABLE([unwind],
1481  AS_HELP_STRING([--disable-unwind],[Don't use the unwind library]), [
1482  ], [
1483    enable_unwind="yes"
1484    enable_unwind_default="yes"
1485])
1486AC_MSG_RESULT([$enable_unwind])
1487
1488AS_IF([test "x$enable_unwind" = "xyes"], [
1489  # Remote process unwinding is only implemented on Linux because it depends on various Linux-specific
1490  # features such as /proc filesystem nodes, ptrace(2) and waitpid(2) extensions.
1491  AS_IF([test "$host_os_def" = "linux"], [
1492    PKG_CHECK_MODULES([LIBUNWIND], [libunwind-ptrace], [
1493      enable_remote_unwinding=yes
1494    ], [
1495      AS_IF([test "x$enable_unwind_default" = "xyes"], [
1496        AC_MSG_WARN([unwind not found, try disabling it --disable-unwind])
1497      ], [
1498        AC_MSG_ERROR([unwind not found, try disabling it --disable-unwind])
1499      ])
1500    ])], [
1501    AS_IF([test "x$enable_unwind_default" = "xyes"], [
1502      AC_MSG_WARN([unwind only available on linux, try disabling it --disable-unwind])
1503    ], [
1504      AC_MSG_ERROR([unwind only available on linux, try disabling it --disable-unwind])
1505    ])
1506  ])
1507])
1508TS_ARG_ENABLE_VAR([use], [remote_unwinding])
1509
1510# Find the appropriate event handling interface. This can be forced on
1511# platforms that support 2 or more of our supported interfaces. It
1512# could also (in the future?) be used to enable other event systems
1513# such as libev.
1514AC_ARG_WITH([event-interface],
1515  [AS_HELP_STRING([--with-event-interface=epoll|kqueue|port],[event interface to use [default=auto]])],
1516  [event_interface=$withval],
1517  [event_interface="auto"]
1518)
1519
1520use_epoll=0
1521use_kqueue=0
1522use_port=0
1523
1524AS_IF([test "x$event_interface" = "xauto"], [
1525  if test "$ac_cv_func_port_create" = "yes"; then
1526    use_port=1
1527    have_good_poller=1
1528    AC_MSG_NOTICE([Using port event interface])
1529  elif test "$ac_cv_func_epoll_ctl" = "yes"; then
1530    use_epoll=1
1531    have_good_poller=1
1532    AC_MSG_NOTICE([Using epoll event interface])
1533  elif test "$ac_cv_func_kqueue" = "yes"; then
1534    use_kqueue=1
1535    have_good_poller=1
1536    AC_MSG_NOTICE([Using kqueue event interface])
1537  else
1538    AC_MSG_FAILURE([No suitable polling interface found])
1539  fi
1540],[
1541  case "x$event_interface" in
1542    xepoll)
1543      use_epoll=1
1544      AC_MSG_RESULT([forced to epoll])
1545      ;;
1546    xport)
1547      use_port=1
1548      AC_MSG_RESULT([forced to port])
1549      ;;
1550    xkqueue)
1551      use_kqueue=1
1552      AC_MSG_RESULT([forced to port])
1553      ;;
1554    *)
1555      AC_MSG_RESULT([failed])
1556      AC_MSG_FAILURE([unknown event system])
1557  esac
1558])
1559
1560AC_SUBST(use_epoll)
1561AC_SUBST(use_kqueue)
1562AC_SUBST(use_port)
1563
1564
1565# Profiler support
1566has_profiler=0
1567if test "x${with_profiler}" = "xyes"; then
1568  AC_CHECK_LIB([profiler], [ProfilerStart],
1569    [AC_SUBST([LIBPROFILER], ["-lprofiler"])
1570     has_profiler=1
1571    ],
1572    [AC_MSG_FAILURE([check for profiler failed. Have you installed google-perftools-devel?])],
1573  )
1574fi
1575AC_SUBST(has_profiler)
1576
1577AC_MSG_CHECKING(for 128bit CAS support)
1578AC_LANG_PUSH([C++])
1579
1580# We need to save and restore compiler flags around this whole block.
1581# TS_TRY_COMPILE_NO_WARNING will save and restore flags, so if we do that in the
1582# middle, then we can accidentally restore modified flags.
1583__saved_CXXFLAGS="${CXXFLAGS}"
1584__saved_CFLAGS="${CFLAGS}"
1585
1586has_128bit_cas=0
1587# Don't add the -mcx16 flag unless needed and it compiles cleanly.
1588needs_mcx16_for_cas=0
1589
1590TS_TRY_COMPILE_NO_WARNING([],[
1591    __int128_t x = 0;
1592    __sync_bool_compare_and_swap(&x,0,10);
1593  ], [
1594    AC_MSG_RESULT(yes)
1595    has_128bit_cas=1
1596  ], [
1597    dnl If 128bit CAS fails, try again with the -mcx16 option. GCC needs this;
1598    dnl clang doesn't; icc does not support -mcx16 (but gives a non-fatal warning).
1599    TS_ADDTO(CXXFLAGS, [-mcx16])
1600    TS_ADDTO(CFLAGS, [-mcx16])
1601    TS_TRY_COMPILE_NO_WARNING([],[
1602        __int128_t x = 0;
1603        __sync_bool_compare_and_swap(&x,0,10);
1604      ], [
1605        AC_MSG_RESULT(yes)
1606        has_128bit_cas=1
1607        needs_mcx16_for_cas=1
1608      ], [
1609        AC_MSG_RESULT(no)
1610    ])
1611])
1612
1613CXXFLAGS="${__saved_CXXFLAGS}"
1614CFLAGS="${__saved_CFLAGS}"
1615AC_LANG_POP
1616AC_SUBST(has_128bit_cas)
1617
1618AS_IF([test "x$needs_mcx16_for_cas" = "x1"], [
1619    TS_ADDTO(AM_CFLAGS, [-mcx16])
1620    TS_ADDTO(AM_CXXFLAGS, [-mcx16])
1621])
1622
1623# Check for POSIX capabilities library.
1624# If we don't find it, disable checking for header.
1625use_posix_cap=0
1626AS_IF([test "x$enable_posix_cap" != "xno"],
1627  AC_CHECK_LIB([cap], [cap_set_proc],
1628    [AC_SUBST([LIBCAP], ["-lcap"])
1629     use_posix_cap=1
1630    ],[
1631     AS_IF([test "x$enable_posix_cap" == "xyes"], [
1632      AC_MSG_FAILURE([POSIX capabilities enabled but system library not found.])
1633     ],[
1634      [enable_posix_cap=no]
1635    ]    )
1636   ]
1637  )
1638)
1639AC_SUBST(use_posix_cap)
1640
1641#
1642# If the OS is linux, we can use the '--enable-experimental-linux-native-aio' option to
1643# replace the aio thread mode. Effective only on the linux system.
1644#
1645
1646AC_MSG_CHECKING([whether to enable Linux native AIO])
1647AC_ARG_ENABLE([experimental-linux-native-aio],
1648  [AS_HELP_STRING([--enable-experimental-linux-native-aio], [WARNING this is experimental and has known issues enable native Linux AIO support @<:@default=no@:>@])],
1649  [enable_linux_native_aio="${enableval}"],
1650  [enable_linux_native_aio=no]
1651)
1652
1653AS_IF([test "x$enable_linux_native_aio" = "xyes"], [
1654  if test $host_os_def  != "linux"; then
1655    AC_MSG_ERROR([Linux native AIO can only be enabled on Linux systems])
1656  fi
1657
1658  AC_CHECK_HEADERS([libaio.h], [],
1659    [AC_MSG_ERROR([Linux native AIO requires libaio.h])]
1660  )
1661
1662  AC_SEARCH_LIBS([io_submit], [aio], [],
1663    [AC_MSG_ERROR([Linux native AIO requires libaio])]
1664  )
1665])
1666
1667AC_MSG_RESULT([$enable_linux_native_aio])
1668TS_ARG_ENABLE_VAR([use], [linux_native_aio])
1669
1670# Check for hwloc library.
1671# If we don't find it, disable checking for header.
1672use_hwloc=0
1673AS_IF([test "x$enable_hwloc" = "xyes"], [
1674  # Use pkg-config, because some distros (*cough* Ubuntu) put hwloc in unusual places.
1675  PKG_CHECK_MODULES([HWLOC], [hwloc], [
1676    SAVE_LIBS="$LIBS"
1677    LIBS="-lhwloc"
1678    AC_LANG_PUSH([C++])
1679    AC_MSG_CHECKING([for hwloc C++ linking])
1680    AC_LINK_IFELSE([
1681      AC_LANG_PROGRAM([#include <hwloc.h>],[hwloc_topology_t t; hwloc_topology_init(&t); hwloc_get_type_depth(t, HWLOC_OBJ_SOCKET);])],[
1682      use_hwloc=1
1683      AC_SUBST([HWLOC_CFLAGS])
1684      AC_SUBST([HWLOC_LIBS])
1685      AC_MSG_RESULT([yes])
1686      # Old versions of libhwloc don't have HWLOC_OBJ_PU.
1687      AC_CHECK_DECL(HWLOC_OBJ_PU,
1688        [AC_DEFINE(HAVE_HWLOC_OBJ_PU, 1, [Whether HWLOC_OBJ_PU is available])], [],
1689        [#include <hwloc.h>]
1690      )
1691    ], [
1692      AC_MSG_RESULT([no])
1693      AC_MSG_WARN([hwloc not linkable, try --disable-hwloc])
1694      AC_SUBST([HWLOC_CFLAGS],[""])
1695      AC_SUBST([HWLOC_LIBS],[""])
1696    ])
1697    AC_LANG_POP()
1698    LIBS="$SAVE_LIBS"
1699  ], [
1700    AC_MSG_WARN([hwloc not found, try --disable-hwloc])
1701    AC_SUBST([HWLOC_CFLAGS],[""])
1702    AC_SUBST([HWLOC_LIBS],[""])
1703  ])
1704])
1705
1706AC_SUBST(use_hwloc)
1707
1708#
1709# Check for Maxmind APIs / includes. TODO: Long term, it might make sense to support
1710# GeoIP as a "helper" plugin, which other plugins can then use. Such a plugin could
1711# then manage which libraries to use via explicit dlopen()'s.
1712#
1713AC_CHECK_HEADERS([GeoIP.h], [
1714  AC_CHECK_LIB([GeoIP], [GeoIP_new], [
1715    AC_SUBST([GEOIP_LIBS], ["-lGeoIP"])
1716    AC_SUBST(has_geoip, 1)
1717  ], [
1718    AC_SUBST([GEOIP_LIBS], [""])
1719    AC_SUBST(has_geoip, 0)
1720  ])
1721])
1722
1723AM_CONDITIONAL([HAS_GEOIP], [test "x${has_geoip}" = "x1" ])
1724
1725#
1726# Check for libmaxmind.  This is the maxmind v2 API where GeoIP is the legacy
1727# v1 dat file based API
1728#
1729AC_CHECK_HEADERS([maxminddb.h], [
1730  AC_CHECK_LIB([maxminddb], [MMDB_open], [
1731    AC_SUBST([MAXMINDDB_LIBS], ["-lmaxminddb"])
1732    AC_SUBST(has_maxminddb, 1)
1733  ], [
1734    AC_SUBST([MAXMINDDB_LIBS], [""])
1735    AC_SUBST(has_maxminddb, 0)
1736  ])
1737])
1738
1739AM_CONDITIONAL([HAS_MAXMINDDB], [test "x${has_maxminddb}" = "x1" ])
1740
1741AC_ARG_WITH([hrw-geo-provider],
1742  [AS_HELP_STRING([--with-hrw-geo-provider=geoip|maxminddb],[geo provider to use with header_rewrite [default=auto] ])],
1743  [geo_provider=$withval],
1744  [geo_provider="auto"]
1745)
1746use_hrw_geoip=0
1747use_hrw_maxminddb=0
1748
1749AS_IF([test "x$geo_provider" = "xauto"], [
1750  if test "x$has_geoip" = "x1"; then
1751    use_hrw_geoip=1
1752    AC_MSG_NOTICE([Using GeoIP interface for header_rewrite])
1753  elif test "x$has_maxminddb" = "x1"; then
1754    use_hrw_maxminddb=1
1755    AC_MSG_NOTICE([Using MaxMindDB interface for header_rewrite])
1756  fi
1757],[
1758  case "x$geo_provider" in
1759    xgeoip)
1760      use_hrw_geoip=1
1761      AC_MSG_RESULT([forced to GeoIP])
1762      ;;
1763    xmaxminddb)
1764      use_hrw_maxminddb=1
1765      AC_MSG_RESULT([forced to MaxMindDB])
1766      ;;
1767    *)
1768      AC_MSG_RESULT([failed])
1769      AC_MSG_FAILURE([unknown geo interface $geo_provider])
1770  esac
1771])
1772
1773AC_SUBST(use_hrw_geoip)
1774AC_SUBST(use_hrw_maxminddb)
1775
1776# Right now, the healthcheck plugins requires inotify_init (and friends)
1777AM_CONDITIONAL([BUILD_HEALTHCHECK_PLUGIN], [ test "$ac_cv_func_inotify_init" = "yes" ])
1778
1779#
1780# Check for tcmalloc and jemalloc
1781TS_CHECK_JEMALLOC
1782TS_CHECK_TCMALLOC
1783
1784#
1785# Check for libreadline/libedit
1786AX_LIB_READLINE
1787
1788# We should be able to build http_load if epoll(2) is available.
1789AM_CONDITIONAL([BUILD_HTTP_LOAD], [test x"$ac_cv_func_epoll_ctl" = x"yes"])
1790
1791# We should only build traffic_top if we have curses
1792AM_CONDITIONAL([BUILD_TRAFFIC_TOP], [test "x$ax_cv_curses" = "xyes"])
1793
1794AC_CHECK_HEADERS([mysql/mysql.h], [has_mysql=1],[has_mysql=0])
1795AC_CHECK_LIB([mysqlclient],[mysql_info],[AC_SUBST([LIB_MYSQLCLIENT],["-lmysqlclient"])],[has_mysql=0])
1796AC_SUBST(has_mysql)
1797AM_CONDITIONAL([HAS_MYSQL], [ test "x${has_mysql}" = "x1" ])
1798
1799AC_CHECK_HEADERS([kclangc.h], [
1800  AC_CHECK_LIB([kyotocabinet], [kcdbopen], [
1801    AC_SUBST([LIB_KYOTOCABINET], ["-lkyotocabinet"])
1802    has_kyotocabinet=1
1803  ], [
1804    has_kyotocabinet=0
1805  ])
1806],
1807[has_kyotocabinet=0]
1808)
1809AC_SUBST(has_kyotocabinet)
1810AM_CONDITIONAL([HAS_KYOTOCABINET], [ test "x${has_kyotocabinet}" = "x1" ])
1811
1812# -----------------------------------------------------------------------------
1813# 5. CHECK FOR HEADER FILES
1814
1815AC_CHECK_HEADERS([sys/types.h \
1816                  sys/uio.h \
1817                  sys/mman.h \
1818                  sys/epoll.h \
1819                  sys/event.h \
1820                  sys/param.h \
1821                  sys/pset.h \
1822                  sched.h \
1823                  pthread.h \
1824                  sys/endian.h \
1825                  machine/endian.h \
1826                  endian.h \
1827                  sys/sysinfo.h \
1828                  sys/systeminfo.h \
1829                  netinet/in.h \
1830                  netinet/in_systm.h \
1831                  netinet/tcp.h \
1832                  sys/ioctl.h \
1833                  sys/byteorder.h \
1834                  sys/sockio.h \
1835                  sys/prctl.h \
1836                  arpa/nameser.h \
1837                  arpa/nameser_compat.h \
1838                  execinfo.h \
1839                  netdb.h \
1840                  ctype.h \
1841                  siginfo.h \
1842                  malloc.h \
1843                  float.h \
1844                  libgen.h \
1845                  values.h \
1846                  alloca.h \
1847                  cpio.h \
1848                  stropts.h \
1849                  sys/param.h \
1850                  sys/sysmacros.h \
1851                  stdint.h \
1852                  stdbool.h \
1853                  sysexits.h \
1854                  net/ppp_defs.h \
1855                  ifaddrs.h\
1856                  readline/readline.h \
1857                  editline/readline.h \
1858                  ucred.h ])
1859
1860# On OpenBSD, pthread.h must be included before pthread_np.h
1861AC_CHECK_HEADERS([pthread_np.h], [], [], [#include <pthread.h>])
1862AC_CHECK_HEADERS([sys/statfs.h sys/statvfs.h sys/disk.h sys/disklabel.h])
1863AC_CHECK_HEADERS([linux/hdreg.h linux/fs.h linux/major.h])
1864
1865AC_CHECK_HEADERS([sys/sysctl.h], [], [],
1866                 [[#ifdef HAVE_SYS_PARAM_H
1867                    #include <sys/param.h>
1868                   #endif
1869                 ]])
1870
1871AC_CHECK_HEADERS([sys/cpuset.h], [], [],
1872                 [[#ifdef HAVE_SYS_PARAM_H
1873                    #include <sys/param.h>
1874                   #endif
1875                 ]])
1876
1877AC_CHECK_HEADERS([sys/mount.h], [], [],
1878                 [[#ifdef HAVE_SYS_PARAM_H
1879                    #include <sys/param.h>
1880                   #endif
1881                 ]])
1882
1883AC_CHECK_HEADERS([arpa/inet.h], [], [],
1884                 [[#ifdef HAVE_SYS_TYPES_H
1885                    #include <sys/types.h>
1886                   #endif
1887                   #ifdef HAVE_NETINET_IN_H
1888                    #include <netinet/in.h>
1889                   #endif
1890                 ]])
1891
1892AC_CHECK_HEADERS([netinet/ip.h], [], [],
1893                 [[#ifdef HAVE_SYS_TYPES_H
1894                    #include <sys/types.h>
1895                   #endif
1896                   #ifdef HAVE_NETINET_IN_H
1897                    #include <netinet/in.h>
1898                   #endif
1899                   #ifdef HAVE_NETINET_IN_SYSTM_H
1900                    #include <netinet/in_systm.h>
1901                   #endif
1902                 ]])
1903
1904AC_CHECK_HEADERS([netinet/ip_icmp.h], [], [],
1905                 [[#ifdef HAVE_SYS_TYPES_H
1906                    #include <sys/types.h>
1907                   #endif
1908                   #ifdef HAVE_NETINET_IN_H
1909                    #include <netinet/in.h>
1910                   #endif
1911                   #ifdef HAVE_NETINET_IP_H
1912                    #include <netinet/ip.h>
1913                   #endif
1914                   #ifdef HAVE_NETINET_IN_SYSTM_H
1915                    #include <netinet/in_systm.h>
1916                   #endif
1917                 ]])
1918
1919
1920# Test for additional pthread interfaces.
1921
1922# Darwin pthread_setname_np:
1923AC_MSG_CHECKING([for 1-parameter version of pthread_setname_np()])
1924AC_LINK_IFELSE([
1925    AC_LANG_PROGRAM([
1926#if HAVE_PTHREAD_H
1927#include <pthread.h>
1928#endif
1929#if PTHREAD_NP_H
1930#include <pthread_np.h>
1931#endif
1932      ], [
1933        pthread_setname_np("conftest");
1934    ])
1935  ], [
1936    AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_1, 1, [Whether the 1 parameter version of pthread_setname_np() is available])
1937    AC_MSG_RESULT([yes])
1938  ], [
1939    AC_MSG_RESULT([no])
1940])
1941
1942# Linux pthread_setname_np:
1943AC_MSG_CHECKING([for 2-parameter version of pthread_setname_np()])
1944AC_LINK_IFELSE([
1945    AC_LANG_PROGRAM([
1946#if HAVE_PTHREAD_H
1947#include <pthread.h>
1948#endif
1949#if PTHREAD_NP_H
1950#include <pthread_np.h>
1951#endif
1952      ], [
1953        pthread_setname_np(pthread_self(), "conftest");
1954    ])
1955  ], [
1956    AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_2, 1, [Whether the 2 parameter version of pthread_setname_np() is available])
1957    AC_MSG_RESULT([yes])
1958  ], [
1959    AC_MSG_RESULT([no])
1960])
1961
1962# BSD pthread_set_name_np:
1963AC_MSG_CHECKING([for 2-parameter version of pthread_set_name_np()])
1964AC_LINK_IFELSE([
1965    AC_LANG_PROGRAM([
1966#if HAVE_PTHREAD_H
1967#include <pthread.h>
1968#endif
1969#if PTHREAD_NP_H
1970#include <pthread_np.h>
1971#endif
1972      ], [
1973        pthread_set_name_np(pthread_self(), "conftest");
1974    ])
1975  ], [
1976    AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP_2, 1, [Whether the 2 parameter version of pthread_set_name_np() is available])
1977    AC_MSG_RESULT([yes])
1978  ], [
1979    AC_MSG_RESULT([no])
1980])
1981
1982# pthread_getname_np / pthread_get_name_np:
1983AC_MSG_CHECKING([pthread_getname_np()])
1984AC_LINK_IFELSE([
1985    AC_LANG_PROGRAM([
1986#if HAVE_PTHREAD_H
1987#include <pthread.h>
1988#endif
1989#if PTHREAD_NP_H
1990#include <pthread_np.h>
1991#endif
1992      ], [
1993        char name[[32]];
1994        pthread_getname_np(pthread_self(), name, sizeof(name));
1995    ])
1996  ], [
1997    AC_DEFINE(HAVE_PTHREAD_GETNAME_NP, 1, [Whether pthread_getname_np() is available])
1998    AC_MSG_RESULT([yes])
1999  ], [
2000    AC_MSG_RESULT([no])
2001    AC_MSG_CHECKING([pthread_get_name_np()])
2002    AC_LINK_IFELSE([
2003        AC_LANG_PROGRAM([
2004    #if HAVE_PTHREAD_H
2005    #include <pthread.h>
2006    #endif
2007    #if PTHREAD_NP_H
2008    #include <pthread_np.h>
2009    #endif
2010          ], [
2011            char name[[32]];
2012            pthread_get_name_np(pthread_self(), name, sizeof(name));
2013        ])
2014      ], [
2015        AC_DEFINE(HAVE_PTHREAD_GET_NAME_NP, 1, [Whether pthread_get_name_np() is available])
2016        AC_MSG_RESULT([yes])
2017      ], [
2018        AC_MSG_RESULT([no])
2019    ])
2020])
2021
2022# BSD-derived systems populate the socket length in the structure itself. It's
2023# redundant to check all of these, but hey, I need the typing practice. Also, we
2024# check for the linux updated version of tcp.h, in linux/tcp.h
2025AC_CHECK_MEMBER([struct sockaddr.sa_len], [], [], [#include <netinet/in.h>])
2026AC_CHECK_MEMBER([struct sockaddr_in.sin_len], [], [], [#include <netinet/in.h>])
2027AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len], [], [], [#include <netinet/in.h>])
2028AC_CHECK_MEMBER([struct tcp_info.tcpi_data_segs_out], [], [], [#include <linux/tcp.h>])
2029
2030if test "x${ac_cv_member_struct_sockaddr_sa_len}" = "xyes"; then
2031    AC_DEFINE(HAVE_STRUCT_SOCKADDR_SA_LEN, 1,
2032            [Whether struct sockaddr_in has the sa_len member])
2033fi
2034
2035if test "x${ac_cv_member_struct_sockaddr_in_sin_len}" = "xyes"; then
2036AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN_SIN_LEN, 1,
2037            [Whether struct sockaddr_in has the sin_len member])
2038fi
2039
2040if test "x${ac_cv_member_struct_sockaddr_in6_sin6_len}" = "xyes"; then
2041    AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN, 1,
2042            [Whether struct sockaddr_in6 has the sin6_len member])
2043fi
2044
2045if test "x${ac_cv_member_struct_tcp_info_tcpi_data_segs_out}" = "xyes"; then
2046    AC_DEFINE(HAVE_STRUCT_LINUX_TCP_INFO, 1,
2047            [Whether struct tcp_info have the tcpi_data_segs_{in,out} member])
2048fi
2049
2050if test "x${with_profiler}" = "xyes"; then
2051AC_CHECK_HEADERS([gperftools/profiler.h \
2052                  ], [], [])
2053fi
2054
2055if test "x${enable_posix_cap}" != "xno"; then
2056  AC_CHECK_HEADERS([sys/capability.h],
2057    [],
2058    [AC_MSG_FAILURE([Found POSIX capabilities library but not the header sys/capability.h. POSIX capabilities are not a required feature, you can disable then with --disable-posix-cap])],
2059    []
2060  )
2061fi
2062
2063# Check for high-resolution timestamps in struct stat
2064AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec])
2065AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec])
2066
2067
2068#
2069# Configure sockopt value for TPROXY. Look at the enable flag.
2070# Value 'no' means user forced disable, don't check anything else.
2071#       'auto' means user didn't say, so silently enable/disable
2072#              based on success.
2073#       A numeric value means enable, don't check, use that value.
2074#       Anything else means user forced, fail if value not found
2075#       in header file.
2076# We can't just include linux/in.h because it's incompatible with
2077# netinet/in.h.
2078# Verify the file exists (is readable), scan for the value we need,
2079# if found export the value and enable use of the value.
2080#
2081ip_transparent=0
2082use_tproxy=0
2083tproxy_header=/usr/include/linux/in.h
2084tproxy_usage_enable="
2085    --enable-tproxy Enable the feature and validate."
2086tproxy_usage_default="
2087    --enable-tproxy=force Enable using default sockopt value, no validation."
2088tproxy_usage_numeric="
2089    --enable-tproxy=X where X is numeric
2090                      Enable, use X for sockopt value, no validation."
2091tproxy_usage_disable="
2092    --disable-tproxy Disable feature, no validation."
2093proxy_usage="$tproxy_usage_enable$tproxy_usage_default$tproxy_usage_numeric$tproxy_usage_disable"
2094
2095AC_MSG_CHECKING([whether to enable transparent proxy])
2096AS_IF([test "x$enable_tproxy" != "xno"], [
2097  AS_IF([test "$use_posix_cap" -eq 0], [
2098    AS_IF([test "x$enable_tproxy" = xauto], [
2099      AC_MSG_RESULT([no])
2100    ],[
2101      AC_MSG_FAILURE([TPROXY feature requires POSIX capabilities.])
2102    ])
2103  ],[
2104    AC_MSG_CHECKING([for TPROXY sockopt IP_TRANSPARENT])
2105    case "$enable_tproxy" in
2106      [[0-9][0-9]*])
2107        ip_transparent=$enable_tproxy
2108        use_tproxy=1
2109        AC_MSG_RESULT([forced to $ip_transparent])
2110        ;;
2111      force)
2112        ip_transparent=19
2113        use_tproxy=1
2114        AC_MSG_RESULT([forced to $ip_transparent])
2115        ;;
2116      yes|auto)
2117        AS_IF([test -r $tproxy_header], [
2118          ip_transparent=`$AWK "/^#define[ \t]+IP_TRANSPARENT[ \t]+[0-9]+/{print \\$3}" $tproxy_header`
2119          AS_IF([test "x$ip_transparent" != "x"], [
2120            use_tproxy=1
2121            AC_MSG_RESULT([set to $ip_transparent])
2122          ],[
2123            ip_transparent=0
2124            AS_IF([test "x$enable_tproxy" = xauto], [
2125             AC_MSG_RESULT([no])
2126            ],[
2127              AC_MSG_RESULT([failed])
2128              AC_MSG_FAILURE([tproxy feature enabled but the sockopt value was not found in $tproxy_header. Try one of$tproxy_usage_default$tproxy_usage_numeric$tproxy_usage_disable])
2129            ])
2130          ])
2131        ],[
2132          AS_IF([test "x$enable_tproxy" = xauto], [
2133            AC_MSG_RESULT([no])
2134          ],[
2135            AC_MSG_RESULT([failed])
2136            AC_MSG_FAILURE([tproxy feature enabled but the header file $tproxy_header was not readable. Try one of$tproxy_usage_default$tproxy_usage_numeric$tproxy_usage_disable])
2137          ])
2138        ])
2139        ;;
2140      *)
2141        AC_MSG_RESULT([failed])
2142        AC_MSG_FAILURE([Invalid argument to feature tproxy.$tproxy_usage])
2143        ;;
2144      esac
2145  ])
2146])
2147
2148AC_SUBST(use_tproxy)
2149AC_SUBST(ip_transparent)
2150
2151TS_CHECK_SOCKOPT(SO_PEERCRED, [has_so_peercred=1], [has_so_peercred=0])
2152TS_CHECK_SOCKOPT(SO_MARK, [has_so_mark=1], [has_so_mark=0])
2153TS_CHECK_SOCKOPT(IP_TOS, [has_ip_tos=1], [has_ip_tos=0])
2154
2155AC_SUBST(has_so_mark)
2156AC_SUBST(has_ip_tos)
2157AC_SUBST(has_so_peercred)
2158
2159TS_CHECK_LOOPBACK_IFACE
2160TS_CHECK_MACRO_IN6_IS_ADDR_UNSPECIFIED
2161
2162AC_CHECK_TYPE([struct tcp_info],
2163  [AC_DEFINE(HAVE_STRUCT_TCP_INFO, 1, [whether struct tcp_info is available])],
2164  [],
2165  [[
2166   #include <netinet/in.h>
2167   #include <netinet/tcp.h>
2168  ]]
2169)
2170
2171AC_MSG_CHECKING([whether to include systemtap tracing support])
2172AC_ARG_ENABLE([systemtap],
2173              [AS_HELP_STRING([--enable-systemtap],
2174                              [Enable inclusion of systemtap trace support])],
2175              [ENABLE_SYSTEMTAP="${enableval}"], [ENABLE_SYSTEMTAP='no'])
2176AM_CONDITIONAL([ENABLE_SYSTEMTAP], [test x$ENABLE_SYSTEMTAP = xyes])
2177AC_MSG_RESULT(${ENABLE_SYSTEMTAP})
2178
2179if test "x${ENABLE_SYSTEMTAP}" = xyes; then
2180  AC_CHECK_PROGS(DTRACE, dtrace)
2181  if test -z "$DTRACE"; then
2182    AC_MSG_ERROR([dtrace not found])
2183  fi
2184  AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND='yes'],
2185                  [SDT_H_FOUND='no';
2186                     AC_MSG_ERROR([systemtap support needs sys/sdt.h header])])
2187  AC_DEFINE([HAVE_SYSTEMTAP], [1], [Define to 1 if using probes.])
2188fi
2189
2190# See if we can build the remap_stats plugin
2191AS_IF([test "x$enable_experimental_plugins" = "xyes"],
2192  [
2193    AC_CHECK_HEADERS([search.h])
2194    AS_IF([test "x$ac_cv_header_search_h" = "xyes"],
2195      [
2196        AC_CHECK_TYPE([struct hsearch_data],[],[],[[#include <search.h>]])
2197        AC_CHECK_FUNCS([hcreate_r hsearch_r])
2198      ])
2199  ])
2200
2201AC_ARG_WITH([default-stack-size],
2202  [AS_HELP_STRING([--with-default-stack-size],[specify the default stack size in bytes [default=1048576]])],
2203  [
2204  with_default_stack_size="$withval"
2205  ],[
2206  with_default_stack_size="1048576"
2207  ]
2208)
2209
2210AC_SUBST([default_stack_size], [$with_default_stack_size])
2211
2212#
2213# use modular IOCORE
2214#
2215iocore_include_dirs="\
2216-I\$(abs_top_srcdir)/iocore/eventsystem \
2217-I\$(abs_top_srcdir)/iocore/net \
2218-I\$(abs_top_srcdir)/iocore/net/quic \
2219-I\$(abs_top_srcdir)/iocore/aio \
2220-I\$(abs_top_srcdir)/iocore/hostdb \
2221-I\$(abs_top_srcdir)/iocore/cache \
2222-I\$(abs_top_srcdir)/iocore/utils \
2223-I\$(abs_top_srcdir)/iocore/dns"
2224
2225AC_SUBST([AM_CPPFLAGS])
2226AC_SUBST([AM_CFLAGS])
2227AC_SUBST([AM_CXXFLAGS])
2228AC_SUBST([AM_LDFLAGS])
2229AC_SUBST([iocore_include_dirs])
2230
2231# NOTE: All additions to the default include path must be added to
2232# TS_INCLUDES *not* to AM_CPPFLAGS. If you add then to AM_CPPFLAGS
2233# then they are always prepended to the local AM_CPPFLAGS which risks
2234# name collisions with in-tree files. We always want the in-tree files
2235# to have precedence.
2236AC_SUBST([TS_INCLUDES])
2237
2238AS_IF([test "x$RPATH" != "x"], [
2239       TS_ADDTO_RPATH([$RPATH])
2240])
2241
2242# -----------------------------------------------------------------------------
2243# 6. OUTPUT FILES
2244
2245AC_CONFIG_FILES([
2246  Makefile
2247  src/Makefile
2248  configs/Makefile
2249  configs/body_factory/Makefile
2250  configs/body_factory/default/Makefile
2251  configs/records.config.default
2252  configs/storage.config.default
2253  doc/Makefile
2254  doc/ext/local-config.py
2255  doc/uml/Makefile
2256  example/Makefile
2257  example/plugins/Makefile
2258  example/plugins/c-api/Makefile
2259  example/plugins/cpp-api/Makefile
2260  include/Makefile
2261  include/ts/Makefile
2262  include/tscpp/api/Makefile
2263  include/tscpp/util/Makefile
2264  iocore/Makefile
2265  iocore/aio/Makefile
2266  iocore/cache/Makefile
2267  iocore/dns/Makefile
2268  iocore/eventsystem/Makefile
2269  iocore/hostdb/Makefile
2270  iocore/net/Makefile
2271  iocore/net/quic/Makefile
2272  iocore/utils/Makefile
2273  lib/Makefile
2274  src/tscpp/api/Makefile
2275  lib/perl/Makefile
2276  lib/perl/lib/Apache/TS.pm
2277  lib/records/Makefile
2278  include/ts/apidefs.h
2279  include/tscore/ink_config.h
2280  src/wccp/Makefile
2281  lib/yamlcpp/Makefile
2282  mgmt/Makefile
2283  mgmt/api/Makefile
2284  mgmt/api/include/Makefile
2285  mgmt/utils/Makefile
2286  plugins/Makefile
2287  proxy/Makefile
2288  proxy/hdrs/Makefile
2289  proxy/http/Makefile
2290  proxy/http/remap/Makefile
2291  proxy/http2/Makefile
2292  proxy/http3/Makefile
2293  proxy/logging/Makefile
2294  proxy/shared/Makefile
2295  rc/Makefile
2296  rc/trafficserver
2297  rc/trafficserver.conf
2298  rc/trafficserver.service
2299  rc/trafficserver.xml
2300  src/tscpp/util/Makefile
2301  src/tscore/Makefile
2302  tools/Makefile
2303  tools/trafficserver.pc
2304  tools/tsxs
2305  tests/unit_tests/Makefile
2306  tests/Makefile
2307])
2308
2309# -----------------------------------------------------------------------------
2310# 7. autoheader TEMPLATES
2311
2312AC_OUTPUT
2313
2314AC_MSG_NOTICE([Build option summary:
2315    CC:                 $CC
2316    CXX:                $CXX
2317    CPP:                $CPP
2318    CFLAGS:             $CFLAGS
2319    CXXFLAGS:           $CXXFLAGS
2320    CPPFLAGS:           $CPPFLAGS
2321    LDFLAGS:            $LDFLAGS
2322    AM@&t@_CFLAGS:          $AM_CFLAGS
2323    AM@&t@_CXXFLAGS:        $AM_CXXFLAGS
2324    AM@&t@_CPPFLAGS:        $AM_CPPFLAGS
2325    AM@&t@_LDFLAGS:         $AM_LDFLAGS
2326    TS_INCLUDES:        $TS_INCLUDES
2327    OPENSSL_LDFLAGS:    $OPENSSL_LDFLAGS
2328    OPENSSL_INCLUDES:   $OPENSSL_INCLUDES
2329    YAMLCPP_LDFLAGS:    $YAMLCPP_LDFLAGS
2330    YAMLCPP_INCLUDES:   $YAMLCPP_INCLUDES
2331])
2332