• 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 http://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html
26
27AC_PREREQ(2.61)
28AC_INIT([nghttp2], [1.43.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])
42
43m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
44
45dnl See versioning rule:
46dnl  http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
47AC_SUBST(LT_CURRENT, 34)
48AC_SUBST(LT_REVISION, 1)
49AC_SUBST(LT_AGE, 20)
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([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
90AC_ARG_ENABLE([examples],
91    [AS_HELP_STRING([--enable-examples],
92                    [Build examples [default=check]])],
93    [request_examples=$enableval], [request_examples=check])
94
95AC_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
100AC_ARG_ENABLE([failmalloc],
101    [AS_HELP_STRING([--disable-failmalloc],
102                    [Do not build failmalloc test program])],
103    [request_failmalloc=$enableval], [request_failmalloc=yes])
104
105AC_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
110AC_ARG_WITH([libxml2],
111    [AS_HELP_STRING([--with-libxml2],
112                    [Use libxml2 [default=check]])],
113    [request_libxml2=$withval], [request_libxml2=check])
114
115AC_ARG_WITH([jemalloc],
116    [AS_HELP_STRING([--with-jemalloc],
117                    [Use jemalloc [default=check]])],
118    [request_jemalloc=$withval], [request_jemalloc=check])
119
120AC_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
125AC_ARG_WITH([mruby],
126    [AS_HELP_STRING([--with-mruby],
127                    [Use mruby [default=no]])],
128    [request_mruby=$withval], [request_mruby=no])
129
130AC_ARG_WITH([neverbleed],
131    [AS_HELP_STRING([--with-neverbleed],
132                    [Use neverbleed [default=no]])],
133    [request_neverbleed=$withval], [request_neverbleed=no])
134
135AC_ARG_WITH([cython],
136    [AS_HELP_STRING([--with-cython=PATH],
137                    [Use cython in given PATH])],
138    [cython_path=$withval], [])
139
140dnl Define variables
141AC_ARG_VAR([CYTHON], [the Cython executable])
142
143dnl Checks for programs
144AC_PROG_CC
145AC_PROG_CXX
146AC_PROG_CPP
147AC_PROG_INSTALL
148AC_PROG_LN_S
149AC_PROG_MAKE_SET
150AC_PROG_MKDIR_P
151
152PKG_PROG_PKG_CONFIG([0.20])
153
154AM_PATH_PYTHON([3.8],, [:])
155
156if [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
161fi
162
163if [test "x$request_python_bindings" != "xno"]; then
164  AX_PYTHON_DEVEL([>= '3.8'])
165fi
166
167if test "x${cython_path}" = "x"; then
168  AC_CHECK_PROGS([CYTHON], [cython.py cython])
169else
170  CYTHON=${cython_path}
171  AC_SUBST([CYTHON])
172fi
173
174if 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])
176else
177  AC_DEFINE([NGHTTP2_NORETURN], , [Hint to the compiler that a function never return])
178fi
179
180save_CXXFLAGS="$CXXFLAGS"
181CXXFLAGS=
182
183AX_CXX_COMPILE_STDCXX([14], [noext], [optional])
184
185CXX1XCXXFLAGS="$CXXFLAGS"
186CXXFLAGS="$save_CXXFLAGS"
187AC_SUBST([CXX1XCXXFLAGS])
188
189AC_LANG_PUSH(C++)
190
191save_CXXFLAGS="$CXXFLAGS"
192CXXFLAGS="$CXXFLAGS $CXX1XCXXFLAGS"
193
194# Check that std::future is available.
195AC_MSG_CHECKING([whether std::future is available])
196AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
197[[
198#include <vector>
199#include <future>
200]],
201[[
202std::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.
212AC_MSG_CHECKING([whether std::map::emplace is available])
213AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
214[[
215#include <map>
216]],
217[[
218std::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.
229AC_MSG_CHECKING([whether std::atomic_* overloads for std::shared_ptr are available])
230AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
231[[
232#include <memory>
233]],
234[[
235auto a = std::make_shared<int>(1000000007);
236auto p = std::atomic_load(&a);
237++*p;
238std::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
248AC_MSG_CHECKING([whether thread_local storage class specifier is available.])
249AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
250,
251[[
252thread_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
262CXXFLAGS=$save_CXXFLAGS
263
264AC_LANG_POP()
265
266# Checks for libraries.
267
268# Additional libraries required for tests.
269TESTLDADD=
270
271# Additional libraries required for programs under src directory.
272APPLDFLAGS=
273
274case "$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    ;;
284esac
285
286case "$host_os" in
287  *solaris*)
288    APPLDFLAGS="$APPLDFLAGS -lsocket -lnsl"
289    ;;
290esac
291
292# zlib
293PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.3], [have_zlib=yes], [have_zlib=no])
294
295if test "x${have_zlib}" = "xno"; then
296  AC_MSG_NOTICE($ZLIB_PKG_ERRORS)
297fi
298
299# dl: openssl requires libdl when it is statically linked.
300case "${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    ;;
309esac
310
311# cunit
312PKG_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.
315if 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
325fi
326if 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
336fi
337
338AM_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.
342save_LIBS=$LIBS
343# android requires -lm for floor
344AC_CHECK_LIB([ev], [ev_time], [have_libev=yes], [have_libev=no], [-lm])
345if 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
353fi
354LIBS=$save_LIBS
355
356# openssl (for src)
357PKG_CHECK_MODULES([OPENSSL], [openssl >= 1.0.1],
358                  [have_openssl=yes], [have_openssl=no])
359if test "x${have_openssl}" = "xno"; then
360  AC_MSG_NOTICE($OPENSSL_PKG_ERRORS)
361fi
362
363# c-ares (for src)
364PKG_CHECK_MODULES([LIBCARES], [libcares >= 1.7.5], [have_libcares=yes],
365                  [have_libcares=no])
366if test "x${have_libcares}" = "xno"; then
367  AC_MSG_NOTICE($LIBCARES_PKG_ERRORS)
368fi
369
370# libevent_openssl (for examples)
371# 2.0.8 is required because we use evconnlistener_set_error_cb()
372PKG_CHECK_MODULES([LIBEVENT_OPENSSL], [libevent_openssl >= 2.0.8],
373                  [have_libevent_openssl=yes], [have_libevent_openssl=no])
374if test "x${have_libevent_openssl}" = "xno"; then
375  AC_MSG_NOTICE($LIBEVENT_OPENSSL_PKG_ERRORS)
376fi
377
378# jansson (for src/nghttp, src/deflatehd and src/inflatehd)
379PKG_CHECK_MODULES([JANSSON], [jansson >= 2.5],
380                  [have_jansson=yes], [have_jansson=no])
381if test "x${have_jansson}" = "xyes"; then
382  AC_DEFINE([HAVE_JANSSON], [1],
383            [Define to 1 if you have `libjansson` library.])
384else
385  AC_MSG_NOTICE($JANSSON_PKG_ERRORS)
386fi
387
388
389#  libsystemd (for src/nghttpx)
390have_libsystemd=no
391if 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
400fi
401
402if test "x${request_systemd}" = "xyes" &&
403   test "x${have_libsystemd}" != "xyes"; then
404  AC_MSG_ERROR([systemd was requested (--with-systemd) but not found])
405fi
406
407# libxml2 (for src/nghttp)
408PKG_CHECK_MODULES([LIBXML2], [libxml-2.0 >= 2.6.26],
409                  [have_libxml2=yes], [have_libxml2=no])
410if test "x${have_libxml2}" = "xyes"; then
411  AC_DEFINE([HAVE_LIBXML2], [1], [Define to 1 if you have `libxml2` library.])
412else
413  AC_MSG_NOTICE($LIBXML2_PKG_ERRORS)
414fi
415
416if test "x${request_libxml2}" = "xyes" &&
417   test "x${have_libxml2}" != "xyes"; then
418  AC_MSG_ERROR([libxml2 was requested (--with-libxml2) but not found])
419fi
420
421AM_CONDITIONAL([HAVE_LIBXML2], [ test "x${have_libxml2}" = "xyes" ])
422
423# jemalloc
424have_jemalloc=no
425if 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
449fi
450
451if test "x${request_jemalloc}" = "xyes" &&
452   test "x${have_jemalloc}" != "xyes"; then
453  AC_MSG_ERROR([jemalloc was requested (--with-jemalloc) but not found])
454fi
455
456# Check Boost Asio library
457have_asio_lib=no
458
459if 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
473fi
474
475# The nghttp, nghttpd and nghttpx under src depend on zlib, OpenSSL,
476# libev, and libc-ares.
477enable_app=no
478if 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
484fi
485
486if 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.])
489fi
490
491AM_CONDITIONAL([ENABLE_APP], [ test "x${enable_app}" = "xyes" ])
492
493enable_hpack_tools=no
494# HPACK tools requires jansson
495if test "x${request_hpack_tools}" != "xno" &&
496   test "x${have_jansson}" = "xyes"; then
497  enable_hpack_tools=yes
498fi
499
500if 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.])
503fi
504
505AM_CONDITIONAL([ENABLE_HPACK_TOOLS], [ test "x${enable_hpack_tools}" = "xyes" ])
506
507# C++ library libnghttp2_asio
508
509enable_asio_lib=no
510if test "x${request_asio_lib}" != "xno" &&
511   test "x${have_asio_lib}" = "xyes"; then
512  enable_asio_lib=yes
513fi
514
515AM_CONDITIONAL([ENABLE_ASIO_LIB], [ test "x${enable_asio_lib}" = "xyes" ])
516
517# The example programs depend on OpenSSL and libevent_openssl
518enable_examples=no
519if test "x${request_examples}" != "xno" &&
520   test "x${have_openssl}" = "xyes" &&
521   test "x${have_libevent_openssl}" = "xyes"; then
522  enable_examples=yes
523fi
524
525if 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.])
528fi
529
530AM_CONDITIONAL([ENABLE_EXAMPLES], [ test "x${enable_examples}" = "xyes" ])
531
532# third-party only be built when needed
533
534enable_third_party=no
535have_mruby=no
536have_neverbleed=no
537if 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
559fi
560
561AM_CONDITIONAL([ENABLE_THIRD_PARTY], [ test "x${enable_third_party}" = "xyes" ])
562AM_CONDITIONAL([HAVE_MRUBY], [test "x${have_mruby}" = "xyes"])
563AM_CONDITIONAL([HAVE_NEVERBLEED], [test "x${have_neverbleed}" = "xyes"])
564
565# Python bindings
566enable_python_bindings=no
567if test "x${request_python_bindings}" != "xno" &&
568   test "x${CYTHON}" != "x" &&
569   test "x${PYTHON}" != "x:" &&
570   test "x${PYTHON_VERSION}" != "x"; then
571  enable_python_bindings=yes
572fi
573
574if 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.])
577fi
578
579AM_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
584AM_CONDITIONAL([HAVE_CYTHON], [test "x${CYTHON}" != "x"])
585
586# failmalloc tests
587enable_failmalloc=no
588if test "x${request_failmalloc}" = "xyes"; then
589  enable_failmalloc=yes
590fi
591
592AM_CONDITIONAL([ENABLE_FAILMALLOC], [ test "x${enable_failmalloc}" = "xyes" ])
593
594# Checks for header files.
595AC_HEADER_ASSERT
596AC_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.
616AC_TYPE_SIZE_T
617AC_TYPE_SSIZE_T
618AC_TYPE_UINT8_T
619AC_TYPE_UINT16_T
620AC_TYPE_UINT32_T
621AC_TYPE_UINT64_T
622AC_TYPE_INT8_T
623AC_TYPE_INT16_T
624AC_TYPE_INT32_T
625AC_TYPE_INT64_T
626AC_TYPE_OFF_T
627AC_TYPE_PID_T
628AC_TYPE_UID_T
629AC_CHECK_TYPES([ptrdiff_t])
630AC_C_BIGENDIAN
631AC_C_INLINE
632AC_SYS_LARGEFILE
633
634AC_CHECK_MEMBER([struct tm.tm_gmtoff], [have_struct_tm_tm_gmtoff=yes],
635                [have_struct_tm_tm_gmtoff=no], [[#include <time.h>]])
636
637AC_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
647AC_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
657if 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.])
660fi
661
662# Check size of pointer to decide we need 8 bytes alignment
663# adjustment.
664AC_CHECK_SIZEOF([int *])
665
666AC_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
673AC_FUNC_CHOWN
674AC_FUNC_ERROR_AT_LINE
675AC_FUNC_FORK
676# Don't check realloc, since LeakSanitizer detects memory leak during check
677# AC_FUNC_REALLOC
678AC_FUNC_STRERROR_R
679AC_FUNC_STRNLEN
680
681AC_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
706AC_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.
712AC_CHECK_DECLS([initgroups], [], [], [[
713  #ifdef HAVE_UNISTD_H
714  # include <unistd.h>
715  #endif
716  #include <grp.h>
717]])
718
719save_CFLAGS=$CFLAGS
720save_CXXFLAGS=$CXXFLAGS
721
722CFLAGS=
723CXXFLAGS=
724
725if 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()
787fi
788
789WARNCFLAGS=$CFLAGS
790WARNCXXFLAGS=$CXXFLAGS
791
792CFLAGS=$save_CFLAGS
793CXXFLAGS=$save_CXXFLAGS
794
795AC_SUBST([WARNCFLAGS])
796AC_SUBST([WARNCXXFLAGS])
797
798EXTRACFLAG=
799AX_CHECK_COMPILE_FLAG([-fvisibility=hidden], [EXTRACFLAG="-fvisibility=hidden"])
800
801AC_SUBST([EXTRACFLAG])
802
803if test "x$debug" != "xno"; then
804    AC_DEFINE([DEBUGBUILD], [1], [Define to 1 to enable debug output.])
805fi
806
807enable_threads=yes
808# Some platform does not have working std::future.  We disable
809# threading for those platforms.
810if 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.])
814fi
815
816# propagate $enable_static to tests/Makefile.am
817AM_CONDITIONAL([ENABLE_STATIC], [test "x$enable_static" = "xyes"])
818
819AC_SUBST([TESTLDADD])
820AC_SUBST([APPLDFLAGS])
821
822AC_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])
861AC_OUTPUT
862
863AC_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_CPPFLAGS:${PYTHON_CPPFLAGS}
894      PYTHON_LIBS:    ${PYTHON_LIBS}
895      Cython:         ${CYTHON}
896    Test:
897      CUnit:          ${have_cunit} (CFLAGS='${CUNIT_CFLAGS}' LIBS='${CUNIT_LIBS}')
898      Failmalloc:     ${enable_failmalloc}
899    Libs:
900      OpenSSL:        ${have_openssl} (CFLAGS='${OPENSSL_CFLAGS}' LIBS='${OPENSSL_LIBS}')
901      Libxml2:        ${have_libxml2} (CFLAGS='${LIBXML2_CFLAGS}' LIBS='${LIBXML2_LIBS}')
902      Libev:          ${have_libev} (CFLAGS='${LIBEV_CFLAGS}' LIBS='${LIBEV_LIBS}')
903      Libc-ares:      ${have_libcares} (CFLAGS='${LIBCARES_CFLAGS}' LIBS='${LIBCARES_LIBS}')
904      Libevent(SSL):  ${have_libevent_openssl} (CFLAGS='${LIBEVENT_OPENSSL_CFLAGS}' LIBS='${LIBEVENT_OPENSSL_LIBS}')
905      Jansson:        ${have_jansson} (CFLAGS='${JANSSON_CFLAGS}' LIBS='${JANSSON_LIBS}')
906      Jemalloc:       ${have_jemalloc} (LIBS='${JEMALLOC_LIBS}')
907      Zlib:           ${have_zlib} (CFLAGS='${ZLIB_CFLAGS}' LIBS='${ZLIB_LIBS}')
908      Systemd:        ${have_libsystemd} (CFLAGS='${SYSTEMD_CFLAGS}' LIBS='${SYSTEMD_LIBS}')
909      Boost CPPFLAGS: ${BOOST_CPPFLAGS}
910      Boost LDFLAGS:  ${BOOST_LDFLAGS}
911      Boost::ASIO:    ${BOOST_ASIO_LIB}
912      Boost::System:  ${BOOST_SYSTEM_LIB}
913      Boost::Thread:  ${BOOST_THREAD_LIB}
914    Third-party:
915      http-parser:    ${enable_third_party}
916      MRuby:          ${have_mruby} (CFLAGS='${LIBMRUBY_CFLAGS}' LIBS='${LIBMRUBY_LIBS}')
917      Neverbleed:     ${have_neverbleed}
918    Features:
919      Applications:   ${enable_app}
920      HPACK tools:    ${enable_hpack_tools}
921      Libnghttp2_asio:${enable_asio_lib}
922      Examples:       ${enable_examples}
923      Python bindings:${enable_python_bindings}
924      Threading:      ${enable_threads}
925])
926