Imported Upstream version 1.0.0
[platform/upstream/nghttp2.git] / configure.ac
1 dnl nghttp2 - HTTP/2 C Library
2
3 dnl Copyright (c) 2012, 2013, 2014, 2015 Tatsuhiro Tsujikawa
4
5 dnl Permission is hereby granted, free of charge, to any person obtaining
6 dnl a copy of this software and associated documentation files (the
7 dnl "Software"), to deal in the Software without restriction, including
8 dnl without limitation the rights to use, copy, modify, merge, publish,
9 dnl distribute, sublicense, and/or sell copies of the Software, and to
10 dnl permit persons to whom the Software is furnished to do so, subject to
11 dnl the following conditions:
12
13 dnl The above copyright notice and this permission notice shall be
14 dnl included in all copies or substantial portions of the Software.
15
16 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 dnl EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 dnl NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 dnl LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 dnl OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 dnl WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24 dnl Do not change user variables!
25 dnl http://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html
26
27 AC_PREREQ(2.61)
28 AC_INIT([nghttp2], [1.0.0], [t-tujikawa@users.sourceforge.net])
29 AC_USE_SYSTEM_EXTENSIONS
30
31 LT_PREREQ([2.2.6])
32 LT_INIT()
33
34 AC_CANONICAL_BUILD
35 AC_CANONICAL_HOST
36 AC_CANONICAL_TARGET
37
38 AM_INIT_AUTOMAKE([subdir-objects])
39 # comment out for now since this requires automake 1.13 or higher and
40 # travis has older one.
41 # AM_EXTRA_RECURSIVE_TARGETS([it])
42
43 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
44
45 AC_CONFIG_MACRO_DIR([m4])
46 AC_CONFIG_HEADERS([config.h])
47
48 dnl See versioning rule:
49 dnl  http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
50 AC_SUBST(LT_CURRENT, 14)
51 AC_SUBST(LT_REVISION, 0)
52 AC_SUBST(LT_AGE, 0)
53
54 major=`echo $PACKAGE_VERSION |cut -d. -f1 | sed -e "s/[^0-9]//g"`
55 minor=`echo $PACKAGE_VERSION |cut -d. -f2 | sed -e "s/[^0-9]//g"`
56 patch=`echo $PACKAGE_VERSION |cut -d. -f3 | cut -d- -f1 | sed -e "s/[^0-9]//g"`
57
58 PACKAGE_VERSION_NUM=`printf "0x%02x%02x%02x" "$major" "$minor" "$patch"`
59
60 AC_SUBST(PACKAGE_VERSION_NUM)
61
62 dnl Checks for command-line options
63 AC_ARG_ENABLE([werror],
64     [AS_HELP_STRING([--enable-werror],
65                     [Turn on compile time warnings])],
66     [werror=$enableval], [werror=no])
67
68 AC_ARG_ENABLE([debug],
69     [AS_HELP_STRING([--enable-debug],
70                     [Turn on debug output])],
71     [debug=$enableval], [debug=no])
72
73 AC_ARG_ENABLE([threads],
74     [AS_HELP_STRING([--disable-threads],
75                     [Turn off threading in apps])],
76     [threads=$enableval], [threads=yes])
77
78 AC_ARG_ENABLE([app],
79     [AS_HELP_STRING([--enable-app],
80                     [Build applications (nghttp, nghttpd and nghttpx) [default=check]])],
81     [request_app=$enableval], [request_app=check])
82
83 AC_ARG_ENABLE([hpack-tools],
84     [AS_HELP_STRING([--enable-hpack-tools],
85                     [Build HPACK tools [default=check]])],
86     [request_hpack_tools=$enableval], [request_hpack_tools=check])
87
88 AC_ARG_ENABLE([asio-lib],
89     [AS_HELP_STRING([--enable-asio-lib],
90                     [Build C++ libnghttp2_asio library [default=no]])],
91     [request_asio_lib=$enableval], [request_asio_lib=no])
92
93 AC_ARG_ENABLE([examples],
94     [AS_HELP_STRING([--enable-examples],
95                     [Build examples [default=check]])],
96     [request_examples=$enableval], [request_examples=check])
97
98 AC_ARG_ENABLE([python-bindings],
99     [AS_HELP_STRING([--enable-python-bindings],
100                     [Build Python bindings [default=check]])],
101     [request_python_bindings=$enableval], [request_python_bindings=check])
102
103 AC_ARG_ENABLE([failmalloc],
104     [AS_HELP_STRING([--disable-failmalloc],
105                     [Do not build failmalloc test program])],
106     [request_failmalloc=$enableval], [request_failmalloc=yes])
107
108 AC_ARG_WITH([libxml2],
109     [AS_HELP_STRING([--with-libxml2],
110                     [Use libxml2 [default=check]])],
111     [request_libxml2=$withval], [request_libxml2=check])
112
113 AC_ARG_WITH([jemalloc],
114     [AS_HELP_STRING([--with-jemalloc],
115                     [Use jemalloc [default=check]])],
116     [request_jemalloc=$withval], [request_jemalloc=check])
117
118 AC_ARG_WITH([spdylay],
119     [AS_HELP_STRING([--with-spdylay],
120                     [Use spdylay [default=check]])],
121     [request_spdylay=$withval], [request_spdylay=check])
122
123 AC_ARG_WITH([cython],
124     [AS_HELP_STRING([--with-cython=PATH],
125                     [Use cython in given PATH])],
126     [cython_path=$withval], [])
127
128 dnl Define variables
129 AC_ARG_VAR([CYTHON], [the Cython executable])
130
131 dnl Checks for programs
132 AC_PROG_CC
133 AC_PROG_CXX
134 AC_PROG_CPP
135 AC_PROG_INSTALL
136 AC_PROG_LN_S
137 AC_PROG_MAKE_SET
138 AC_PROG_MKDIR_P
139
140 PKG_PROG_PKG_CONFIG([0.20])
141
142 if [test "x$request_python_bindings" != "xno"]; then
143   AM_PATH_PYTHON([2.7],, [:])
144   AX_PYTHON_DEVEL([>= '2.7'])
145 fi
146
147 if test "x${cython_path}" = "x"; then
148   AC_CHECK_PROGS([CYTHON], [cython.py cython])
149 else
150   CYTHON=${cython_path}
151   AC_SUBST([CYTHON])
152 fi
153
154 #
155 # If we're running GCC or clang define _U_ to be "__attribute__((unused))"
156 # so we can use _U_ to flag unused function parameters and not get warnings
157 # about them. Otherwise, define _U_ to be an empty string so that _U_ used
158 # to flag an unused function parameters will compile with other compilers.
159 #
160 # XXX - similar hints for other compilers?
161 #
162 if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
163   AC_DEFINE([_U_], [__attribute__((unused))], [Hint to the compiler that a function parameters is not used])
164 else
165   AC_DEFINE([_U_], , [Hint to the compiler that a function parameters is not used])
166 fi
167
168 AX_CXX_COMPILE_STDCXX_11([noext], [optional])
169
170 AC_LANG_PUSH(C++)
171
172 # Check that std::chrono::steady_clock is available. In particular,
173 # gcc 4.6 does not have one, but has monotonic_clock which is the old
174 # name existed in the pre-standard draft. If steady_clock is not
175 # available, don't define HAVE_STEADY_CLOCK and replace steady_clock
176 # with monotonic_clock.
177 AC_MSG_CHECKING([whether std::chrono::steady_clock is available])
178 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
179 [[
180 #include <chrono>
181 ]],
182 [[
183 auto tp = std::chrono::steady_clock::now();
184 ]])],
185     [AC_DEFINE([HAVE_STEADY_CLOCK], [1],
186                [Define to 1 if you have the `std::chrono::steady_clock`.])
187      AC_MSG_RESULT([yes])],
188     [AC_MSG_RESULT([no])])
189
190 # Check that std::future is available.
191 AC_MSG_CHECKING([whether std::future is available])
192 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
193 [[
194 #include <vector>
195 #include <future>
196 ]],
197 [[
198 std::vector<std::future<int>> v;
199 ]])],
200     [AC_DEFINE([HAVE_STD_FUTURE], [1],
201                [Define to 1 if you have the `std::future`.])
202      have_std_future=yes
203      AC_MSG_RESULT([yes])],
204     [have_std_future=no
205      AC_MSG_RESULT([no])])
206
207 # Check that std::map::emplace is available for g++-4.7.
208 AC_MSG_CHECKING([whether std::map::emplace is available])
209 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
210 [[
211 #include <map>
212 ]],
213 [[
214 std::map<int, int>().emplace(1, 2);
215 ]])],
216     [AC_DEFINE([HAVE_STD_MAP_EMPLACE], [1],
217                [Define to 1 if you have the `std::map::emplace`.])
218      have_std_map_emplace=yes
219      AC_MSG_RESULT([yes])],
220     [have_std_map_emplace=no
221      AC_MSG_RESULT([no])])
222
223 AC_LANG_POP()
224
225 # Checks for libraries.
226
227 # Additional libraries required for tests.
228 TESTLDADD=
229
230 # Additional libraries required for programs under src directory.
231 APPLDFLAGS=
232
233 LIBS_OLD=$LIBS
234 # Search for dlsym function, which is used in tests. Linux needs -ldl,
235 # but netbsd does not need it.
236 AC_SEARCH_LIBS([dlsym], [dl])
237 TESTLDADD="$LIBS $TESTLDADD"
238 LIBS=$LIBS_OLD
239
240 LIBS_OLD=$LIBS
241 AC_SEARCH_LIBS([clock_gettime], [rt],
242                [AC_DEFINE([HAVE_CLOCK_GETTIME], [1],
243                           [Define to 1 if you have the `clock_gettime`.])])
244 APPLDFLAGS="$LIBS $APPLDFLAGS"
245 LIBS=$LIBS_OLD
246
247 case "$host" in
248   *android*)
249     android_build=yes
250     # android does not need -pthread, but needs followng 3 libs for C++
251     APPLDFLAGS="$APPLDFLAGS -lstdc++ -latomic -lsupc++"
252     ;;
253   *)
254     PTHREAD_LDFLAGS="-pthread"
255     APPLDFLAGS="$APPLDFLAGS $PTHREAD_LDFLAGS"
256     ;;
257 esac
258
259 # zlib
260 if test "x$android_build" = "xyes"; then
261   # Use zlib provided by NDK
262   APPLDFLAGS="-lz $APPLDFLAGS"
263   have_zlib=yes
264 else
265   PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.3], [have_zlib=yes], [have_zlib=no])
266
267   if test "x${have_zlib}" = "xno"; then
268     AC_MSG_NOTICE($ZLIB_PKG_ERRORS)
269   fi
270 fi
271
272 # cunit
273 PKG_CHECK_MODULES([CUNIT], [cunit >= 2.1], [have_cunit=yes], [have_cunit=no])
274 # If pkg-config does not find cunit, check it using AC_CHECK_LIB.  We
275 # do this because Debian (Ubuntu) lacks pkg-config file for cunit.
276 if test "x${have_cunit}" = "xno"; then
277   AC_MSG_WARN([${CUNIT_PKG_ERRORS}])
278   AC_CHECK_LIB([cunit], [CU_initialize_registry],
279                [have_cunit=yes], [have_cunit=no])
280   if test "x${have_cunit}" = "xyes"; then
281     CUNIT_LIBS="-lcunit"
282     CUNIT_CFLAGS=""
283     AC_SUBST([CUNIT_LIBS])
284     AC_SUBST([CUNIT_CFLAGS])
285   fi
286 fi
287 if test "x${have_cunit}" = "xyes"; then
288   # cunit in Mac OS X requires ncurses. Note that in Mac OS X, test
289   # program can be built without -lncurses, but it emits runtime
290   # error.
291   case "${build}" in
292     *-apple-darwin*)
293       CUNIT_LIBS="$CUNIT_LIBS -lncurses"
294       AC_SUBST([CUNIT_LIBS])
295       ;;
296   esac
297 fi
298
299 AM_CONDITIONAL([HAVE_CUNIT], [ test "x${have_cunit}" = "xyes" ])
300
301 # libev (for src)
302 # libev does not have pkg-config file.  Check it in an old way.
303 LIBS_OLD=$LIBS
304 # android requires -lm for floor
305 AC_CHECK_LIB([ev], [ev_time], [have_libev=yes], [have_libev=no], [-lm])
306 if test "x${have_libev}" = "xyes"; then
307   AC_CHECK_HEADER([ev.h], [have_libev=yes], [have_libev=no])
308   if test "x${have_libev}" = "xyes"; then
309     LIBEV_LIBS=-lev
310     LIBEV_CFLAGS=
311     AC_SUBST([LIBEV_LIBS])
312     AC_SUBST([LIBEV_CFLAGS])
313   fi
314 fi
315 LIBS=$LIBS_OLD
316
317 # openssl (for src)
318 PKG_CHECK_MODULES([OPENSSL], [openssl >= 1.0.1],
319                   [have_openssl=yes], [have_openssl=no])
320 if test "x${have_openssl}" = "xno"; then
321   AC_MSG_NOTICE($OPENSSL_PKG_ERRORS)
322 fi
323
324 # libevent_openssl (for examples)
325 # 2.0.8 is required because we use evconnlistener_set_error_cb()
326 PKG_CHECK_MODULES([LIBEVENT_OPENSSL], [libevent_openssl >= 2.0.8],
327                   [have_libevent_openssl=yes], [have_libevent_openssl=no])
328 if test "x${have_libevent_openssl}" = "xno"; then
329   AC_MSG_NOTICE($LIBEVENT_OPENSSL_PKG_ERRORS)
330 fi
331
332 # jansson (for src/nghttp, src/deflatehd and src/inflatehd)
333 PKG_CHECK_MODULES([JANSSON], [jansson >= 2.5],
334                   [have_jansson=yes], [have_jansson=no])
335 if test "x${have_jansson}" == "xyes"; then
336   AC_DEFINE([HAVE_JANSSON], [1],
337             [Define to 1 if you have `libjansson` library.])
338 else
339   AC_MSG_NOTICE($JANSSON_PKG_ERRORS)
340 fi
341
342 # libxml2 (for src/nghttp)
343 have_libxml2=no
344 if test "x${request_libxml2}" != "xno"; then
345   AM_PATH_XML2(2.7.7, [have_libxml2=yes], [have_libxml2=no])
346   if test "x${have_libxml2}" = "xyes"; then
347     AC_DEFINE([HAVE_LIBXML2], [1], [Define to 1 if you have `libxml2` library.])
348   fi
349 fi
350
351 if test "x${request_libxml2}" = "xyes" &&
352    test "x${have_libxml2}" != "xyes"; then
353   AC_MSG_ERROR([libxml2 was requested (--with-libxml2) but not found])
354 fi
355
356 AM_CONDITIONAL([HAVE_LIBXML2], [ test "x${have_libxml2}" = "xyes" ])
357
358 # jemalloc
359 have_jemalloc=no
360 if test "x${request_jemalloc}" != "xno"; then
361   LIBS_OLD=$LIBS
362   AC_SEARCH_LIBS([malloc_stats_print], [jemalloc], [have_jemalloc=yes], [],
363                  [$PTHREAD_LDFLAGS])
364   LIBS=$LIBS_OLD
365
366   if test "x${have_jemalloc}" = "xyes"; then
367     jemalloc_libs=${ac_cv_search_malloc_stats_print}
368   else
369     # On Darwin, malloc_stats_print is je_malloc_stats_print
370     AC_SEARCH_LIBS([je_malloc_stats_print], [jemalloc], [have_jemalloc=yes], [],
371                    [$PTHREAD_LDFLAGS])
372     LIBS=$LIBS_OLD
373
374     if test "x${have_jemalloc}" = "xyes"; then
375       jemalloc_libs=${ac_cv_search_je_malloc_stats_print}
376     fi
377   fi
378
379   if test "x${have_jemalloc}" = "xyes" &&
380      test "x${jemalloc_libs}" != "xnone required"; then
381     JEMALLOC_LIBS=${jemalloc_libs}
382     AC_SUBST([JEMALLOC_LIBS])
383   fi
384 fi
385
386 if test "x${request_jemalloc}" = "xyes" &&
387    test "x${have_jemalloc}" != "xyes"; then
388   AC_MSG_ERROR([jemalloc was requested (--with-jemalloc) but not found])
389 fi
390
391 # spdylay (for src/nghttpx and src/h2load)
392 have_spdylay=no
393 if test "x${request_spdylay}" != "xno"; then
394   PKG_CHECK_MODULES([LIBSPDYLAY], [libspdylay >= 1.3.2],
395                     [have_spdylay=yes], [have_spdylay=no])
396   if test "x${have_spdylay}" = "xyes"; then
397     AC_DEFINE([HAVE_SPDYLAY], [1], [Define to 1 if you have `spdylay` library.])
398   else
399     AC_MSG_NOTICE($LIBSPDYLAY_PKG_ERRORS)
400     AC_MSG_NOTICE([The SPDY support in nghttpx and h2load will be disabled.])
401   fi
402 fi
403
404 if test "x${request_spdylay}" = "xyes" &&
405    test "x${have_spdylay}" != "xyes"; then
406   AC_MSG_ERROR([spdylay was requested (--with-spdylay) but not found])
407 fi
408
409 AM_CONDITIONAL([HAVE_SPDYLAY], [ test "x${have_spdylay}" = "xyes" ])
410
411 # Check Boost Asio library
412 have_asio_lib=no
413
414 if test "x${request_asio_lib}" = "xyes"; then
415   AX_BOOST_BASE([1.54.0], [have_boost_base=yes], [have_boost_base=no])
416
417   if test "x${have_boost_base}" = "xyes"; then
418     AX_BOOST_ASIO()
419     AX_BOOST_SYSTEM()
420     AX_BOOST_THREAD()
421
422     if test "x${ax_cv_boost_asio}" = "xyes" &&
423        test "x${ax_cv_boost_system}" = "xyes" &&
424        test "x${ax_cv_boost_thread}" = "xyes"; then
425       have_asio_lib=yes
426     fi
427   fi
428 fi
429
430 # The nghttp, nghttpd and nghttpx under src depend on zlib, OpenSSL
431 # and libev
432 enable_app=no
433 if test "x${request_app}" != "xno" &&
434    test "x${have_zlib}" = "xyes" &&
435    test "x${have_openssl}" = "xyes" &&
436    test "x${have_libev}" = "xyes"; then
437   enable_app=yes
438 fi
439
440 if test "x${request_app}" = "xyes" &&
441    test "x${enable_app}" != "xyes"; then
442   AC_MSG_ERROR([applications were requested (--enable-app) but dependencies are not met.])
443 fi
444
445 AM_CONDITIONAL([ENABLE_APP], [ test "x${enable_app}" = "xyes" ])
446
447 enable_hpack_tools=no
448 # HPACK tools requires jansson
449 if test "x${request_hpack_tools}" != "xno" &&
450    test "x${have_jansson}" = "xyes"; then
451   enable_hpack_tools=yes
452 fi
453
454 if test "x${request_hpack_tools}" = "xyes" &&
455    test "x${enable_hpack_tools}" != "xyes"; then
456   AC_MSG_ERROR([HPACK tools were requested (--enable-hpack-tools) but dependencies are not met.])
457 fi
458
459 AM_CONDITIONAL([ENABLE_HPACK_TOOLS], [ test "x${enable_hpack_tools}" = "xyes" ])
460
461 # C++ library libnghttp2_asio
462
463 enable_asio_lib=no
464 if test "x${request_asio_lib}" != "xno" &&
465    test "x${have_asio_lib}" = "xyes"; then
466   enable_asio_lib=yes
467 fi
468
469 AM_CONDITIONAL([ENABLE_ASIO_LIB], [ test "x${enable_asio_lib}" = "xyes" ])
470
471 # The example programs depend on OpenSSL and libevent_openssl
472 enable_examples=no
473 if test "x${request_examples}" != "xno" &&
474    test "x${have_openssl}" = "xyes" &&
475    test "x${have_libevent_openssl}" = "xyes"; then
476   enable_examples=yes
477 fi
478
479 if test "x${request_examples}" = "xyes" &&
480    test "x${enable_examples}" != "xyes"; then
481   AC_MSG_ERROR([examples were requested (--enable-examples) but dependencies are not met.])
482 fi
483
484 AM_CONDITIONAL([ENABLE_EXAMPLES], [ test "x${enable_examples}" = "xyes" ])
485
486 # Python bindings
487 enable_python_bindings=no
488 if test "x${request_python_bindings}" != "xno" &&
489    test "x${CYTHON}" != "x" &&
490    test "x${PYTHON}" != "x:" &&
491    test "x${have_python_dev}" = "xyes"; then
492   enable_python_bindings=yes
493 fi
494
495 if test "x${request_python_bindings}" = "xyes" &&
496    test "x${enable_python_bindings}" != "xyes"; then
497   AC_MSG_ERROR([python bindings were requested (--enable-python-bindings) but dependencies are not met.])
498 fi
499
500 AM_CONDITIONAL([ENABLE_PYTHON_BINDINGS],
501                [test "x${enable_python_bindings}" = "xyes"])
502
503 # Produce cython conditional, so that we can distribute generated C
504 # source
505 AM_CONDITIONAL([HAVE_CYTHON], [test "x${CYTHON}" != "x"])
506
507 # failmalloc tests
508 enable_failmalloc=no
509 if test "x${request_failmalloc}" = "xyes"; then
510   enable_failmalloc=yes
511 fi
512
513 AM_CONDITIONAL([ENABLE_FAILMALLOC], [ test "x${enable_failmalloc}" = "xyes" ])
514
515 # Checks for header files.
516 AC_HEADER_ASSERT
517 AC_CHECK_HEADERS([ \
518   arpa/inet.h \
519   fcntl.h \
520   inttypes.h \
521   limits.h \
522   netdb.h \
523   netinet/in.h \
524   pwd.h \
525   stddef.h \
526   stdint.h \
527   stdlib.h \
528   string.h \
529   sys/socket.h \
530   sys/time.h \
531   syslog.h \
532   time.h \
533   unistd.h \
534 ])
535
536 # Checks for typedefs, structures, and compiler characteristics.
537 AC_TYPE_SIZE_T
538 AC_TYPE_SSIZE_T
539 AC_TYPE_UINT8_T
540 AC_TYPE_UINT16_T
541 AC_TYPE_UINT32_T
542 AC_TYPE_UINT64_T
543 AC_TYPE_INT8_T
544 AC_TYPE_INT16_T
545 AC_TYPE_INT32_T
546 AC_TYPE_INT64_T
547 AC_TYPE_OFF_T
548 AC_TYPE_PID_T
549 AC_TYPE_UID_T
550 AC_CHECK_TYPES([ptrdiff_t])
551 AC_C_BIGENDIAN
552 AC_C_INLINE
553 AC_SYS_LARGEFILE
554
555 AC_CHECK_MEMBER([struct tm.tm_gmtoff], [have_struct_tm_tm_gmtoff=yes],
556                 [have_struct_tm_tm_gmtoff=no], [[#include <time.h>]])
557
558 if test "x$have_struct_tm_tm_gmtoff" = "xyes"; then
559   AC_DEFINE([HAVE_STRUCT_TM_TM_GMTOFF], [1],
560             [Define to 1 if you have `struct tm.tm_gmtoff` member.])
561 fi
562
563 # Check size of pointer to decide we need 8 bytes alignment
564 # adjustment.
565 AC_CHECK_SIZEOF([int *])
566
567 # Checks for library functions.
568 if test "x$cross_compiling" != "xyes"; then
569   AC_FUNC_MALLOC
570 fi
571
572 AC_FUNC_CHOWN
573 AC_FUNC_ERROR_AT_LINE
574 AC_FUNC_FORK
575 # Don't check realloc, since LeakSanitizer detects memory leak during check
576 # AC_FUNC_REALLOC
577 AC_FUNC_STRERROR_R
578 AC_FUNC_STRNLEN
579
580 AC_CHECK_FUNCS([ \
581   _Exit \
582   accept4 \
583   dup2 \
584   getcwd \
585   getpwnam \
586   localtime_r \
587   memchr \
588   memmove \
589   memset \
590   socket \
591   sqrt \
592   strchr \
593   strdup \
594   strerror \
595   strndup \
596   strstr \
597   strtol \
598   strtoul \
599   timegm \
600 ])
601
602 # timerfd_create was added in linux kernel 2.6.25
603
604 AC_CHECK_FUNC([timerfd_create],
605               [have_timerfd_create=yes], [have_timerfd_create=no])
606
607
608 # Checks for epoll availability, primarily for examples/tiny-nghttpd
609 AX_HAVE_EPOLL([have_epoll=yes], [have_epoll=no])
610
611 AM_CONDITIONAL([ENABLE_TINY_NGHTTPD],
612                [ test "x${have_epoll}" = "xyes" &&
613                  test "x${have_timerfd_create}" = "xyes"])
614
615 ac_save_CFLAGS=$CFLAGS
616 CFLAGS=
617
618 if test "x$werror" != "xno"; then
619     AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"])
620     AX_CHECK_COMPILE_FLAG([-Wextra], [CFLAGS="$CFLAGS -Wextra"])
621     AX_CHECK_COMPILE_FLAG([-Werror], [CFLAGS="$CFLAGS -Werror"])
622     AX_CHECK_COMPILE_FLAG([-Wmissing-prototypes], [CFLAGS="$CFLAGS -Wmissing-prototypes"])
623     AX_CHECK_COMPILE_FLAG([-Wstrict-prototypes], [CFLAGS="$CFLAGS -Wstrict-prototypes"])
624     AX_CHECK_COMPILE_FLAG([-Wmissing-declarations], [CFLAGS="$CFLAGS -Wmissing-declarations"])
625     AX_CHECK_COMPILE_FLAG([-Wpointer-arith], [CFLAGS="$CFLAGS -Wpointer-arith"])
626     AX_CHECK_COMPILE_FLAG([-Wdeclaration-after-statement], [CFLAGS="$CFLAGS -Wdeclaration-after-statement"])
627     AX_CHECK_COMPILE_FLAG([-Wformat-security], [CFLAGS="$CFLAGS -Wformat-security"])
628     AX_CHECK_COMPILE_FLAG([-Wwrite-strings], [CFLAGS="$CFLAGS -Wwrite-strings"])
629     AX_CHECK_COMPILE_FLAG([-Wshadow], [CFLAGS="$CFLAGS -Wshadow"])
630     AX_CHECK_COMPILE_FLAG([-Winline], [CFLAGS="$CFLAGS -Winline"])
631     AX_CHECK_COMPILE_FLAG([-Wnested-externs], [CFLAGS="$CFLAGS -Wnested-externs"])
632     AX_CHECK_COMPILE_FLAG([-Wfloat-equal], [CFLAGS="$CFLAGS -Wfloat-equal"])
633     AX_CHECK_COMPILE_FLAG([-Wundef], [CFLAGS="$CFLAGS -Wundef"])
634     AX_CHECK_COMPILE_FLAG([-Wendif-labels], [CFLAGS="$CFLAGS -Wendif-labels"])
635     AX_CHECK_COMPILE_FLAG([-Wempty-body], [CFLAGS="$CFLAGS -Wempty-body"])
636     AX_CHECK_COMPILE_FLAG([-Wcast-align], [CFLAGS="$CFLAGS -Wcast-align"])
637     AX_CHECK_COMPILE_FLAG([-Wclobbered], [CFLAGS="$CFLAGS -Wclobbered"])
638     AX_CHECK_COMPILE_FLAG([-Wvla], [CFLAGS="$CFLAGS -Wvla"])
639     AX_CHECK_COMPILE_FLAG([-Wpragmas], [CFLAGS="$CFLAGS -Wpragmas"])
640     AX_CHECK_COMPILE_FLAG([-Wunreachable-code], [CFLAGS="$CFLAGS -Wunreachable-code"])
641     AX_CHECK_COMPILE_FLAG([-Waddress], [CFLAGS="$CFLAGS -Waddress"])
642     AX_CHECK_COMPILE_FLAG([-Wattributes], [CFLAGS="$CFLAGS -Wattributes"])
643     AX_CHECK_COMPILE_FLAG([-Wdiv-by-zero], [CFLAGS="$CFLAGS -Wdiv-by-zero"])
644     AX_CHECK_COMPILE_FLAG([-Wshorten-64-to-32], [CFLAGS="$CFLAGS -Wshorten-64-to-32"])
645
646     # Only work with Clang for the moment
647     AX_CHECK_COMPILE_FLAG([-Wheader-guard], [CFLAGS="$CFLAGS -Wheader-guard"])
648 fi
649
650 WARNCFLAGS=$CFLAGS
651 CFLAGS=$ac_save_CFLAGS
652
653 AC_SUBST([WARNCFLAGS])
654
655 if test "x$debug" != "xno"; then
656     AC_DEFINE([DEBUGBUILD], [1], [Define to 1 to enable debug output.])
657 fi
658
659 enable_threads=yes
660 # Some platform does not have working std::future.  We disable
661 # threading for those platforms.
662 if test "x$threads" != "xyes" ||
663    test "x$have_std_future" != "xyes"; then
664     enable_threads=no
665     AC_DEFINE([NOTHREADS], [1], [Define to 1 if you want to disable threads.])
666 fi
667
668 AC_SUBST([TESTLDADD])
669 AC_SUBST([APPLDFLAGS])
670
671 AC_CONFIG_FILES([
672   Makefile
673   lib/Makefile
674   lib/libnghttp2.pc
675   lib/includes/Makefile
676   lib/includes/nghttp2/nghttp2ver.h
677   tests/Makefile
678   tests/testdata/Makefile
679   third-party/Makefile
680   src/Makefile
681   src/includes/Makefile
682   src/libnghttp2_asio.pc
683   examples/Makefile
684   python/Makefile
685   python/setup.py
686   integration-tests/Makefile
687   integration-tests/config.go
688   integration-tests/setenv
689   doc/Makefile
690   doc/conf.py
691   doc/index.rst
692   doc/package_README.rst
693   doc/tutorial-client.rst
694   doc/tutorial-server.rst
695   doc/tutorial-hpack.rst
696   doc/nghttpx-howto.rst
697   doc/h2load-howto.rst
698   doc/libnghttp2_asio.rst
699   doc/python-apiref.rst
700   doc/building-android-binary.rst
701   doc/nghttp2.h.rst
702   doc/nghttp2ver.h.rst
703   doc/asio_http2.h.rst
704   doc/asio_http2_server.h.rst
705   doc/asio_http2_client.h.rst
706   doc/contribute.rst
707   contrib/Makefile
708 ])
709 AC_OUTPUT
710
711 AC_MSG_NOTICE([summary of build options:
712
713     Version:        ${VERSION} shared $LT_CURRENT:$LT_REVISION:$LT_AGE
714     Host type:      ${host}
715     Install prefix: ${prefix}
716     C compiler:     ${CC}
717     CFLAGS:         ${CFLAGS}
718     WARNCFLAGS:     ${WARNCFLAGS}
719     LDFLAGS:        ${LDFLAGS}
720     LIBS:           ${LIBS}
721     CPPFLAGS:       ${CPPFLAGS}
722     C preprocessor: ${CPP}
723     C++ compiler:   ${CXX}
724     CXXFLAGS:       ${CXXFLAGS}
725     CXXCPP:         ${CXXCPP}
726     Library types:  Shared=${enable_shared}, Static=${enable_static}
727     Python:
728       Python:         ${PYTHON}
729       PYTHON_VERSION: ${PYTHON_VERSION}
730       pyexecdir:      ${pyexecdir}
731       Python-dev:     ${have_python_dev}
732       PYTHON_CPPFLAGS:${PYTHON_CPPFLAGS}
733       PYTHON_LDFLAGS: ${PYTHON_LDFLAGS}
734       Cython:         ${CYTHON}
735     Test:
736       CUnit:          ${have_cunit}
737       Failmalloc:     ${enable_failmalloc}
738     Libs:
739       OpenSSL:        ${have_openssl}
740       Libxml2:        ${have_libxml2}
741       Libev:          ${have_libev}
742       Libevent(SSL):  ${have_libevent_openssl}
743       Spdylay:        ${have_spdylay}
744       Jansson:        ${have_jansson}
745       Jemalloc:       ${have_jemalloc}
746       Boost CPPFLAGS: ${BOOST_CPPFLAGS}
747       Boost LDFLAGS:  ${BOOST_LDFLAGS}
748       Boost::ASIO:    ${BOOST_ASIO_LIB}
749       Boost::System:  ${BOOST_SYSTEM_LIB}
750       Boost::Thread:  ${BOOST_THREAD_LIB}
751     Features:
752       Applications:   ${enable_app}
753       HPACK tools:    ${enable_hpack_tools}
754       Libnghttp2_asio:${enable_asio_lib}
755       Examples:       ${enable_examples}
756       Python bindings:${enable_python_bindings}
757       Threading:      ${enable_threads}
758 ])