Migration to openssl 1.1
[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 http://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html
26
27 AC_PREREQ(2.61)
28 AC_INIT([nghttp2], [1.34.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  http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
47 AC_SUBST(LT_CURRENT, 31)
48 AC_SUBST(LT_REVISION, 1)
49 AC_SUBST(LT_AGE, 17)
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_WITH([libxml2],
111     [AS_HELP_STRING([--with-libxml2],
112                     [Use libxml2 [default=check]])],
113     [request_libxml2=$withval], [request_libxml2=check])
114
115 AC_ARG_WITH([jemalloc],
116     [AS_HELP_STRING([--with-jemalloc],
117                     [Use jemalloc [default=check]])],
118     [request_jemalloc=$withval], [request_jemalloc=check])
119
120 AC_ARG_WITH([systemd],
121     [AS_HELP_STRING([--with-systemd],
122                     [Enable systemd support in nghttpx [default=check]])],
123     [request_systemd=$withval], [request_systemd=check])
124
125 AC_ARG_WITH([mruby],
126     [AS_HELP_STRING([--with-mruby],
127                     [Use mruby [default=no]])],
128     [request_mruby=$withval], [request_mruby=no])
129
130 AC_ARG_WITH([neverbleed],
131     [AS_HELP_STRING([--with-neverbleed],
132                     [Use neverbleed [default=no]])],
133     [request_neverbleed=$withval], [request_neverbleed=no])
134
135 AC_ARG_WITH([cython],
136     [AS_HELP_STRING([--with-cython=PATH],
137                     [Use cython in given PATH])],
138     [cython_path=$withval], [])
139
140 dnl Define variables
141 AC_ARG_VAR([CYTHON], [the Cython executable])
142
143 dnl Checks for programs
144 AC_PROG_CC
145 AC_PROG_CXX
146 AC_PROG_CPP
147 AC_PROG_INSTALL
148 AC_PROG_LN_S
149 AC_PROG_MAKE_SET
150 AC_PROG_MKDIR_P
151
152 PKG_PROG_PKG_CONFIG([0.20])
153
154 AM_PATH_PYTHON([2.7],, [:])
155
156 if [test "x$request_lib_only" = "xyes"]; then
157   request_app=no
158   request_hpack_tools=no
159   request_examples=no
160   request_python_bindings=no
161 fi
162
163 if [test "x$request_python_bindings" != "xno"]; then
164   AX_PYTHON_DEVEL([>= '2.7'])
165 fi
166
167 if test "x${cython_path}" = "x"; then
168   AC_CHECK_PROGS([CYTHON], [cython.py cython])
169 else
170   CYTHON=${cython_path}
171   AC_SUBST([CYTHON])
172 fi
173
174 if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
175   AC_DEFINE([NGHTTP2_NORETURN], [__attribute__((noreturn))], [Hint to the compiler that a function never return])
176 else
177   AC_DEFINE([NGHTTP2_NORETURN], , [Hint to the compiler that a function never return])
178 fi
179
180 save_CXXFLAGS="$CXXFLAGS"
181 CXXFLAGS=
182
183 AX_CXX_COMPILE_STDCXX_11([noext], [optional])
184
185 CXX1XCXXFLAGS="$CXXFLAGS"
186 CXXFLAGS="$save_CXXFLAGS"
187 AC_SUBST([CXX1XCXXFLAGS])
188
189 AC_LANG_PUSH(C++)
190
191 save_CXXFLAGS="$CXXFLAGS"
192 CXXFLAGS="$CXXFLAGS $CXX1XCXXFLAGS"
193
194 # Check that std::future is available.
195 AC_MSG_CHECKING([whether std::future is available])
196 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
197 [[
198 #include <vector>
199 #include <future>
200 ]],
201 [[
202 std::vector<std::future<int>> v;
203 ]])],
204     [AC_DEFINE([HAVE_STD_FUTURE], [1],
205                [Define to 1 if you have the `std::future`.])
206      have_std_future=yes
207      AC_MSG_RESULT([yes])],
208     [have_std_future=no
209      AC_MSG_RESULT([no])])
210
211 # Check that std::map::emplace is available for g++-4.7.
212 AC_MSG_CHECKING([whether std::map::emplace is available])
213 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
214 [[
215 #include <map>
216 ]],
217 [[
218 std::map<int, int>().emplace(1, 2);
219 ]])],
220     [AC_DEFINE([HAVE_STD_MAP_EMPLACE], [1],
221                [Define to 1 if you have the `std::map::emplace`.])
222      have_std_map_emplace=yes
223      AC_MSG_RESULT([yes])],
224     [have_std_map_emplace=no
225      AC_MSG_RESULT([no])])
226
227 # Check that std::atomic_* overloads for std::shared_ptr are
228 # available.
229 AC_MSG_CHECKING([whether std::atomic_* overloads for std::shared_ptr are available])
230 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
231 [[
232 #include <memory>
233 ]],
234 [[
235 auto a = std::make_shared<int>(1000000007);
236 auto p = std::atomic_load(&a);
237 ++*p;
238 std::atomic_store(&a, p);
239 ]])],
240     [AC_DEFINE([HAVE_ATOMIC_STD_SHARED_PTR], [1],
241                [Define to 1 if you have the std::atomic_* overloads for std::shared_ptr.])
242      have_atomic_std_shared_ptr=yes
243      AC_MSG_RESULT([yes])],
244     [have_atomic_std_shared_ptr=no
245      AC_MSG_RESULT([no])])
246
247 # Check that thread_local storage specifier is available
248 AC_MSG_CHECKING([whether thread_local storage class specifier is available.])
249 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
250 ,
251 [[
252 thread_local int a = 0;
253 (void)a;
254 ]])],
255     [AC_DEFINE([HAVE_THREAD_LOCAL], [1],
256                [Define to 1 if you have thread_local storage specifier.])
257      have_thread_local=yes
258      AC_MSG_RESULT([yes])],
259     [have_Thread_local=no
260      AC_MSG_RESULT([no])])
261
262 CXXFLAGS=$save_CXXFLAGS
263
264 AC_LANG_POP()
265
266 # Checks for libraries.
267
268 # Additional libraries required for tests.
269 TESTLDADD=
270
271 # Additional libraries required for programs under src directory.
272 APPLDFLAGS=
273
274 case "$host_os" in
275   *android*)
276     android_build=yes
277     # android does not need -pthread, but needs followng 3 libs for C++
278     APPLDFLAGS="$APPLDFLAGS -lstdc++ -latomic -lsupc++"
279     ;;
280   *)
281     PTHREAD_LDFLAGS="-pthread"
282     APPLDFLAGS="$APPLDFLAGS $PTHREAD_LDFLAGS"
283     ;;
284 esac
285
286 case "$host_os" in
287   *solaris*)
288     APPLDFLAGS="$APPLDFLAGS -lsocket -lnsl"
289     ;;
290 esac
291
292 # zlib
293 PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.3], [have_zlib=yes], [have_zlib=no])
294
295 if test "x${have_zlib}" = "xno"; then
296   AC_MSG_NOTICE($ZLIB_PKG_ERRORS)
297 fi
298
299 # dl: openssl requires libdl when it is statically linked.
300 case "${host_os}" in
301   *bsd*)
302     # dlopen is in libc on *BSD
303     ;;
304   *)
305     save_LIBS=$LIBS
306     AC_SEARCH_LIBS([dlopen], [dl], [APPLDFLAGS="-ldl $APPLDFLAGS"], [], [])
307     LIBS=$save_LIBS
308     ;;
309 esac
310
311 # cunit
312 PKG_CHECK_MODULES([CUNIT], [cunit >= 2.1], [have_cunit=yes], [have_cunit=no])
313 # If pkg-config does not find cunit, check it using AC_CHECK_LIB.  We
314 # do this because Debian (Ubuntu) lacks pkg-config file for cunit.
315 if test "x${have_cunit}" = "xno"; then
316   AC_MSG_WARN([${CUNIT_PKG_ERRORS}])
317   AC_CHECK_LIB([cunit], [CU_initialize_registry],
318                [have_cunit=yes], [have_cunit=no])
319   if test "x${have_cunit}" = "xyes"; then
320     CUNIT_LIBS="-lcunit"
321     CUNIT_CFLAGS=""
322     AC_SUBST([CUNIT_LIBS])
323     AC_SUBST([CUNIT_CFLAGS])
324   fi
325 fi
326 if test "x${have_cunit}" = "xyes"; then
327   # cunit in Mac OS X requires ncurses. Note that in Mac OS X, test
328   # program can be built without -lncurses, but it emits runtime
329   # error.
330   case "${build}" in
331     *-apple-darwin*)
332       CUNIT_LIBS="$CUNIT_LIBS -lncurses"
333       AC_SUBST([CUNIT_LIBS])
334       ;;
335   esac
336 fi
337
338 AM_CONDITIONAL([HAVE_CUNIT], [ test "x${have_cunit}" = "xyes" ])
339
340 # libev (for src)
341 # libev does not have pkg-config file.  Check it in an old way.
342 save_LIBS=$LIBS
343 # android requires -lm for floor
344 AC_CHECK_LIB([ev], [ev_time], [have_libev=yes], [have_libev=no], [-lm])
345 if test "x${have_libev}" = "xyes"; then
346   AC_CHECK_HEADER([ev.h], [have_libev=yes], [have_libev=no])
347   if test "x${have_libev}" = "xyes"; then
348     LIBEV_LIBS=-lev
349     LIBEV_CFLAGS=
350     AC_SUBST([LIBEV_LIBS])
351     AC_SUBST([LIBEV_CFLAGS])
352   fi
353 fi
354 LIBS=$save_LIBS
355
356 # openssl (for src)
357 PKG_CHECK_MODULES([OPENSSL], [openssl1.1 >= 1.0.1],
358                   [have_openssl=yes], [have_openssl=no])
359 if test "x${have_openssl}" = "xno"; then
360   AC_MSG_NOTICE($OPENSSL_PKG_ERRORS)
361 fi
362
363 # c-ares (for src)
364 PKG_CHECK_MODULES([LIBCARES], [libcares >= 1.7.5], [have_libcares=yes],
365                   [have_libcares=no])
366 if test "x${have_libcares}" = "xno"; then
367   AC_MSG_NOTICE($LIBCARES_PKG_ERRORS)
368 fi
369
370 # libevent_openssl (for examples)
371 # 2.0.8 is required because we use evconnlistener_set_error_cb()
372 PKG_CHECK_MODULES([LIBEVENT_OPENSSL], [libevent_openssl >= 2.0.8],
373                   [have_libevent_openssl=yes], [have_libevent_openssl=no])
374 if test "x${have_libevent_openssl}" = "xno"; then
375   AC_MSG_NOTICE($LIBEVENT_OPENSSL_PKG_ERRORS)
376 fi
377
378 # jansson (for src/nghttp, src/deflatehd and src/inflatehd)
379 PKG_CHECK_MODULES([JANSSON], [jansson >= 2.5],
380                   [have_jansson=yes], [have_jansson=no])
381 if test "x${have_jansson}" = "xyes"; then
382   AC_DEFINE([HAVE_JANSSON], [1],
383             [Define to 1 if you have `libjansson` library.])
384 else
385   AC_MSG_NOTICE($JANSSON_PKG_ERRORS)
386 fi
387
388
389 #  libsystemd (for src/nghttpx)
390 have_libsystemd=no
391 if test "x${request_systemd}" != "xno"; then
392   PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 209], [have_libsystemd=yes],
393                     [have_libsystemd=no])
394   if test "x${have_libsystemd}" = "xyes"; then
395     AC_DEFINE([HAVE_LIBSYSTEMD], [1],
396               [Define to 1 if you have `libsystemd` library.])
397   else
398     AC_MSG_NOTICE($SYSTEMD_PKG_ERRORS)
399   fi
400 fi
401
402 if test "x${request_systemd}" = "xyes" &&
403    test "x${have_libsystemd}" != "xyes"; then
404   AC_MSG_ERROR([systemd was requested (--with-systemd) but not found])
405 fi
406
407 # libxml2 (for src/nghttp)
408 PKG_CHECK_MODULES([LIBXML2], [libxml-2.0 >= 2.6.26],
409                   [have_libxml2=yes], [have_libxml2=no])
410 if test "x${have_libxml2}" = "xyes"; then
411   AC_DEFINE([HAVE_LIBXML2], [1], [Define to 1 if you have `libxml2` library.])
412 else
413   AC_MSG_NOTICE($LIBXML2_PKG_ERRORS)
414 fi
415
416 if test "x${request_libxml2}" = "xyes" &&
417    test "x${have_libxml2}" != "xyes"; then
418   AC_MSG_ERROR([libxml2 was requested (--with-libxml2) but not found])
419 fi
420
421 AM_CONDITIONAL([HAVE_LIBXML2], [ test "x${have_libxml2}" = "xyes" ])
422
423 # jemalloc
424 have_jemalloc=no
425 if test "x${request_jemalloc}" != "xno"; then
426   save_LIBS=$LIBS
427   AC_SEARCH_LIBS([malloc_stats_print], [jemalloc], [have_jemalloc=yes], [],
428                  [$PTHREAD_LDFLAGS])
429
430   if test "x${have_jemalloc}" = "xyes"; then
431     jemalloc_libs=${ac_cv_search_malloc_stats_print}
432   else
433     # On Darwin, malloc_stats_print is je_malloc_stats_print
434     AC_SEARCH_LIBS([je_malloc_stats_print], [jemalloc], [have_jemalloc=yes], [],
435                    [$PTHREAD_LDFLAGS])
436
437     if test "x${have_jemalloc}" = "xyes"; then
438       jemalloc_libs=${ac_cv_search_je_malloc_stats_print}
439     fi
440   fi
441
442   LIBS=$save_LIBS
443
444   if test "x${have_jemalloc}" = "xyes" &&
445      test "x${jemalloc_libs}" != "xnone required"; then
446     JEMALLOC_LIBS=${jemalloc_libs}
447     AC_SUBST([JEMALLOC_LIBS])
448   fi
449 fi
450
451 if test "x${request_jemalloc}" = "xyes" &&
452    test "x${have_jemalloc}" != "xyes"; then
453   AC_MSG_ERROR([jemalloc was requested (--with-jemalloc) but not found])
454 fi
455
456 # Check Boost Asio library
457 have_asio_lib=no
458
459 if test "x${request_asio_lib}" = "xyes"; then
460   AX_BOOST_BASE([1.54.0], [have_boost_base=yes], [have_boost_base=no])
461
462   if test "x${have_boost_base}" = "xyes"; then
463     AX_BOOST_ASIO()
464     AX_BOOST_SYSTEM()
465     AX_BOOST_THREAD()
466
467     if test "x${ax_cv_boost_asio}" = "xyes" &&
468        test "x${ax_cv_boost_system}" = "xyes" &&
469        test "x${ax_cv_boost_thread}" = "xyes"; then
470       have_asio_lib=yes
471     fi
472   fi
473 fi
474
475 # The nghttp, nghttpd and nghttpx under src depend on zlib, OpenSSL,
476 # libev, and libc-ares.
477 enable_app=no
478 if test "x${request_app}" != "xno" &&
479    test "x${have_zlib}" = "xyes" &&
480    test "x${have_openssl}" = "xyes" &&
481    test "x${have_libev}" = "xyes" &&
482    test "x${have_libcares}" = "xyes"; then
483   enable_app=yes
484 fi
485
486 if test "x${request_app}" = "xyes" &&
487    test "x${enable_app}" != "xyes"; then
488   AC_MSG_ERROR([applications were requested (--enable-app) but dependencies are not met.])
489 fi
490
491 AM_CONDITIONAL([ENABLE_APP], [ test "x${enable_app}" = "xyes" ])
492
493 enable_hpack_tools=no
494 # HPACK tools requires jansson
495 if test "x${request_hpack_tools}" != "xno" &&
496    test "x${have_jansson}" = "xyes"; then
497   enable_hpack_tools=yes
498 fi
499
500 if test "x${request_hpack_tools}" = "xyes" &&
501    test "x${enable_hpack_tools}" != "xyes"; then
502   AC_MSG_ERROR([HPACK tools were requested (--enable-hpack-tools) but dependencies are not met.])
503 fi
504
505 AM_CONDITIONAL([ENABLE_HPACK_TOOLS], [ test "x${enable_hpack_tools}" = "xyes" ])
506
507 # C++ library libnghttp2_asio
508
509 enable_asio_lib=no
510 if test "x${request_asio_lib}" != "xno" &&
511    test "x${have_asio_lib}" = "xyes"; then
512   enable_asio_lib=yes
513 fi
514
515 AM_CONDITIONAL([ENABLE_ASIO_LIB], [ test "x${enable_asio_lib}" = "xyes" ])
516
517 # The example programs depend on OpenSSL and libevent_openssl
518 enable_examples=no
519 if test "x${request_examples}" != "xno" &&
520    test "x${have_openssl}" = "xyes" &&
521    test "x${have_libevent_openssl}" = "xyes"; then
522   enable_examples=yes
523 fi
524
525 if test "x${request_examples}" = "xyes" &&
526    test "x${enable_examples}" != "xyes"; then
527   AC_MSG_ERROR([examples were requested (--enable-examples) but dependencies are not met.])
528 fi
529
530 AM_CONDITIONAL([ENABLE_EXAMPLES], [ test "x${enable_examples}" = "xyes" ])
531
532 # third-party only be built when needed
533
534 enable_third_party=no
535 have_mruby=no
536 have_neverbleed=no
537 if test "x${enable_examples}" = "xyes" ||
538    test "x${enable_app}" = "xyes" ||
539    test "x${enable_hpack_tools}" = "xyes" ||
540    test "x${enable_asio_lib}" = "xyes"; then
541   enable_third_party=yes
542
543   # mruby (for src/nghttpx)
544   if test "x${request_mruby}" = "xyes"; then
545     # We are going to build mruby
546     have_mruby=yes
547     AC_DEFINE([HAVE_MRUBY], [1], [Define to 1 if you have `mruby` library.])
548     LIBMRUBY_LIBS="-lmruby -lm"
549     LIBMRUBY_CFLAGS=
550     AC_SUBST([LIBMRUBY_LIBS])
551     AC_SUBST([LIBMRUBY_CFLAGS])
552   fi
553
554   # neverbleed (for src/nghttpx)
555   if test "x${request_neverbleed}" = "xyes"; then
556     have_neverbleed=yes
557     AC_DEFINE([HAVE_NEVERBLEED], [1], [Define to 1 if you have `neverbleed` library.])
558   fi
559 fi
560
561 AM_CONDITIONAL([ENABLE_THIRD_PARTY], [ test "x${enable_third_party}" = "xyes" ])
562 AM_CONDITIONAL([HAVE_MRUBY], [test "x${have_mruby}" = "xyes"])
563 AM_CONDITIONAL([HAVE_NEVERBLEED], [test "x${have_neverbleed}" = "xyes"])
564
565 # Python bindings
566 enable_python_bindings=no
567 if test "x${request_python_bindings}" != "xno" &&
568    test "x${CYTHON}" != "x" &&
569    test "x${PYTHON}" != "x:" &&
570    test "x${have_python_dev}" = "xyes"; then
571   enable_python_bindings=yes
572 fi
573
574 if test "x${request_python_bindings}" = "xyes" &&
575    test "x${enable_python_bindings}" != "xyes"; then
576   AC_MSG_ERROR([python bindings were requested (--enable-python-bindings) but dependencies are not met.])
577 fi
578
579 AM_CONDITIONAL([ENABLE_PYTHON_BINDINGS],
580                [test "x${enable_python_bindings}" = "xyes"])
581
582 # Produce cython conditional, so that we can distribute generated C
583 # source
584 AM_CONDITIONAL([HAVE_CYTHON], [test "x${CYTHON}" != "x"])
585
586 # failmalloc tests
587 enable_failmalloc=no
588 if test "x${request_failmalloc}" = "xyes"; then
589   enable_failmalloc=yes
590 fi
591
592 AM_CONDITIONAL([ENABLE_FAILMALLOC], [ test "x${enable_failmalloc}" = "xyes" ])
593
594 # Checks for header files.
595 AC_HEADER_ASSERT
596 AC_CHECK_HEADERS([ \
597   arpa/inet.h \
598   fcntl.h \
599   inttypes.h \
600   limits.h \
601   netdb.h \
602   netinet/in.h \
603   pwd.h \
604   stddef.h \
605   stdint.h \
606   stdlib.h \
607   string.h \
608   sys/socket.h \
609   sys/time.h \
610   syslog.h \
611   time.h \
612   unistd.h \
613 ])
614
615 # Checks for typedefs, structures, and compiler characteristics.
616 AC_TYPE_SIZE_T
617 AC_TYPE_SSIZE_T
618 AC_TYPE_UINT8_T
619 AC_TYPE_UINT16_T
620 AC_TYPE_UINT32_T
621 AC_TYPE_UINT64_T
622 AC_TYPE_INT8_T
623 AC_TYPE_INT16_T
624 AC_TYPE_INT32_T
625 AC_TYPE_INT64_T
626 AC_TYPE_OFF_T
627 AC_TYPE_PID_T
628 AC_TYPE_UID_T
629 AC_CHECK_TYPES([ptrdiff_t])
630 AC_C_BIGENDIAN
631 AC_C_INLINE
632 AC_SYS_LARGEFILE
633
634 AC_CHECK_MEMBER([struct tm.tm_gmtoff], [have_struct_tm_tm_gmtoff=yes],
635                 [have_struct_tm_tm_gmtoff=no], [[#include <time.h>]])
636
637 AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
638                 [AC_DEFINE([HAVE_SOCKADDR_IN_SIN_LEN],[1],
639                   [Define to 1 if struct sockaddr_in has sin_len member.])],
640                 [],
641                 [[
642 #include <sys/types.h>
643 #include <sys/socket.h>
644 #include <netinet/in.h>
645 ]])
646
647 AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len],
648                 [AC_DEFINE([HAVE_SOCKADDR_IN6_SIN6_LEN],[1],
649                   [Define to 1 if struct sockaddr_in6 has sin6_len member.])],
650                 [],
651                 [[
652 #include <sys/types.h>
653 #include <sys/socket.h>
654 #include <netinet/in.h>
655 ]])
656
657 if test "x$have_struct_tm_tm_gmtoff" = "xyes"; then
658   AC_DEFINE([HAVE_STRUCT_TM_TM_GMTOFF], [1],
659             [Define to 1 if you have `struct tm.tm_gmtoff` member.])
660 fi
661
662 # Check size of pointer to decide we need 8 bytes alignment
663 # adjustment.
664 AC_CHECK_SIZEOF([int *])
665
666 AC_CHECK_SIZEOF([time_t])
667
668 # Checks for library functions.
669
670 # Don't check malloc, since it does not play nicely with C++ stdlib
671 # AC_FUNC_MALLOC
672
673 AC_FUNC_CHOWN
674 AC_FUNC_ERROR_AT_LINE
675 AC_FUNC_FORK
676 # Don't check realloc, since LeakSanitizer detects memory leak during check
677 # AC_FUNC_REALLOC
678 AC_FUNC_STRERROR_R
679 AC_FUNC_STRNLEN
680
681 AC_CHECK_FUNCS([ \
682   _Exit \
683   accept4 \
684   dup2 \
685   getcwd \
686   getpwnam \
687   localtime_r \
688   memchr \
689   memmove \
690   memset \
691   mkostemp \
692   socket \
693   sqrt \
694   strchr \
695   strdup \
696   strerror \
697   strndup \
698   strstr \
699   strtol \
700   strtoul \
701   timegm \
702 ])
703
704 # timerfd_create was added in linux kernel 2.6.25
705
706 AC_CHECK_FUNC([timerfd_create],
707               [have_timerfd_create=yes], [have_timerfd_create=no])
708
709 # For cygwin: we can link initgroups, so AC_CHECK_FUNCS succeeds, but
710 # cygwin disables initgroups due to feature test macro magic with our
711 # configuration.  FreeBSD declares initgroups() in unistd.h.
712 AC_CHECK_DECLS([initgroups], [], [], [[
713   #ifdef HAVE_UNISTD_H
714   # include <unistd.h>
715   #endif
716   #include <grp.h>
717 ]])
718
719 save_CFLAGS=$CFLAGS
720 save_CXXFLAGS=$CXXFLAGS
721
722 CFLAGS=
723 CXXFLAGS=
724
725 if test "x$werror" != "xno"; then
726     # For C compiler
727     AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"])
728     AX_CHECK_COMPILE_FLAG([-Wextra], [CFLAGS="$CFLAGS -Wextra"])
729     AX_CHECK_COMPILE_FLAG([-Werror], [CFLAGS="$CFLAGS -Werror"])
730     AX_CHECK_COMPILE_FLAG([-Wmissing-prototypes], [CFLAGS="$CFLAGS -Wmissing-prototypes"])
731     AX_CHECK_COMPILE_FLAG([-Wstrict-prototypes], [CFLAGS="$CFLAGS -Wstrict-prototypes"])
732     AX_CHECK_COMPILE_FLAG([-Wmissing-declarations], [CFLAGS="$CFLAGS -Wmissing-declarations"])
733     AX_CHECK_COMPILE_FLAG([-Wpointer-arith], [CFLAGS="$CFLAGS -Wpointer-arith"])
734     AX_CHECK_COMPILE_FLAG([-Wdeclaration-after-statement], [CFLAGS="$CFLAGS -Wdeclaration-after-statement"])
735     AX_CHECK_COMPILE_FLAG([-Wformat-security], [CFLAGS="$CFLAGS -Wformat-security"])
736     AX_CHECK_COMPILE_FLAG([-Wwrite-strings], [CFLAGS="$CFLAGS -Wwrite-strings"])
737     AX_CHECK_COMPILE_FLAG([-Wshadow], [CFLAGS="$CFLAGS -Wshadow"])
738     AX_CHECK_COMPILE_FLAG([-Winline], [CFLAGS="$CFLAGS -Winline"])
739     AX_CHECK_COMPILE_FLAG([-Wnested-externs], [CFLAGS="$CFLAGS -Wnested-externs"])
740     AX_CHECK_COMPILE_FLAG([-Wfloat-equal], [CFLAGS="$CFLAGS -Wfloat-equal"])
741     AX_CHECK_COMPILE_FLAG([-Wundef], [CFLAGS="$CFLAGS -Wundef"])
742     AX_CHECK_COMPILE_FLAG([-Wendif-labels], [CFLAGS="$CFLAGS -Wendif-labels"])
743     AX_CHECK_COMPILE_FLAG([-Wempty-body], [CFLAGS="$CFLAGS -Wempty-body"])
744     AX_CHECK_COMPILE_FLAG([-Wcast-align], [CFLAGS="$CFLAGS -Wcast-align"])
745     AX_CHECK_COMPILE_FLAG([-Wclobbered], [CFLAGS="$CFLAGS -Wclobbered"])
746     AX_CHECK_COMPILE_FLAG([-Wvla], [CFLAGS="$CFLAGS -Wvla"])
747     AX_CHECK_COMPILE_FLAG([-Wpragmas], [CFLAGS="$CFLAGS -Wpragmas"])
748     AX_CHECK_COMPILE_FLAG([-Wunreachable-code], [CFLAGS="$CFLAGS -Wunreachable-code"])
749     AX_CHECK_COMPILE_FLAG([-Waddress], [CFLAGS="$CFLAGS -Waddress"])
750     AX_CHECK_COMPILE_FLAG([-Wattributes], [CFLAGS="$CFLAGS -Wattributes"])
751     AX_CHECK_COMPILE_FLAG([-Wdiv-by-zero], [CFLAGS="$CFLAGS -Wdiv-by-zero"])
752     AX_CHECK_COMPILE_FLAG([-Wshorten-64-to-32], [CFLAGS="$CFLAGS -Wshorten-64-to-32"])
753
754     AX_CHECK_COMPILE_FLAG([-Wconversion], [CFLAGS="$CFLAGS -Wconversion"])
755     AX_CHECK_COMPILE_FLAG([-Wextended-offsetof], [CFLAGS="$CFLAGS -Wextended-offsetof"])
756     AX_CHECK_COMPILE_FLAG([-Wformat-nonliteral], [CFLAGS="$CFLAGS -Wformat-nonliteral"])
757     AX_CHECK_COMPILE_FLAG([-Wlanguage-extension-token], [CFLAGS="$CFLAGS -Wlanguage-extension-token"])
758     AX_CHECK_COMPILE_FLAG([-Wmissing-field-initializers], [CFLAGS="$CFLAGS -Wmissing-field-initializers"])
759     AX_CHECK_COMPILE_FLAG([-Wmissing-noreturn], [CFLAGS="$CFLAGS -Wmissing-noreturn"])
760     AX_CHECK_COMPILE_FLAG([-Wmissing-variable-declarations], [CFLAGS="$CFLAGS -Wmissing-variable-declarations"])
761     # Not used because we cannot change public structs
762     # AX_CHECK_COMPILE_FLAG([-Wpadded], [CFLAGS="$CFLAGS -Wpadded"])
763     AX_CHECK_COMPILE_FLAG([-Wsign-conversion], [CFLAGS="$CFLAGS -Wsign-conversion"])
764     # Not used because this basically disallows default case
765     # AX_CHECK_COMPILE_FLAG([-Wswitch-enum], [CFLAGS="$CFLAGS -Wswitch-enum"])
766     AX_CHECK_COMPILE_FLAG([-Wunreachable-code-break], [CFLAGS="$CFLAGS -Wunreachable-code-break"])
767     AX_CHECK_COMPILE_FLAG([-Wunused-macros], [CFLAGS="$CFLAGS -Wunused-macros"])
768     AX_CHECK_COMPILE_FLAG([-Wunused-parameter], [CFLAGS="$CFLAGS -Wunused-parameter"])
769     AX_CHECK_COMPILE_FLAG([-Wredundant-decls], [CFLAGS="$CFLAGS -Wredundant-decls"])
770     # Only work with Clang for the moment
771     AX_CHECK_COMPILE_FLAG([-Wheader-guard], [CFLAGS="$CFLAGS -Wheader-guard"])
772     AX_CHECK_COMPILE_FLAG([-Wsometimes-uninitialized], [CFLAGS="$CFLAGS -Wsometimes-uninitialized"])
773
774     # This is required because we pass format string as "const char*.
775     AX_CHECK_COMPILE_FLAG([-Wno-format-nonliteral], [CFLAGS="$CFLAGS -Wno-format-nonliteral"])
776
777     # For C++ compiler
778     AC_LANG_PUSH(C++)
779     AX_CHECK_COMPILE_FLAG([-Wall], [CXXFLAGS="$CXXFLAGS -Wall"])
780     AX_CHECK_COMPILE_FLAG([-Werror], [CXXFLAGS="$CXXFLAGS -Werror"])
781     AX_CHECK_COMPILE_FLAG([-Wformat-security], [CXXFLAGS="$CXXFLAGS -Wformat-security"])
782     AX_CHECK_COMPILE_FLAG([-Wsometimes-uninitialized], [CXXFLAGS="$CXXFLAGS -Wsometimes-uninitialized"])
783     # Disable noexcept-type warning of g++-7.  This is not harmful as
784     # long as all source files are compiled with the same compiler.
785     AX_CHECK_COMPILE_FLAG([-Wno-noexcept-type], [CXXFLAGS="$CXXFLAGS -Wno-noexcept-type"])
786     AC_LANG_POP()
787 fi
788
789 WARNCFLAGS=$CFLAGS
790 WARNCXXFLAGS=$CXXFLAGS
791
792 CFLAGS=$save_CFLAGS
793 CXXFLAGS=$save_CXXFLAGS
794
795 AC_SUBST([WARNCFLAGS])
796 AC_SUBST([WARNCXXFLAGS])
797
798 EXTRACFLAG=
799 AX_CHECK_COMPILE_FLAG([-fvisibility=hidden], [EXTRACFLAG="-fvisibility=hidden"])
800
801 AC_SUBST([EXTRACFLAG])
802
803 if test "x$debug" != "xno"; then
804     AC_DEFINE([DEBUGBUILD], [1], [Define to 1 to enable debug output.])
805 fi
806
807 enable_threads=yes
808 # Some platform does not have working std::future.  We disable
809 # threading for those platforms.
810 if test "x$threads" != "xyes" ||
811    test "x$have_std_future" != "xyes"; then
812     enable_threads=no
813     AC_DEFINE([NOTHREADS], [1], [Define to 1 if you want to disable threads.])
814 fi
815
816 # propagate $enable_static to tests/Makefile.am
817 AM_CONDITIONAL([ENABLE_STATIC], [test "x$enable_static" = "xyes"])
818
819 AC_SUBST([TESTLDADD])
820 AC_SUBST([APPLDFLAGS])
821
822 AC_CONFIG_FILES([
823   Makefile
824   lib/Makefile
825   lib/libnghttp2.pc
826   lib/includes/Makefile
827   lib/includes/nghttp2/nghttp2ver.h
828   tests/Makefile
829   tests/testdata/Makefile
830   third-party/Makefile
831   src/Makefile
832   src/includes/Makefile
833   src/libnghttp2_asio.pc
834   examples/Makefile
835   python/Makefile
836   python/setup.py
837   integration-tests/Makefile
838   integration-tests/config.go
839   integration-tests/setenv
840   doc/Makefile
841   doc/conf.py
842   doc/index.rst
843   doc/package_README.rst
844   doc/tutorial-client.rst
845   doc/tutorial-server.rst
846   doc/tutorial-hpack.rst
847   doc/nghttpx-howto.rst
848   doc/h2load-howto.rst
849   doc/libnghttp2_asio.rst
850   doc/python-apiref.rst
851   doc/building-android-binary.rst
852   doc/nghttp2.h.rst
853   doc/nghttp2ver.h.rst
854   doc/asio_http2.h.rst
855   doc/asio_http2_server.h.rst
856   doc/asio_http2_client.h.rst
857   doc/contribute.rst
858   contrib/Makefile
859   script/Makefile
860 ])
861 AC_OUTPUT
862
863 AC_MSG_NOTICE([summary of build options:
864
865     Package version: ${VERSION}
866     Library version: $LT_CURRENT:$LT_REVISION:$LT_AGE
867     Install prefix:  ${prefix}
868     System types:
869       Build:         ${build}
870       Host:          ${host}
871       Target:        ${target}
872     Compiler:
873       C compiler:     ${CC}
874       CFLAGS:         ${CFLAGS}
875       LDFLAGS:        ${LDFLAGS}
876       C++ compiler:   ${CXX}
877       CXXFLAGS:       ${CXXFLAGS}
878       CXXCPP:         ${CXXCPP}
879       C preprocessor: ${CPP}
880       CPPFLAGS:       ${CPPFLAGS}
881       WARNCFLAGS:     ${WARNCFLAGS}
882       WARNCXXFLAGS:   ${WARNCXXFLAGS}
883       CXX1XCXXFLAGS:  ${CXX1XCXXFLAGS}
884       EXTRACFLAG:     ${EXTRACFLAG}
885       LIBS:           ${LIBS}
886     Library:
887       Shared:         ${enable_shared}
888       Static:         ${enable_static}
889     Python:
890       Python:         ${PYTHON}
891       PYTHON_VERSION: ${PYTHON_VERSION}
892       pyexecdir:      ${pyexecdir}
893       Python-dev:     ${have_python_dev}
894       PYTHON_CPPFLAGS:${PYTHON_CPPFLAGS}
895       PYTHON_LDFLAGS: ${PYTHON_LDFLAGS}
896       Cython:         ${CYTHON}
897     Test:
898       CUnit:          ${have_cunit} (CFLAGS='${CUNIT_CFLAGS}' LIBS='${CUNIT_LIBS}')
899       Failmalloc:     ${enable_failmalloc}
900     Libs:
901       OpenSSL:        ${have_openssl} (CFLAGS='${OPENSSL_CFLAGS}' LIBS='${OPENSSL_LIBS}')
902       Libxml2:        ${have_libxml2} (CFLAGS='${LIBXML2_CPPFLAGS}' LIBS='${LIBXML2_LIBS}')
903       Libev:          ${have_libev} (CFLAGS='${LIBEV_CFLAGS}' LIBS='${LIBEV_LIBS}')
904       Libc-ares       ${have_libcares} (CFLAGS='${LIBCARES_CFLAGS}' LIBS='${LIBCARES_LIBS}')
905       Libevent(SSL):  ${have_libevent_openssl} (CFLAGS='${LIBEVENT_OPENSSL_CFLAGS}' LIBS='${LIBEVENT_OPENSSL_LIBS}')
906       Jansson:        ${have_jansson} (CFLAGS='${JANSSON_CFLAGS}' LIBS='${JANSSON_LIBS}')
907       Jemalloc:       ${have_jemalloc} (LIBS='${JEMALLOC_LIBS}')
908       Zlib:           ${have_zlib} (CFLAGS='${ZLIB_CFLAGS}' LIBS='${ZLIB_LIBS}')
909       Systemd:        ${have_libsystemd} (CFLAGS='${SYSTEMD_CFLAGS}' LIBS='${SYSTEMD_LIBS}')
910       Boost CPPFLAGS: ${BOOST_CPPFLAGS}
911       Boost LDFLAGS:  ${BOOST_LDFLAGS}
912       Boost::ASIO:    ${BOOST_ASIO_LIB}
913       Boost::System:  ${BOOST_SYSTEM_LIB}
914       Boost::Thread:  ${BOOST_THREAD_LIB}
915     Third-party:
916       http-parser:    ${enable_third_party}
917       MRuby:          ${have_mruby} (CFLAGS='${LIBMRUBY_CFLAGS}' LIBS='${LIBMRUBY_LIBS}')
918       Neverbleed:     ${have_neverbleed}
919     Features:
920       Applications:   ${enable_app}
921       HPACK tools:    ${enable_hpack_tools}
922       Libnghttp2_asio:${enable_asio_lib}
923       Examples:       ${enable_examples}
924       Python bindings:${enable_python_bindings}
925       Threading:      ${enable_threads}
926 ])