configure.ac 7.1 KB
Newer Older
Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
dnl Spdylay - SPDY Library

dnl Copyright (c) 2012 Tatsuhiro Tsujikawa

dnl Permission is hereby granted, free of charge, to any person obtaining
dnl a copy of this software and associated documentation files (the
dnl "Software"), to deal in the Software without restriction, including
dnl without limitation the rights to use, copy, modify, merge, publish,
dnl distribute, sublicense, and/or sell copies of the Software, and to
dnl permit persons to whom the Software is furnished to do so, subject to
dnl the following conditions:

dnl The above copyright notice and this permission notice shall be
dnl included in all copies or substantial portions of the Software.

dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
dnl EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
dnl NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
dnl LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
dnl OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
dnl WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AC_PREREQ(2.61)
24
AC_INIT([spdylay], [0.3.2], [t-tujikawa@users.sourceforge.net])
25 26
LT_PREREQ([2.2.6])
LT_INIT()
Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
27 28
dnl See versioning rule:
dnl  http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
29
AC_SUBST(LT_CURRENT, 2)
30
AC_SUBST(LT_REVISION, 1)
31
AC_SUBST(LT_AGE, 1)
Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
32

33 34 35 36
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET

Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
37 38 39 40 41
AC_CONFIG_MACRO_DIR([m4])

AM_INIT_AUTOMAKE()
AC_CONFIG_HEADERS([config.h])

42 43 44 45 46 47
dnl Checks for command-line options
AC_ARG_ENABLE([maintainer-mode],
    [AS_HELP_STRING([--enable-maintainer-mode],
                    [Turn on compile time warnings])],
    [maintainer_mode=$withval], [maintainer_mode=no])

Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
48 49
dnl Checks for programs
AC_PROG_CC
50
AC_PROG_CXX
Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
51 52 53
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
54
PKG_PROG_PKG_CONFIG([0.20])
Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
55

56 57 58 59
AC_COMPILE_STDCXX_11
AM_CONDITIONAL([HAVE_STDCXX_11],
               [ test "x$ac_cv_cxx_compile_cxx11_cxx" = "xyes" ])

Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
60
# Checks for libraries.
61

62 63 64 65
# Search for dlsym function, which is used in tests. Linux needs -ldl,
# but netbsd does not need it.
AC_SEARCH_LIBS([dlsym], [dl])

66
# zlib
67
PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.3])
68 69
LIBS="$ZLIB_LIBS $LIBS"
CFLAGS="$CFLAGS $ZLIB_CFLAGS"
70

71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
# cunit
PKG_CHECK_MODULES([CUNIT], [cunit >= 2.1], [have_cunit=yes], [have_cunit=no])
# If pkg-config does not find cunit, check it using AC_CHECK_LIB.  We
# do this because Debian (Ubuntu) lacks pkg-config file for cunit.
if test "x${have_cunit}" = "xno"; then
  AC_MSG_WARN([${CUNIT_PKG_ERRORS}])
  AC_CHECK_LIB([cunit], [CU_initialize_registry],
               [have_cunit=yes], [have_cunit=no])
  if test "x${have_cunit}" = "xyes"; then
    CUNIT_LIBS="-lcunit"
    CUNIT_CFLAGS=""
    AC_SUBST([CUNIT_LIBS])
    AC_SUBST([CUNIT_CFLAGS])
  fi
fi
86
if test "x${have_cunit}" = "xyes"; then
87 88 89 90 91 92 93 94 95
  # cunit in Mac OS X requires ncurses. Note that in Mac OS X, test
  # program can be built without -lncurses, but it emits runtime
  # error.
  case "${build}" in
    *-apple-darwin*)
      CUNIT_LIBS="$CUNIT_LIBS -lncurses"
      AC_SUBST([CUNIT_LIBS])
      ;;
  esac
96 97
fi

Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
98 99
AM_CONDITIONAL([HAVE_CUNIT], [ test "x${have_cunit}" = "xyes" ])

100
# openssl (for examples)
101 102 103 104 105 106 107
PKG_CHECK_MODULES([OPENSSL], [openssl >= 1.0.1],
                  [have_openssl=yes], [have_openssl=no])
if test "x${have_openssl}" = "xno"; then
  AC_MSG_NOTICE($OPENSSL_PKG_ERRORS)
  AC_MSG_NOTICE([The example programs will not be built.])
fi

108
# libevent_openssl
109 110
# 2.0.8 is required because we use evconnlistener_set_error_cb()
PKG_CHECK_MODULES([LIBEVENT_OPENSSL], [libevent_openssl >= 2.0.8],
111 112 113 114 115
                  [have_libevent_openssl=yes], [have_libevent_openssl=no])
if test "x${have_libevent_openssl}" = "xno"; then
  AC_MSG_NOTICE($LIBEVENT_OPENSSL_PKG_ERRORS)
  AC_MSG_NOTICE([Shrpx example program will not be built.])
fi
116 117
AM_CONDITIONAL([HAVE_LIBEVENT_OPENSSL],
               [ test "x${have_libevent_openssl}" = "xyes" ])
