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