Upgrade to 1.46.0
[platform/upstream/nghttp2.git] / configure.ac
1 dnl nghttp2 - HTTP/2 C Library
2
3 dnl Copyright (c) 2012, 2013, 2014, 2015 Tatsuhiro Tsujikawa
4
5 dnl Permission is hereby granted, free of charge, to any person obtaining
6 dnl a copy of this software and associated documentation files (the
7 dnl "Software"), to deal in the Software without restriction, including
8 dnl without limitation the rights to use, copy, modify, merge, publish,
9 dnl distribute, sublicense, and/or sell copies of the Software, and to
10 dnl permit persons to whom the Software is furnished to do so, subject to
11 dnl the following conditions:
12
13 dnl The above copyright notice and this permission notice shall be
14 dnl included in all copies or substantial portions of the Software.
15
16 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 dnl EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 dnl NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 dnl LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 dnl OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 dnl WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24 dnl Do not change user variables!
25 dnl https://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html
26
27 AC_PREREQ(2.61)
28 AC_INIT([nghttp2], [1.46.0], [t-tujikawa@users.sourceforge.net])
29 AC_CONFIG_AUX_DIR([.])
30 AC_CONFIG_MACRO_DIR([m4])
31 AC_CONFIG_HEADERS([config.h])
32 AC_USE_SYSTEM_EXTENSIONS
33
34 LT_PREREQ([2.2.6])
35 LT_INIT()
36
37 AC_CANONICAL_BUILD
38 AC_CANONICAL_HOST
39 AC_CANONICAL_TARGET
40
41 AM_INIT_AUTOMAKE([subdir-objects])
42
43 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
44
45 dnl See versioning rule:
46 dnl  https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
47 AC_SUBST(LT_CURRENT, 35)
48 AC_SUBST(LT_REVISION, 1)
49 AC_SUBST(LT_AGE, 21)
50
51 major=`echo $PACKAGE_VERSION |cut -d. -f1 | sed -e "s/[^0-9]//g"`
52 minor=`echo $PACKAGE_VERSION |cut -d. -f2 | sed -e "s/[^0-9]//g"`
53 patch=`echo $PACKAGE_VERSION |cut -d. -f3 | cut -d- -f1 | sed -e "s/[^0-9]//g"`
54
55 PACKAGE_VERSION_NUM=`printf "0x%02x%02x%02x" "$major" "$minor" "$patch"`
56
57 AC_SUBST(PACKAGE_VERSION_NUM)
58
59 dnl Checks for command-line options
60 AC_ARG_ENABLE([werror],
61     [AS_HELP_STRING([--enable-werror],
62                     [Turn on compile time warnings])],
63     [werror=$enableval], [werror=no])
64
65 AC_ARG_ENABLE([debug],
66     [AS_HELP_STRING([--enable-debug],
67                     [Turn on debug output])],
68     [debug=$enableval], [debug=no])
69
70 AC_ARG_ENABLE([threads],
71     [AS_HELP_STRING([--disable-threads],
72                     [Turn off threading in apps])],
73     [threads=$enableval], [threads=yes])
74
75 AC_ARG_ENABLE([app],
76     [AS_HELP_STRING([--enable-app],
77                     [Build applications (nghttp, nghttpd, nghttpx and h2load) [default=check]])],
78     [request_app=$enableval], [request_app=check])
79
80 AC_ARG_ENABLE([hpack-tools],
81     [AS_HELP_STRING([--enable-hpack-tools],
82                     [Build HPACK tools [default=check]])],
83     [request_hpack_tools=$enableval], [request_hpack_tools=check])
84
85 AC_ARG_ENABLE([asio-lib],
86     [AS_HELP_STRING([--enable-asio-lib],
87                     [Build C++ libnghttp2_asio library [default=no]])],
88     [request_asio_lib=$enableval], [request_asio_lib=no])
89
90 AC_ARG_ENABLE([examples],
91     [AS_HELP_STRING([--enable-examples],
92                     [Build examples [default=check]])],
93     [request_examples=$enableval], [request_examples=check])
94
95 AC_ARG_ENABLE([python-bindings],
96     [AS_HELP_STRING([--enable-python-bindings],
97                     [Build Python bindings [default=check]])],
98     [request_python_bindings=$enableval], [request_python_bindings=check])
99
100 AC_ARG_ENABLE([failmalloc],
101     [AS_HELP_STRING([--disable-failmalloc],
102                     [Do not build failmalloc test program])],
103     [request_failmalloc=$enableval], [request_failmalloc=yes])
104
105 AC_ARG_ENABLE([lib-only],
106     [AS_HELP_STRING([--enable-lib-only],
107                     [Build libnghttp2 only.  This is a short hand for --disable-app --disable-examples --disable-hpack-tools --disable-python-bindings])],
108     [request_lib_only=$enableval], [request_lib_only=no])
109
110 AC_ARG_ENABLE([http3],
111     [AS_HELP_STRING([--enable-http3],
112                     [(EXPERIMENTAL) Enable HTTP/3.  This requires ngtcp2, nghttp3, and a custom OpenSSL.])],
113     [request_http3=$enableval], [request_http3=no])
114
115 AC_ARG_WITH([libxml2],
116     [AS_HELP_STRING([--with-libxml2],
117                     [Use libxml2 [default=check]])],
118     [request_libxml2=$withval], [request_libxml2=check])
119
120 AC_ARG_WITH([jansson],
121     [AS_HELP_STRING([--with-jansson],
122                     [Use jansson [default=check]])],
123     [request_jansson=$withval], [request_jansson=check])
124
125 AC_ARG_WITH([zlib],
126     [AS_HELP_STRING([--with-zlib],
127                     [Use zlib [default=check]])],
128     [request_zlib=$withval], [request_zlib=check])
129
130 AC_ARG_WITH([libevent-openssl],
131     [AS_HELP_STRING([--with-libevent-openssl],
132                     [Use libevent_openssl [default=check]])],
133     [request_libevent_openssl=$withval], [request_libevent_openssl=check])
134
135 AC_ARG_WITH([libcares],
136     [AS_HELP_STRING([--with-libcares],
137                     [Use libc-ares [default=check]])],
138     [request_libcares=$withval], [request_libcares=check])
139
140 AC_ARG_WITH([openssl],
141     [AS_HELP_STRING([--with-openssl],
142                     [Use openssl [default=check]])],
143     [request_openssl=$withval], [request_openssl=check])
144
145 AC_ARG_WITH([libev],
146     [AS_HELP_STRING([--with-libev],
147                     [Use libev [default=check]])],
148     [request_libev=$withval], [request_libev=check])
149
150 AC_ARG_WITH([cunit],
151     [AS_HELP_STRING([--with-cunit],
152                     [Use cunit [default=check]])],
153     [request_cunit=$withval], [request_cunit=check])
154
155 AC_ARG_WITH([jemalloc],
156     [AS_HELP_STRING([--with-jemalloc],
157                     [Use jemalloc [default=check]])],
158     [request_jemalloc=$withval], [request_jemalloc=check])
159
160 AC_ARG_WITH([systemd],
161     [AS_HELP_STRING([--with-systemd],
162                     [Enable systemd support in nghttpx [default=check]])],
163     [request_systemd=$withval], [request_systemd=check])
164
165 AC_ARG_WITH([mruby],
166     [AS_HELP_STRING([--with-mruby],
167                     [Use mruby [default=no]])],
168     [request_mruby=$withval], [request_mruby=no])
169
170 AC_ARG_WITH([neverbleed],
171     [AS_HELP_STRING([--with-neverbleed],
172                     [Use neverbleed [default=no]])],
173     [request_neverbleed=$withval], [request_neverbleed=no])
174
175 AC_ARG_WITH([cython],
176     [AS_HELP_STRING([--with-cython=PATH],
177                     [Use cython in given PATH])],
178     [cython_path=$withval], [])
179
180 AC_ARG_WITH([libngtcp2],
181     [AS_HELP_STRING([--with-libngtcp2],
182                     [Use libngtcp2 [default=check]])],
183     [request_libngtcp2=$withval], [request_libngtcp2=check])
184
185 AC_ARG_WITH([libnghttp3],
186     [AS_HELP_STRING([--with-libnghttp3],
187                     [Use libnghttp3 [default=check]])],
188     [request_libnghttp3=$withval], [request_libnghttp3=check])
189
190 AC_ARG_WITH([libbpf],
191     [AS_HELP_STRING([--with-libbpf],
192                     [Use libbpf [default=no]])],
193     [request_libbpf=$withval], [request_libbpf=no])
194
195 dnl Define variables
196 AC_ARG_VAR([CYTHON], [the Cython executable])
197
198 AC_ARG_VAR([LIBEV_CFLAGS], [C compiler flags for libev, skipping any checks])
199 AC_ARG_VAR([LIBEV_LIBS], [linker flags for libev, skipping any checks])
200
201 AC_ARG_VAR([JEMALLOC_CFLAGS],
202            [C compiler flags for jemalloc, skipping any checks])
203 AC_ARG_VAR([JEMALLOC_LIBS], [linker flags for jemalloc, skipping any checks])
204
205 AC_ARG_VAR([LIBTOOL_LDFLAGS],
206            [libtool specific flags (e.g., -static-libtool-libs)])
207
208 AC_ARG_VAR([BPFCFLAGS], [C compiler flags for bpf program])
209
210 dnl Checks for programs
211 AC_PROG_CC
212 AC_PROG_CXX
213 AC_PROG_CPP
214 AC_PROG_INSTALL
215 AC_PROG_LN_S
216 AC_PROG_MAKE_SET
217 AC_PROG_MKDIR_P
218
219 PKG_PROG_PKG_CONFIG([0.20])
220
221 AM_PATH_PYTHON([3.8],, [:])
222
223 if test "x$request_python_bindings" = "xyes" &&
224    test "x$PYTHON" = "x:"; then
225   AC_MSG_ERROR([python was requested (enable-python-bindings) but not found])
226 fi
227
228 if [test "x$request_lib_only" = "xyes"]; then
229   request_app=no
230   request_hpack_tools=no
231   request_examples=no
232   request_python_bindings=no
233 fi
234
235 if test "x$request_python_bindings" != "xno" &&
236    test "x$PYTHON" != "x:"; then
237   # version check is broken
238   AX_PYTHON_DEVEL()
239 fi
240
241 if test "x${cython_path}" = "x"; then
242   AC_CHECK_PROGS([CYTHON], [cython.py cython])
243 else
244   CYTHON=${cython_path}
245   AC_SUBST([CYTHON])
246 fi
247
248 if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
249   AC_DEFINE([NGHTTP2_NORETURN], [__attribute__((noreturn))], [Hint to the compiler that a function never return])
250 else
251   AC_DEFINE([NGHTTP2_NORETURN], , [Hint to the compiler that a function never return])
252 fi
253
254 save_CXXFLAGS="$CXXFLAGS"
255 CXXFLAGS=
256
257 AX_CXX_COMPILE_STDCXX([14], [noext], [optional])
258
259 CXX1XCXXFLAGS="$CXXFLAGS"
260 CXXFLAGS="$save_CXXFLAGS"
261 AC_SUBST([CXX1XCXXFLAGS])
262
263 AC_LANG_PUSH(C++)
264
265 save_CXXFLAGS="$CXXFLAGS"
266 CXXFLAGS="$CXXFLAGS $CXX1XCXXFLAGS"
267
268 # Check that std::future is available.
269 AC_MSG_CHECKING([whether std::future is available])
270 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
271 [[
272 #include <vector>
273 #include <future>
274 ]],
275 [[
276 std::vector<std::future<int>> v;
277 (void)v;
278 ]])],
279     [AC_DEFINE([HAVE_STD_FUTURE], [1],
280                [Define to 1 if you have the `std::future`.])
281      have_std_future=yes
282      AC_MSG_RESULT([yes])],
283     [have_std_future=no
284      AC_MSG_RESULT([no])])
285
286 # Check that std::map::emplace is available for g++-4.7.
287 AC_MSG_CHECKING([whether std::map::emplace is available])
288 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
289 [[
290 #include <map>
291 ]],
292 [[
293 std::map<int, int>().emplace(1, 2);
294 ]])],
295     [AC_DEFINE([HAVE_STD_MAP_EMPLACE], [1],
296                [Define to 1 if you have the `std::map::emplace`.])
297      have_std_map_emplace=yes
298      AC_MSG_RESULT([yes])],
299     [have_std_map_emplace=no
300      AC_MSG_RESULT([no])])
301
302 # Check that std::atomic_* overloads for std::shared_ptr are
303 # available.
304 AC_MSG_CHECKING([whether std::atomic_* overloads for std::shared_ptr are available])
305 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
306 [[
307 #include <memory>
308 ]],
309 [[
310 auto a = std::make_shared<int>(1000000007);
311 auto p = std::atomic_load(&a);
312 ++*p;
313 std::atomic_store(&a, p);
314 ]])],
315     [AC_DEFINE([HAVE_ATOMIC_STD_SHARED_PTR], [1],
316                [Define to 1 if you have the std::atomic_* overloads for std::shared_ptr.])
317      have_atomic_std_shared_ptr=yes
318      AC_MSG_RESULT([yes])],
319     [have_atomic_std_shared_ptr=no
320      AC_MSG_RESULT([no])])
321
322 # Check that thread_local storage specifier is available
323 AC_MSG_CHECKING([whether thread_local storage class specifier is available.])
324 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
325 ,
326 [[
327 thread_local int a = 0;
328 (void)a;
329 ]])],
330     [AC_DEFINE([HAVE_THREAD_LOCAL], [1],
331                [Define to 1 if you have thread_local storage specifier.])
332      have_thread_local=yes
333      AC_MSG_RESULT([yes])],
334     [have_Thread_local=no
335      AC_MSG_RESULT([no])])
336
337 CXXFLAGS=$save_CXXFLAGS
338
339 AC_LANG_POP()
340
341 # Checks for libraries.
342
343 # Additional libraries required for tests.
344 TESTLDADD=
345
346 # Additional libraries required for programs under src directory.
347 APPLDFLAGS=
348
349 case "$host_os" in
350   *android*)
351     android_build=yes
352     # android does not need -pthread, but needs followng 3 libs for C++
353     APPLDFLAGS="$APPLDFLAGS -lstdc++ -latomic -lsupc++"
354     ;;
355   *)
356     PTHREAD_LDFLAGS="-pthread"
357     APPLDFLAGS="$APPLDFLAGS $PTHREAD_LDFLAGS"
358     ;;
359 esac
360
361 case "$host_os" in
362   *solaris*)
363     APPLDFLAGS="$APPLDFLAGS -lsocket -lnsl"
364     ;;
365 esac
366
367 case "${build}" in
368   *-apple-darwin*)
369     EXTRA_DEFS="-D__APPLE_USE_RFC_3542"
370     AC_SUBST([EXTRA_DEFS])
371     ;;
372 esac
373
374 # zlib
375 have_zlib=no
376 if test "x${request_zlib}" != "xno"; then
377   PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.3], [have_zlib=yes], [have_zlib=no])
378
379   if test "x${have_zlib}" = "xno"; then
380     AC_MSG_NOTICE($ZLIB_PKG_ERRORS)
381   fi
382 fi
383
384 if test "x${request_zlib}" = "xyes" &&
385    test "x${have_zlib}" != "xyes"; then
386   AC_MSG_ERROR([zlib was requested (--with-zlib) but not found])
387 fi
388
389 # dl: openssl requires libdl when it is statically linked.
390 case "${host_os}" in
391   *bsd*)
392     # dlopen is in libc on *BSD
393     ;;
394   *)
395     save_LIBS=$LIBS
396     AC_SEARCH_LIBS([dlopen], [dl], [APPLDFLAGS="-ldl $APPLDFLAGS"], [], [])
397     LIBS=$save_LIBS
398     ;;
399 esac
400
401 # cunit
402 have_cunit=no
403 if test "x${request_cunit}" != "xno"; then
404   PKG_CHECK_MODULES([CUNIT], [cunit >= 2.1], [have_cunit=yes], [have_cunit=no])
405   # If pkg-config does not find cunit, check it using AC_CHECK_LIB.  We
406   # do this because Debian (Ubuntu) lacks pkg-config file for cunit.
407   if test "x${have_cunit}" = "xno"; then
408     AC_MSG_WARN([${CUNIT_PKG_ERRORS}])
409     AC_CHECK_LIB([cunit], [CU_initialize_registry],
410                  [have_cunit=yes], [have_cunit=no])
411     if test "x${have_cunit}" = "xyes"; then
412       CUNIT_LIBS="-lcunit"
413       CUNIT_CFLAGS=""
414       AC_SUBST([CUNIT_LIBS])
415       AC_SUBST([CUNIT_CFLAGS])
416     fi
417   fi
418   if test "x${have_cunit}" = "xyes"; then
419     # cunit in Mac OS X requires ncurses. Note that in Mac OS X, test
420     # program can be built without -lncurses, but it emits runtime
421     # error.
422     case "${build}" in
423       *-apple-darwin*)
424         CUNIT_LIBS="$CUNIT_LIBS -lncurses"
425         AC_SUBST([CUNIT_LIBS])
426         ;;
427     esac
428   fi
429 fi
430
431 if test "x${request_cunit}" = "xyes" &&
432    test "x${have_cunit}" != "xyes"; then
433   AC_MSG_ERROR([cunit was requested (--with-cunit) but not found])
434 fi
435
436 AM_CONDITIONAL([HAVE_CUNIT], [ test "x${have_cunit}" = "xyes" ])
437
438 # libev (for src)
439 have_libev=no
440 if test "x${request_libev}" != "xno"; then
441   if test "x${LIBEV_LIBS}" = "x" && test "x${LIBEV_CFLAGS}" = "x"; then
442     # libev does not have pkg-config file.  Check it in an old way.
443     save_LIBS=$LIBS
444     # android requires -lm for floor
445    AC_CHECK_LIB([ev], [ev_time], [have_libev=yes], [have_libev=no], [-lm])
446    if test "x${have_libev}" = "xyes"; then
447       AC_CHECK_HEADER([ev.h], [have_libev=yes], [have_libev=no])
448       if test "x${have_libev}" = "xyes"; then
449         LIBEV_LIBS=-lev
450         LIBEV_CFLAGS=
451       fi
452     fi
453     LIBS=$save_LIBS
454   else
455     have_libev=yes
456   fi
457 fi
458
459 if test "x${request_libev}" = "xyes" &&
460    test "x${have_libev}" != "xyes"; then
461   AC_MSG_ERROR([libev was requested (--with-libev) but not found])
462 fi
463
464 # openssl (for src)
465 have_openssl=no
466 if test "x${request_openssl}" != "xno"; then
467   PKG_CHECK_MODULES([OPENSSL], [openssl1.1 >= 1.0.1],
468                     [have_openssl=yes], [have_openssl=no])
469   if test "x${have_openssl}" = "xno"; then
470     AC_MSG_NOTICE($OPENSSL_PKG_ERRORS)
471   else
472     save_CFLAGS="$CFLAGS"
473     save_LIBS="$LIBS"
474     CFLAGS="$OPENSSL_CFLAGS $CFLAGS"
475     LIBS="$OPENSSL_LIBS $LIBS"
476
477     # quictls/openssl has SSL_is_quic.
478     have_ssl_is_quic=no
479     AC_MSG_CHECKING([for SSL_is_quic])
480     AC_LINK_IFELSE([AC_LANG_PROGRAM([[
481       #include <openssl/ssl.h>
482     ]], [[
483       SSL *ssl = NULL;
484       SSL_is_quic(ssl);
485     ]])],
486     [AC_MSG_RESULT([yes]); have_ssl_is_quic=yes],
487     [AC_MSG_RESULT([no]); have_ssl_is_quic=no])
488
489     # boringssl has SSL_set_quic_early_data_context.
490     AC_MSG_CHECKING([for SSL_set_quic_early_data_context])
491     AC_LINK_IFELSE([AC_LANG_PROGRAM([[
492       #include <openssl/ssl.h>
493     ]], [[
494       SSL *ssl = NULL;
495       SSL_set_quic_early_data_context(ssl, NULL, 0);
496     ]])],
497     [AC_MSG_RESULT([yes]); have_boringssl_quic=yes],
498     [AC_MSG_RESULT([no]); have_boringssl_quic=no])
499
500     CFLAGS="$save_CFLAGS"
501     LIBS="$save_LIBS"
502   fi
503 fi
504
505 if test "x${request_openssl}" = "xyes" &&
506    test "x${have_openssl}" != "xyes"; then
507   AC_MSG_ERROR([openssl was requested (--with-openssl) but not found])
508 fi
509
510 # c-ares (for src)
511 have_libcares=no
512 if test "x${request_libcares}" != "xno"; then
513   PKG_CHECK_MODULES([LIBCARES], [libcares >= 1.7.5], [have_libcares=yes],
514                     [have_libcares=no])
515   if test "x${have_libcares}" = "xno"; then
516     AC_MSG_NOTICE($LIBCARES_PKG_ERRORS)
517   fi
518 fi
519
520 if test "x${request_libcares}" = "xyes" &&
521    test "x${have_libcares}" != "xyes"; then
522   AC_MSG_ERROR([libcares was requested (--with-libcares) but not found])
523 fi
524
525 # ngtcp2 (for src)
526 have_libngtcp2=no
527 if test "x${request_libngtcp2}" != "xno"; then
528   PKG_CHECK_MODULES([LIBNGTCP2], [libngtcp2 >= 0.0.0], [have_libngtcp2=yes],
529                     [have_libngtcp2=no])
530   if test "x${have_libngtcp2}" = "xno"; then
531     AC_MSG_NOTICE($LIBNGTCP2_PKG_ERRORS)
532   fi
533 fi
534
535 if test "x${request_libngtcp2}" = "xyes" &&
536    test "x${have_libngtcp2}" != "xyes"; then
537   AC_MSG_ERROR([libngtcp2 was requested (--with-libngtcp2) but not found])
538 fi
539
540 # ngtcp2_crypto_openssl (for src)
541 have_libngtcp2_crypto_openssl=no
542 if test "x${have_ssl_is_quic}" = "xyes" &&
543    test "x${request_libngtcp2}" != "xno"; then
544   PKG_CHECK_MODULES([LIBNGTCP2_CRYPTO_OPENSSL],
545                     [libngtcp2_crypto_openssl >= 0.0.0],
546                     [have_libngtcp2_crypto_openssl=yes],
547                     [have_libngtcp2_crypto_openssl=no])
548   if test "x${have_libngtcp2_crypto_openssl}" = "xno"; then
549     AC_MSG_NOTICE($LIBNGTCP2_CRYPTO_OPENSSL_PKG_ERRORS)
550   else
551     AC_DEFINE([HAVE_LIBNGTCP2_CRYPTO_OPENSSL], [1],
552               [Define to 1 if you have `libngtcp2_crypto_openssl` library.])
553   fi
554 fi
555
556 if test "x${have_ssl_is_quic}" = "xyes" &&
557    test "x${request_libngtcp2}" = "xyes" &&
558    test "x${have_libngtcp2_crypto_openssl}" != "xyes"; then
559   AC_MSG_ERROR([libngtcp2_crypto_openssl was requested (--with-libngtcp2) but not found])
560 fi
561
562 # ngtcp2_crypto_boringssl (for src)
563 have_libngtcp2_crypto_boringssl=no
564 if test "x${have_boringssl_quic}" = "xyes" &&
565    test "x${request_libngtcp2}" != "xno"; then
566   PKG_CHECK_MODULES([LIBNGTCP2_CRYPTO_BORINGSSL],
567                     [libngtcp2_crypto_boringssl >= 0.0.0],
568                     [have_libngtcp2_crypto_boringssl=yes],
569                     [have_libngtcp2_crypto_boringssl=no])
570   if test "x${have_libngtcp2_crypto_boringssl}" = "xno"; then
571     AC_MSG_NOTICE($LIBNGTCP2_CRYPTO_BORINGSSL_PKG_ERRORS)
572   else
573     AC_DEFINE([HAVE_LIBNGTCP2_CRYPTO_BORINGSSL], [1],
574               [Define to 1 if you have `libngtcp2_crypto_boringssl` library.])
575   fi
576 fi
577
578 if test "x${have_boringssl_quic}" = "xyes" &&
579    test "x${request_libngtcp2}" = "xyes" &&
580    test "x${have_libngtcp2_crypto_boringssl}" != "xyes"; then
581   AC_MSG_ERROR([libngtcp2_crypto_boringssl was requested (--with-libngtcp2) but not found])
582 fi
583
584 # nghttp3 (for src)
585 have_libnghttp3=no
586 if test "x${request_libnghttp3}" != "xno"; then
587   PKG_CHECK_MODULES([LIBNGHTTP3], [libnghttp3 >= 0.0.0], [have_libnghttp3=yes],
588                     [have_libnghttp3=no])
589   if test "x${have_libnghttp3}" = "xno"; then
590     AC_MSG_NOTICE($LIBNGHTTP3_PKG_ERRORS)
591   fi
592 fi
593
594 if test "x${request_libnghttp3}" = "xyes" &&
595    test "x${have_libnghttp3}" != "xyes"; then
596   AC_MSG_ERROR([libnghttp3 was requested (--with-libnghttp3) but not found])
597 fi
598
599 # libbpf (for src)
600 have_libbpf=no
601 if test "x${request_libbpf}" != "xno"; then
602   PKG_CHECK_MODULES([LIBBPF], [libbpf >= 0.4.0], [have_libbpf=yes],
603                     [have_libbpf=no])
604   if test "x${have_libbpf}" = "xyes"; then
605     AC_DEFINE([HAVE_LIBBPF], [1], [Define to 1 if you have `libbpf` library.])
606     if test "x${BPFCFLAGS}" = "x"; then
607       BPFCFLAGS="-Wall -O2 -g"
608     fi
609     # Add the include path for Debian
610     EXTRABPFCFLAGS="-I/usr/include/$host_cpu-$host_os"
611     AC_SUBST([EXTRABPFCFLAGS])
612
613     AC_MSG_CHECKING([whether enum bpf_stats_type is defined in linux/bpf.h])
614     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
615     [[
616     #include <linux/bpf.h>
617     ]],
618     [[
619     enum bpf_stats_type foo;
620     (void)foo;
621     ]])],
622     [have_bpf_stats_type=yes],
623     [have_bpf_stats_type=no])
624
625     if test "x${have_bpf_stats_type}" = "xyes"; then
626       AC_MSG_RESULT([yes])
627       AC_DEFINE([HAVE_BPF_STATS_TYPE], [1],
628                 [Define to 1 if you have enum bpf_stats_type in linux/bpf.h.])
629     else
630       AC_MSG_RESULT([no])
631     fi
632   else
633     AC_MSG_NOTICE($LIBBPF_PKG_ERRORS)
634   fi
635 fi
636
637 if test "x${request_libbpf}" = "xyes" &&
638    test "x${have_libbpf}" != "xyes"; then
639   AC_MSG_ERROR([libbpf was requested (--with-libbpf) but not found])
640 fi
641
642 AM_CONDITIONAL([HAVE_LIBBPF], [ test "x${have_libbpf}" = "xyes" ])
643
644 # libevent_openssl (for examples)
645 # 2.0.8 is required because we use evconnlistener_set_error_cb()
646 have_libevent_openssl=no
647 if test "x${request_libevent_openssl}" != "xno"; then
648   PKG_CHECK_MODULES([LIBEVENT_OPENSSL], [libevent_openssl >= 2.0.8],
649                     [have_libevent_openssl=yes], [have_libevent_openssl=no])
650   if test "x${have_libevent_openssl}" = "xno"; then
651     AC_MSG_NOTICE($LIBEVENT_OPENSSL_PKG_ERRORS)
652   fi
653 fi
654
655 if test "x${request_libevent_openssl}" = "xyes" &&
656    test "x${have_libevent_openssl}" != "xyes"; then
657   AC_MSG_ERROR([libevent_openssl was requested (--with-libevent) but not found])
658 fi
659
660 # jansson (for src/nghttp, src/deflatehd and src/inflatehd)
661 have_jansson=no
662 if test "x${request_jansson}" != "xno"; then
663   PKG_CHECK_MODULES([JANSSON], [jansson >= 2.5],
664                     [have_jansson=yes], [have_jansson=no])
665   if test "x${have_jansson}" = "xyes"; then
666     AC_DEFINE([HAVE_JANSSON], [1],
667               [Define to 1 if you have `libjansson` library.])
668   else
669     AC_MSG_NOTICE($JANSSON_PKG_ERRORS)
670   fi
671 fi
672
673 if test "x${request_jansson}" = "xyes" &&
674    test "x${have_jansson}" != "xyes"; then
675   AC_MSG_ERROR([jansson was requested (--with-jansson) but not found])
676 fi
677
678 #  libsystemd (for src/nghttpx)
679 have_libsystemd=no
680 if test "x${request_systemd}" != "xno"; then
681   PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 209], [have_libsystemd=yes],
682                     [have_libsystemd=no])
683   if test "x${have_libsystemd}" = "xyes"; then
684     AC_DEFINE([HAVE_LIBSYSTEMD], [1],
685               [Define to 1 if you have `libsystemd` library.])
686   else
687     AC_MSG_NOTICE($SYSTEMD_PKG_ERRORS)
688   fi
689 fi
690
691 if test "x${request_systemd}" = "xyes" &&
692    test "x${have_libsystemd}" != "xyes"; then
693   AC_MSG_ERROR([systemd was requested (--with-systemd) but not found])
694 fi
695
696 # libxml2 (for src/nghttp)
697 have_libxml2=no
698 if test "x${request_libxml2}" != "xno"; then
699   PKG_CHECK_MODULES([LIBXML2], [libxml-2.0 >= 2.6.26],
700                     [have_libxml2=yes], [have_libxml2=no])
701   if test "x${have_libxml2}" = "xyes"; then
702     AC_DEFINE([HAVE_LIBXML2], [1], [Define to 1 if you have `libxml2` library.])
703   else
704     AC_MSG_NOTICE($LIBXML2_PKG_ERRORS)
705   fi
706 fi
707
708 if test "x${request_libxml2}" = "xyes" &&
709    test "x${have_libxml2}" != "xyes"; then
710   AC_MSG_ERROR([libxml2 was requested (--with-libxml2) but not found])
711 fi
712
713 AM_CONDITIONAL([HAVE_LIBXML2], [ test "x${have_libxml2}" = "xyes" ])
714
715 # jemalloc
716 have_jemalloc=no
717 if test "x${request_jemalloc}" != "xno"; then
718   if test "x${JEMALLOC_LIBS}" = "x" && test "x${JEMALLOC_CFLAGS}" = "x"; then
719     save_LIBS=$LIBS
720     AC_SEARCH_LIBS([malloc_stats_print], [jemalloc], [have_jemalloc=yes], [],
721                    [$PTHREAD_LDFLAGS])
722
723     if test "x${have_jemalloc}" = "xyes"; then
724       jemalloc_libs=${ac_cv_search_malloc_stats_print}
725     else
726       # On Darwin, malloc_stats_print is je_malloc_stats_print
727       AC_SEARCH_LIBS([je_malloc_stats_print], [jemalloc], [have_jemalloc=yes], [],
728                      [$PTHREAD_LDFLAGS])
729
730       if test "x${have_jemalloc}" = "xyes"; then
731         jemalloc_libs=${ac_cv_search_je_malloc_stats_print}
732       fi
733     fi
734
735     LIBS=$save_LIBS
736
737     if test "x${have_jemalloc}" = "xyes" &&
738        test "x${jemalloc_libs}" != "xnone required"; then
739       JEMALLOC_LIBS=${jemalloc_libs}
740     fi
741   else
742     have_jemalloc=yes
743   fi
744 fi
745
746 if test "x${request_jemalloc}" = "xyes" &&
747    test "x${have_jemalloc}" != "xyes"; then
748   AC_MSG_ERROR([jemalloc was requested (--with-jemalloc) but not found])
749 fi
750
751 # Check Boost Asio library
752 have_asio_lib=no
753
754 if test "x${request_asio_lib}" = "xyes"; then
755   AX_BOOST_BASE([1.54.0], [have_boost_base=yes], [have_boost_base=no])
756
757   if test "x${have_boost_base}" = "xyes"; then
758     AX_BOOST_ASIO()
759     AX_BOOST_SYSTEM()
760     AX_BOOST_THREAD()
761
762     if test "x${ax_cv_boost_asio}" = "xyes" &&
763        test "x${ax_cv_boost_system}" = "xyes" &&
764        test "x${ax_cv_boost_thread}" = "xyes"; then
765       have_asio_lib=yes
766     fi
767   fi
768 fi
769
770 # The nghttp, nghttpd and nghttpx under src depend on zlib, OpenSSL,
771 # libev, and libc-ares.
772 enable_app=no
773 if test "x${request_app}" != "xno" &&
774    test "x${have_zlib}" = "xyes" &&
775    test "x${have_openssl}" = "xyes" &&
776    test "x${have_libev}" = "xyes" &&
777    test "x${have_libcares}" = "xyes"; then
778   enable_app=yes
779 fi
780
781 if test "x${request_app}" = "xyes" &&
782    test "x${enable_app}" != "xyes"; then
783   AC_MSG_ERROR([applications were requested (--enable-app) but dependencies are not met.])
784 fi
785
786 AM_CONDITIONAL([ENABLE_APP], [ test "x${enable_app}" = "xyes" ])
787
788 # Check HTTP/3 support
789 enable_http3=no
790 if test "x${request_http3}" != "xno" &&
791    (test "x${have_ssl_is_quic}" = "xyes" ||
792     test "x${have_boringssl_quic}" = "xyes") &&
793    test "x${have_libngtcp2}" = "xyes" &&
794    (test "x${have_libngtcp2_crypto_openssl}" = "xyes" ||
795     test "x${have_libngtcp2_crypto_boringssl}" = "xyes") &&
796    test "x${have_libnghttp3}" = "xyes"; then
797   enable_http3=yes
798   AC_DEFINE([ENABLE_HTTP3], [1], [Define to 1 if HTTP/3 is enabled.])
799 fi
800
801 if test "x${request_http3}" = "xyes" &&
802    test "x${enable_http3}" != "xyes"; then
803   AC_MSG_ERROR([HTTP/3 was requested (--enable-http3) but dependencies are not met.])
804 fi
805
806 AM_CONDITIONAL([ENABLE_HTTP3], [ test "x${enable_http3}" = "xyes" ])
807
808 enable_hpack_tools=no
809 # HPACK tools requires jansson
810 if test "x${request_hpack_tools}" != "xno" &&
811    test "x${have_jansson}" = "xyes"; then
812   enable_hpack_tools=yes
813 fi
814
815 if test "x${request_hpack_tools}" = "xyes" &&
816    test "x${enable_hpack_tools}" != "xyes"; then
817   AC_MSG_ERROR([HPACK tools were requested (--enable-hpack-tools) but dependencies are not met.])
818 fi
819
820 AM_CONDITIONAL([ENABLE_HPACK_TOOLS], [ test "x${enable_hpack_tools}" = "xyes" ])
821
822 # C++ library libnghttp2_asio
823
824 enable_asio_lib=no
825 if test "x${request_asio_lib}" != "xno" &&
826    test "x${have_asio_lib}" = "xyes"; then
827   enable_asio_lib=yes
828 fi
829
830 AM_CONDITIONAL([ENABLE_ASIO_LIB], [ test "x${enable_asio_lib}" = "xyes" ])
831
832 # The example programs depend on OpenSSL and libevent_openssl
833 enable_examples=no
834 if test "x${request_examples}" != "xno" &&
835    test "x${have_openssl}" = "xyes" &&
836    test "x${have_libevent_openssl}" = "xyes"; then
837   enable_examples=yes
838 fi
839
840 if test "x${request_examples}" = "xyes" &&
841    test "x${enable_examples}" != "xyes"; then
842   AC_MSG_ERROR([examples were requested (--enable-examples) but dependencies are not met.])
843 fi
844
845 AM_CONDITIONAL([ENABLE_EXAMPLES], [ test "x${enable_examples}" = "xyes" ])
846
847 # third-party only be built when needed
848
849 enable_third_party=no
850 have_mruby=no
851 have_neverbleed=no
852 if test "x${enable_examples}" = "xyes" ||
853    test "x${enable_app}" = "xyes" ||
854    test "x${enable_hpack_tools}" = "xyes" ||
855    test "x${enable_asio_lib}" = "xyes"; then
856   enable_third_party=yes
857
858   # mruby (for src/nghttpx)
859   if test "x${request_mruby}" = "xyes"; then
860     # We are going to build mruby
861     have_mruby=yes
862     AC_DEFINE([HAVE_MRUBY], [1], [Define to 1 if you have `mruby` library.])
863     LIBMRUBY_LIBS="-lmruby -lm"
864     LIBMRUBY_CFLAGS=
865     AC_SUBST([LIBMRUBY_LIBS])
866     AC_SUBST([LIBMRUBY_CFLAGS])
867   fi
868
869   # neverbleed (for src/nghttpx)
870   if test "x${request_neverbleed}" = "xyes"; then
871     have_neverbleed=yes
872     AC_DEFINE([HAVE_NEVERBLEED], [1], [Define to 1 if you have `neverbleed` library.])
873   fi
874 fi
875
876 AM_CONDITIONAL([ENABLE_THIRD_PARTY], [ test "x${enable_third_party}" = "xyes" ])
877 AM_CONDITIONAL([HAVE_MRUBY], [test "x${have_mruby}" = "xyes"])
878 AM_CONDITIONAL([HAVE_NEVERBLEED], [test "x${have_neverbleed}" = "xyes"])
879
880 # Python bindings
881 enable_python_bindings=no
882 if test "x${request_python_bindings}" != "xno" &&
883    test "x${CYTHON}" != "x" &&
884    test "x${PYTHON}" != "x:" &&
885    test "x${PYTHON_VERSION}" != "x"; then
886   enable_python_bindings=yes
887 fi
888
889 if test "x${request_python_bindings}" = "xyes" &&
890    test "x${enable_python_bindings}" != "xyes"; then
891   AC_MSG_ERROR([python bindings were requested (--enable-python-bindings) but dependencies are not met.])
892 fi
893
894 AM_CONDITIONAL([ENABLE_PYTHON_BINDINGS],
895                [test "x${enable_python_bindings}" = "xyes"])
896
897 # Produce cython conditional, so that we can distribute generated C
898 # source
899 AM_CONDITIONAL([HAVE_CYTHON], [test "x${CYTHON}" != "x"])
900
901 # failmalloc tests
902 enable_failmalloc=no
903 if test "x${request_failmalloc}" = "xyes"; then
904   enable_failmalloc=yes
905 fi
906
907 AM_CONDITIONAL([ENABLE_FAILMALLOC], [ test "x${enable_failmalloc}" = "xyes" ])
908
909 # Checks for header files.
910 AC_HEADER_ASSERT
911 AC_CHECK_HEADERS([ \
912   arpa/inet.h \
913   fcntl.h \
914   inttypes.h \
915   limits.h \
916   netdb.h \
917   netinet/in.h \
918   pwd.h \
919   stddef.h \
920   stdint.h \
921   stdlib.h \
922   string.h \
923   sys/socket.h \
924   sys/time.h \
925   syslog.h \
926   time.h \
927   unistd.h \
928 ])
929
930 # Checks for typedefs, structures, and compiler characteristics.
931 AC_TYPE_SIZE_T
932 AC_TYPE_SSIZE_T
933 AC_TYPE_UINT8_T
934 AC_TYPE_UINT16_T
935 AC_TYPE_UINT32_T
936 AC_TYPE_UINT64_T
937 AC_TYPE_INT8_T
938 AC_TYPE_INT16_T
939 AC_TYPE_INT32_T
940 AC_TYPE_INT64_T
941 AC_TYPE_OFF_T
942 AC_TYPE_PID_T
943 AC_TYPE_UID_T
944 AC_CHECK_TYPES([ptrdiff_t])
945 AC_C_BIGENDIAN
946 AC_C_INLINE
947 AC_SYS_LARGEFILE
948
949 AC_CHECK_MEMBER([struct tm.tm_gmtoff], [have_struct_tm_tm_gmtoff=yes],
950                 [have_struct_tm_tm_gmtoff=no], [[#include <time.h>]])
951
952 AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
953                 [AC_DEFINE([HAVE_SOCKADDR_IN_SIN_LEN],[1],
954                   [Define to 1 if struct sockaddr_in has sin_len member.])],
955                 [],
956                 [[
957 #include <sys/types.h>
958 #include <sys/socket.h>
959 #include <netinet/in.h>
960 ]])
961
962 AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len],
963                 [AC_DEFINE([HAVE_SOCKADDR_IN6_SIN6_LEN],[1],
964                   [Define to 1 if struct sockaddr_in6 has sin6_len member.])],
965                 [],
966                 [[
967 #include <sys/types.h>
968 #include <sys/socket.h>
969 #include <netinet/in.h>
970 ]])
971
972 if test "x$have_struct_tm_tm_gmtoff" = "xyes"; then
973   AC_DEFINE([HAVE_STRUCT_TM_TM_GMTOFF], [1],
974             [Define to 1 if you have `struct tm.tm_gmtoff` member.])
975 fi
976
977 # Check size of pointer to decide we need 8 bytes alignment
978 # adjustment.
979 AC_CHECK_SIZEOF([int *])
980
981 AC_CHECK_SIZEOF([time_t])
982
983 # Checks for library functions.
984
985 # Don't check malloc, since it does not play nicely with C++ stdlib
986 # AC_FUNC_MALLOC
987
988 AC_FUNC_CHOWN
989 AC_FUNC_ERROR_AT_LINE
990 AC_FUNC_FORK
991 # Don't check realloc, since LeakSanitizer detects memory leak during check
992 # AC_FUNC_REALLOC
993 AC_FUNC_STRERROR_R
994 AC_FUNC_STRNLEN
995
996 AC_CHECK_FUNCS([ \
997   _Exit \
998   accept4 \
999   dup2 \
1000   getcwd \
1001   getpwnam \
1002   localtime_r \
1003   memchr \
1004   memmove \
1005   memset \
1006   mkostemp \
1007   socket \
1008   sqrt \
1009   strchr \
1010   strdup \
1011   strerror \
1012   strndup \
1013   strstr \
1014   strtol \
1015   strtoul \
1016   timegm \
1017 ])
1018
1019 # timerfd_create was added in linux kernel 2.6.25
1020
1021 AC_CHECK_FUNC([timerfd_create],
1022               [have_timerfd_create=yes], [have_timerfd_create=no])
1023
1024 # For cygwin: we can link initgroups, so AC_CHECK_FUNCS succeeds, but
1025 # cygwin disables initgroups due to feature test macro magic with our
1026 # configuration.  FreeBSD declares initgroups() in unistd.h.
1027 AC_CHECK_DECLS([initgroups], [], [], [[
1028   #ifdef HAVE_UNISTD_H
1029   # include <unistd.h>
1030   #endif
1031   #include <grp.h>
1032 ]])
1033
1034 save_CFLAGS=$CFLAGS
1035 save_CXXFLAGS=$CXXFLAGS
1036
1037 CFLAGS=
1038 CXXFLAGS=
1039
1040 if test "x$werror" != "xno"; then
1041     # For C compiler
1042     AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"])
1043     AX_CHECK_COMPILE_FLAG([-Wextra], [CFLAGS="$CFLAGS -Wextra"])
1044     AX_CHECK_COMPILE_FLAG([-Werror], [CFLAGS="$CFLAGS -Werror"])
1045     AX_CHECK_COMPILE_FLAG([-Wmissing-prototypes], [CFLAGS="$CFLAGS -Wmissing-prototypes"])
1046     AX_CHECK_COMPILE_FLAG([-Wstrict-prototypes], [CFLAGS="$CFLAGS -Wstrict-prototypes"])
1047     AX_CHECK_COMPILE_FLAG([-Wmissing-declarations], [CFLAGS="$CFLAGS -Wmissing-declarations"])
1048     AX_CHECK_COMPILE_FLAG([-Wpointer-arith], [CFLAGS="$CFLAGS -Wpointer-arith"])
1049     AX_CHECK_COMPILE_FLAG([-Wdeclaration-after-statement], [CFLAGS="$CFLAGS -Wdeclaration-after-statement"])
1050     AX_CHECK_COMPILE_FLAG([-Wformat-security], [CFLAGS="$CFLAGS -Wformat-security"])
1051     AX_CHECK_COMPILE_FLAG([-Wwrite-strings], [CFLAGS="$CFLAGS -Wwrite-strings"])
1052     AX_CHECK_COMPILE_FLAG([-Wshadow], [CFLAGS="$CFLAGS -Wshadow"])
1053     AX_CHECK_COMPILE_FLAG([-Winline], [CFLAGS="$CFLAGS -Winline"])
1054     AX_CHECK_COMPILE_FLAG([-Wnested-externs], [CFLAGS="$CFLAGS -Wnested-externs"])
1055     AX_CHECK_COMPILE_FLAG([-Wfloat-equal], [CFLAGS="$CFLAGS -Wfloat-equal"])
1056     AX_CHECK_COMPILE_FLAG([-Wundef], [CFLAGS="$CFLAGS -Wundef"])
1057     AX_CHECK_COMPILE_FLAG([-Wendif-labels], [CFLAGS="$CFLAGS -Wendif-labels"])
1058     AX_CHECK_COMPILE_FLAG([-Wempty-body], [CFLAGS="$CFLAGS -Wempty-body"])
1059     AX_CHECK_COMPILE_FLAG([-Wcast-align], [CFLAGS="$CFLAGS -Wcast-align"])
1060     AX_CHECK_COMPILE_FLAG([-Wclobbered], [CFLAGS="$CFLAGS -Wclobbered"])
1061     AX_CHECK_COMPILE_FLAG([-Wvla], [CFLAGS="$CFLAGS -Wvla"])
1062     AX_CHECK_COMPILE_FLAG([-Wpragmas], [CFLAGS="$CFLAGS -Wpragmas"])
1063     AX_CHECK_COMPILE_FLAG([-Wunreachable-code], [CFLAGS="$CFLAGS -Wunreachable-code"])
1064     AX_CHECK_COMPILE_FLAG([-Waddress], [CFLAGS="$CFLAGS -Waddress"])
1065     AX_CHECK_COMPILE_FLAG([-Wattributes], [CFLAGS="$CFLAGS -Wattributes"])
1066     AX_CHECK_COMPILE_FLAG([-Wdiv-by-zero], [CFLAGS="$CFLAGS -Wdiv-by-zero"])
1067     AX_CHECK_COMPILE_FLAG([-Wshorten-64-to-32], [CFLAGS="$CFLAGS -Wshorten-64-to-32"])
1068
1069     AX_CHECK_COMPILE_FLAG([-Wconversion], [CFLAGS="$CFLAGS -Wconversion"])
1070     AX_CHECK_COMPILE_FLAG([-Wextended-offsetof], [CFLAGS="$CFLAGS -Wextended-offsetof"])
1071     AX_CHECK_COMPILE_FLAG([-Wformat-nonliteral], [CFLAGS="$CFLAGS -Wformat-nonliteral"])
1072     AX_CHECK_COMPILE_FLAG([-Wlanguage-extension-token], [CFLAGS="$CFLAGS -Wlanguage-extension-token"])
1073     AX_CHECK_COMPILE_FLAG([-Wmissing-field-initializers], [CFLAGS="$CFLAGS -Wmissing-field-initializers"])
1074     AX_CHECK_COMPILE_FLAG([-Wmissing-noreturn], [CFLAGS="$CFLAGS -Wmissing-noreturn"])
1075     AX_CHECK_COMPILE_FLAG([-Wmissing-variable-declarations], [CFLAGS="$CFLAGS -Wmissing-variable-declarations"])
1076     # Not used because we cannot change public structs
1077     # AX_CHECK_COMPILE_FLAG([-Wpadded], [CFLAGS="$CFLAGS -Wpadded"])
1078     AX_CHECK_COMPILE_FLAG([-Wsign-conversion], [CFLAGS="$CFLAGS -Wsign-conversion"])
1079     # Not used because this basically disallows default case
1080     # AX_CHECK_COMPILE_FLAG([-Wswitch-enum], [CFLAGS="$CFLAGS -Wswitch-enum"])
1081     AX_CHECK_COMPILE_FLAG([-Wunreachable-code-break], [CFLAGS="$CFLAGS -Wunreachable-code-break"])
1082     AX_CHECK_COMPILE_FLAG([-Wunused-macros], [CFLAGS="$CFLAGS -Wunused-macros"])
1083     AX_CHECK_COMPILE_FLAG([-Wunused-parameter], [CFLAGS="$CFLAGS -Wunused-parameter"])
1084     AX_CHECK_COMPILE_FLAG([-Wredundant-decls], [CFLAGS="$CFLAGS -Wredundant-decls"])
1085     # Only work with Clang for the moment
1086     AX_CHECK_COMPILE_FLAG([-Wheader-guard], [CFLAGS="$CFLAGS -Wheader-guard"])
1087     AX_CHECK_COMPILE_FLAG([-Wsometimes-uninitialized], [CFLAGS="$CFLAGS -Wsometimes-uninitialized"])
1088
1089     # This is required because we pass format string as "const char*.
1090     AX_CHECK_COMPILE_FLAG([-Wno-format-nonliteral], [CFLAGS="$CFLAGS -Wno-format-nonliteral"])
1091
1092     # For C++ compiler
1093     AC_LANG_PUSH(C++)
1094     AX_CHECK_COMPILE_FLAG([-Wall], [CXXFLAGS="$CXXFLAGS -Wall"])
1095     AX_CHECK_COMPILE_FLAG([-Werror], [CXXFLAGS="$CXXFLAGS -Werror"])
1096     AX_CHECK_COMPILE_FLAG([-Wformat-security], [CXXFLAGS="$CXXFLAGS -Wformat-security"])
1097     AX_CHECK_COMPILE_FLAG([-Wsometimes-uninitialized], [CXXFLAGS="$CXXFLAGS -Wsometimes-uninitialized"])
1098     # Disable noexcept-type warning of g++-7.  This is not harmful as
1099     # long as all source files are compiled with the same compiler.
1100     AX_CHECK_COMPILE_FLAG([-Wno-noexcept-type], [CXXFLAGS="$CXXFLAGS -Wno-noexcept-type"])
1101     AC_LANG_POP()
1102 fi
1103
1104 WARNCFLAGS=$CFLAGS
1105 WARNCXXFLAGS=$CXXFLAGS
1106
1107 CFLAGS=$save_CFLAGS
1108 CXXFLAGS=$save_CXXFLAGS
1109
1110 AC_SUBST([WARNCFLAGS])
1111 AC_SUBST([WARNCXXFLAGS])
1112
1113 EXTRACFLAG=
1114 AX_CHECK_COMPILE_FLAG([-fvisibility=hidden], [EXTRACFLAG="-fvisibility=hidden"])
1115
1116 AC_SUBST([EXTRACFLAG])
1117
1118 if test "x$debug" != "xno"; then
1119     AC_DEFINE([DEBUGBUILD], [1], [Define to 1 to enable debug output.])
1120 fi
1121
1122 enable_threads=yes
1123 # Some platform does not have working std::future.  We disable
1124 # threading for those platforms.
1125 if test "x$threads" != "xyes" ||
1126    test "x$have_std_future" != "xyes"; then
1127     enable_threads=no
1128     AC_DEFINE([NOTHREADS], [1], [Define to 1 if you want to disable threads.])
1129 fi
1130
1131 # propagate $enable_static to tests/Makefile.am
1132 AM_CONDITIONAL([ENABLE_STATIC], [test "x$enable_static" = "xyes"])
1133
1134 AC_SUBST([TESTLDADD])
1135 AC_SUBST([APPLDFLAGS])
1136
1137 AC_CONFIG_FILES([
1138   Makefile
1139   lib/Makefile
1140   lib/libnghttp2.pc
1141   lib/includes/Makefile
1142   lib/includes/nghttp2/nghttp2ver.h
1143   tests/Makefile
1144   tests/testdata/Makefile
1145   third-party/Makefile
1146   src/Makefile
1147   src/includes/Makefile
1148   src/libnghttp2_asio.pc
1149   bpf/Makefile
1150   examples/Makefile
1151   python/Makefile
1152   python/setup.py
1153   integration-tests/Makefile
1154   integration-tests/config.go
1155   integration-tests/setenv
1156   doc/Makefile
1157   doc/conf.py
1158   doc/index.rst
1159   doc/package_README.rst
1160   doc/tutorial-client.rst
1161   doc/tutorial-server.rst
1162   doc/tutorial-hpack.rst
1163   doc/nghttpx-howto.rst
1164   doc/h2load-howto.rst
1165   doc/libnghttp2_asio.rst
1166   doc/python-apiref.rst
1167   doc/building-android-binary.rst
1168   doc/nghttp2.h.rst
1169   doc/nghttp2ver.h.rst
1170   doc/asio_http2.h.rst
1171   doc/asio_http2_server.h.rst
1172   doc/asio_http2_client.h.rst
1173   doc/contribute.rst
1174   contrib/Makefile
1175   script/Makefile
1176 ])
1177 AC_OUTPUT
1178
1179 AC_MSG_NOTICE([summary of build options:
1180
1181     Package version: ${VERSION}
1182     Library version: $LT_CURRENT:$LT_REVISION:$LT_AGE
1183     Install prefix:  ${prefix}
1184     System types:
1185       Build:         ${build}
1186       Host:          ${host}
1187       Target:        ${target}
1188     Compiler:
1189       C compiler:     ${CC}
1190       CFLAGS:         ${CFLAGS}
1191       LDFLAGS:        ${LDFLAGS}
1192       C++ compiler:   ${CXX}
1193       CXXFLAGS:       ${CXXFLAGS}
1194       CXXCPP:         ${CXXCPP}
1195       C preprocessor: ${CPP}
1196       CPPFLAGS:       ${CPPFLAGS}
1197       WARNCFLAGS:     ${WARNCFLAGS}
1198       WARNCXXFLAGS:   ${WARNCXXFLAGS}
1199       CXX1XCXXFLAGS:  ${CXX1XCXXFLAGS}
1200       EXTRACFLAG:     ${EXTRACFLAG}
1201       BPFCFLAGS:      ${BPFCFLAGS}
1202       EXTRABPFCFLAGS: ${EXTRABPFCFLAGS}
1203       LIBS:           ${LIBS}
1204       DEFS:           ${DEFS}
1205       EXTRA_DEFS:     ${EXTRA_DEFS}
1206     Library:
1207       Shared:         ${enable_shared}
1208       Static:         ${enable_static}
1209     Libtool:
1210       LIBTOOL_LDFLAGS: ${LIBTOOL_LDFLAGS}
1211     Python:
1212       Python:         ${PYTHON}
1213       PYTHON_VERSION: ${PYTHON_VERSION}
1214       pyexecdir:      ${pyexecdir}
1215       PYTHON_CPPFLAGS:${PYTHON_CPPFLAGS}
1216       PYTHON_LIBS:    ${PYTHON_LIBS}
1217       Cython:         ${CYTHON}
1218     Test:
1219       CUnit:          ${have_cunit} (CFLAGS='${CUNIT_CFLAGS}' LIBS='${CUNIT_LIBS}')
1220       Failmalloc:     ${enable_failmalloc}
1221     Libs:
1222       OpenSSL:        ${have_openssl} (CFLAGS='${OPENSSL_CFLAGS}' LIBS='${OPENSSL_LIBS}')
1223       Libxml2:        ${have_libxml2} (CFLAGS='${LIBXML2_CFLAGS}' LIBS='${LIBXML2_LIBS}')
1224       Libev:          ${have_libev} (CFLAGS='${LIBEV_CFLAGS}' LIBS='${LIBEV_LIBS}')
1225       Libc-ares:      ${have_libcares} (CFLAGS='${LIBCARES_CFLAGS}' LIBS='${LIBCARES_LIBS}')
1226       libngtcp2:      ${have_libngtcp2} (CFLAGS='${LIBNGTCP2_CFLAGS}' LIBS='${LIBNGTCP2_LIBS}')
1227       libngtcp2_crypto_openssl: ${have_libngtcp2_crypto_openssl} (CFLAGS='${LIBNGTCP2_CRYPTO_OPENSSL_CFLAGS}' LIBS='${LIBNGTCP2_CRYPTO_OPENSSL_LIBS}')
1228       libngtcp2_crypto_boringssl: ${have_libngtcp2_crypto_boringssl} (CFLAGS='${LIBNGTCP2_CRYPTO_BORINGSSL_CFLAGS}' LIBS='${LIBNGTCP2_CRYPTO_BORINGSSL_LIBS}')
1229       libnghttp3:     ${have_libnghttp3} (CFLAGS='${LIBNGHTTP3_CFLAGS}' LIBS='${LIBNGHTTP3_LIBS}')
1230       libbpf:         ${have_libbpf} (CFLAGS='${LIBBPF_CFLAGS}' LIBS='${LIBBPF_LIBS}')
1231       Libevent(SSL):  ${have_libevent_openssl} (CFLAGS='${LIBEVENT_OPENSSL_CFLAGS}' LIBS='${LIBEVENT_OPENSSL_LIBS}')
1232       Jansson:        ${have_jansson} (CFLAGS='${JANSSON_CFLAGS}' LIBS='${JANSSON_LIBS}')
1233       Jemalloc:       ${have_jemalloc} (CFLAGS='${JEMALLOC_CFLAGS}' LIBS='${JEMALLOC_LIBS}')
1234       Zlib:           ${have_zlib} (CFLAGS='${ZLIB_CFLAGS}' LIBS='${ZLIB_LIBS}')
1235       Systemd:        ${have_libsystemd} (CFLAGS='${SYSTEMD_CFLAGS}' LIBS='${SYSTEMD_LIBS}')
1236       Boost CPPFLAGS: ${BOOST_CPPFLAGS}
1237       Boost LDFLAGS:  ${BOOST_LDFLAGS}
1238       Boost::ASIO:    ${BOOST_ASIO_LIB}
1239       Boost::System:  ${BOOST_SYSTEM_LIB}
1240       Boost::Thread:  ${BOOST_THREAD_LIB}
1241     Third-party:
1242       http-parser:    ${enable_third_party}
1243       MRuby:          ${have_mruby} (CFLAGS='${LIBMRUBY_CFLAGS}' LIBS='${LIBMRUBY_LIBS}')
1244       Neverbleed:     ${have_neverbleed}
1245     Features:
1246       Applications:   ${enable_app}
1247       HPACK tools:    ${enable_hpack_tools}
1248       Libnghttp2_asio:${enable_asio_lib}
1249       Examples:       ${enable_examples}
1250       Python bindings:${enable_python_bindings}
1251       Threading:      ${enable_threads}
1252       HTTP/3 (EXPERIMENTAL): ${enable_http3}
1253 ])