118

119
# libxml2 (for examples/spdycat)
120
AM_PATH_XML2(2.7.7, [have_libxml2=yes], [have_libxml2=no])
121 122 123 124 125
if test "x${have_libxml2}" = "xyes"; then
  AC_DEFINE([HAVE_LIBXML2], [1], [Define to 1 if you have `libxml2` library.])
fi
AM_CONDITIONAL([HAVE_LIBXML2], [ test "x${have_libxml2}" = "xyes" ])

126 127 128
# The example programs depend on OpenSSL
enable_examples=$have_openssl
AM_CONDITIONAL([ENABLE_EXAMPLES], [ test "x${enable_examples}" = "xyes" ])
129

Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
130 131 132
# Checks for header files.
AC_CHECK_HEADERS([ \
  arpa/inet.h \
133
  netinet/in.h \
134
  pwd.h \
Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
135 136 137 138
  stddef.h \
  stdint.h \
  stdlib.h \
  string.h \
139
  time.h \
Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
140 141 142 143 144 145 146 147 148 149 150 151 152 153
  unistd.h \
])

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_CHECK_TYPES([ptrdiff_t])
AC_C_BIGENDIAN

# Checks for library functions.
154 155 156
if test "x$cross_compiling" != "xyes"; then
  AC_FUNC_MALLOC
fi
Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
157
AC_CHECK_FUNCS([ \
158
  getpwnam \
Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
159 160 161 162
  memmove \
  memset \
])

163 164 165 166 167 168 169 170 171
AX_HAVE_EPOLL([have_epoll=yes], [have_epoll=no])
if test "x${have_epoll}" = "xyes"; then
  AC_DEFINE([HAVE_EPOLL], [1], [Define to 1 if you have the `epoll`.])
fi
AM_CONDITIONAL([HAVE_EPOLL], [ test "x${have_epoll}" = "xyes" ])

AC_CHECK_FUNCS([kqueue], [have_kqueue=yes])
AM_CONDITIONAL([HAVE_KQUEUE], [test "x${have_kqueue}" = "xyes"])

172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
AC_MSG_CHECKING([whether struct kevent.udata is intptr_t])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
]],
[[
struct kevent event;
event.udata = (intptr_t*)(&event);
]])],
[kevent_udata_intptr_t=yes], [kevent_udata_intptr_t=no])
AC_MSG_RESULT([$kevent_udata_intptr_t])
if test "x$kevent_udata_intptr_t" = "xyes"; then
  AC_DEFINE([KEVENT_UDATA_INTPTR_T], [1],
            [Define to 1 if struct kevent.udata is intptr_t])
fi

189 190 191 192 193 194 195 196 197 198 199 200
if test "x$maintainer_mode" != "xno"; then
    CFLAGS="$CFLAGS -Wall -Wextra -Werror"
    CFLAGS="$CFLAGS -Wmissing-prototypes -Wstrict-prototypes"
    CFLAGS="$CFLAGS -Wmissing-declarations -Wpointer-arith"
    CFLAGS="$CFLAGS -Wdeclaration-after-statement"
    CFLAGS="$CFLAGS -Wformat-security"
    CFLAGS="$CFLAGS -Wwrite-strings -Wshadow -Winline -Wnested-externs"
    CFLAGS="$CFLAGS -Wfloat-equal -Wundef -Wendif-labels -Wempty-body"
    CFLAGS="$CFLAGS -Wcast-align -Wclobbered -Wvla"
    CFLAGS="$CFLAGS -Wno-unused-parameter"
fi

Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
201 202 203 204 205 206 207
AC_CONFIG_FILES([
  Makefile
  lib/Makefile
  lib/libspdylay.pc
  lib/includes/Makefile
  lib/includes/spdylay/spdylayver.h
  tests/Makefile
Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
208
  tests/testdata/Makefile
209
  examples/Makefile
210 211
  doc/Makefile
  doc/conf.py
Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
212 213 214 215 216
])
AC_OUTPUT

AC_MSG_NOTICE([summary of build options:

Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
217
    Version:        ${VERSION} shared $LT_CURRENT:$LT_REVISION:$LT_AGE
Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
218 219 220
    Host type:      ${host}
    Install prefix: ${prefix}
    C compiler:     ${CC}
221 222 223 224 225 226 227 228
    CFLAGS:         ${CFLAGS}
    LDFLAGS:        ${LDFLAGS}
    LIBS:           ${LIBS}
    CPPFLAGS:       ${CPPFLAGS}
    C preprocessor: ${CPP}
    C++ compiler:   ${CXX}
    CXXFLAGS:       ${CXXFLAGS}
    CXXCPP:         ${CXXCPP}
Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
229 230
    Library types:  Shared=${enable_shared}, Static=${enable_static}
    CUnit:          ${have_cunit}
231
    OpenSSL:        ${have_openssl}
232
    Libxml2:        ${have_libxml2}
233
    Libevent(SSL):  ${have_libevent_openssl}
234
    Examples:       ${enable_examples}
Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
235
])