configure.ac (6250B)
1 ## Process this file with autoconf to produce configure. 2 3 AC_INIT([Capn Proto],[0.10-dev],[capnproto@googlegroups.com],[capnproto-c++]) 4 5 AC_CONFIG_SRCDIR([src/capnp/layout.c++]) 6 AC_CONFIG_AUX_DIR([build-aux]) 7 AC_CONFIG_HEADERS([config.h]) 8 AC_CONFIG_MACRO_DIR([m4]) 9 10 # autoconf's default CXXFLAGS are usually "-g -O2". A far more reasonable 11 # default is -O2 -NDEBUG. 12 AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"], 13 [CFLAGS="-O2 -DNDEBUG"]) 14 AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"], 15 [CXXFLAGS="-O2 -DNDEBUG"]) 16 17 AM_INIT_AUTOMAKE([tar-ustar]) 18 19 AC_ARG_WITH([external-capnp], 20 [AS_HELP_STRING([--with-external-capnp], 21 [use the system capnp binary (or the one specified with $CAPNP) instead of compiling a new 22 one (useful for cross-compiling)])], 23 [external_capnp=yes],[external_capnp=no]) 24 25 AC_ARG_WITH([zlib], 26 [AS_HELP_STRING([--with-zlib], 27 [build libkj-gzip by linking against zlib @<:@default=check@:>@])], 28 [],[with_zlib=check]) 29 30 AC_ARG_WITH([openssl], 31 [AS_HELP_STRING([--with-openssl], 32 [build libkj-tls by linking against openssl @<:@default=check@:>@])], 33 [],[with_openssl=check]) 34 35 AC_ARG_ENABLE([reflection], [ 36 AS_HELP_STRING([--disable-reflection], [ 37 compile Cap'n Proto in "lite mode", in which all reflection APIs (schema.h, dynamic.h, etc.) 38 are not included. Produces a smaller library at the cost of features. All programs built 39 against the library MUST be compiled with -DCAPNP_LITE=1. Note that because the compiler 40 itself uses reflection in its implementation, you must also use --with-external-capnp when 41 using this option.]) 42 ], [ 43 case "${enableval}" in 44 yes) 45 lite_mode=no 46 ;; 47 no) 48 lite_mode=yes 49 AS_IF([test "$external_capnp" != "yes"], [ 50 AC_MSG_ERROR([you must specify --with-external-capnp when using --disable-reflection]) 51 ]) 52 ;; 53 *) 54 AC_MSG_ERROR([bad value ${enableval} for --enable-reflection]) 55 ;; 56 esac 57 ], [lite_mode=no]) 58 59 # Checks for programs. 60 AC_PROG_CC 61 AC_PROG_CXX 62 AC_LANG([C++]) 63 AX_CXX_COMPILE_STDCXX_14 64 65 AS_CASE("${host_os}", *mingw*, [ 66 # We don't use pthreads on MinGW. 67 PTHREAD_CFLAGS="-mthreads" 68 PTHREAD_LIBS="" 69 PTHREAD_CC="" 70 ASYNC_LIBS="-lws2_32" 71 AC_SUBST(PTHREAD_LIBS) 72 AC_SUBST(PTHREAD_CFLAGS) 73 AC_SUBST(PTHREAD_CC) 74 AC_SUBST(ASYNC_LIBS) 75 ], *, [ 76 ACX_PTHREAD 77 ASYNC_LIBS="" 78 AC_SUBST(ASYNC_LIBS) 79 ]) 80 81 LT_INIT 82 83 AS_IF([test "$external_capnp" != "no"], [ 84 AS_IF([test "x$CAPNP" = "x"], [CAPNP="capnp"], [with_capnp=yes]) 85 AS_IF([test "x$CAPNPC_CXX" = "x"], [ 86 # CAPNPC_CXX was not specified. Choose a reasonable default. 87 AS_CASE([$CAPNP], [*/*], [ 88 # $CAPNP contains a slash, so it's not on $PATH. Assume capnpc-c++ is not either, but is 89 # in the same directory. 90 CAPNPC_CXX=`dirname $CAPNP`/capnpc-c++ 91 ], [ 92 # $CAPNP is on $PATH, so tell it to find the plugin on $PATH as well. 93 CAPNPC_CXX="c++" 94 ]) 95 ]) 96 AC_SUBST([CAPNP]) 97 AC_SUBST([CAPNPC_CXX]) 98 ]) 99 AM_CONDITIONAL([USE_EXTERNAL_CAPNP], [test "$external_capnp" != "no"]) 100 101 AM_CONDITIONAL([LITE_MODE], [test "$lite_mode" = "yes"]) 102 103 AS_IF([test "$lite_mode" = "yes"], [ 104 CXXFLAGS="-DCAPNP_LITE $CXXFLAGS" 105 CAPNP_LITE_FLAG=-DCAPNP_LITE 106 ]) 107 AC_SUBST([CAPNP_LITE_FLAG]) 108 109 AC_SEARCH_LIBS(sched_yield, rt) 110 111 # Users will need to use the same -stdlib as us so we'd better let pkg-config know about it. 112 STDLIB_FLAG=`echo "$CXX $CXXFLAGS" | grep -o ' [[-]]stdlib=[[^ ]]*'` 113 AC_SUBST([STDLIB_FLAG]) 114 115 LIBS="$PTHREAD_LIBS $LIBS" 116 CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" 117 118 AC_DEFUN([CAPNP_PKG_CONFIG_FILES], [ \ 119 pkgconfig/capnp.pc \ 120 pkgconfig/capnpc.pc \ 121 pkgconfig/capnp-rpc.pc \ 122 pkgconfig/capnp-json.pc \ 123 pkgconfig/capnp-websocket.pc \ 124 pkgconfig/kj.pc \ 125 pkgconfig/kj-async.pc \ 126 pkgconfig/kj-http.pc \ 127 pkgconfig/kj-gzip.pc \ 128 pkgconfig/kj-tls.pc \ 129 pkgconfig/kj-test.pc \ 130 ]) 131 AC_DEFUN([CAPNP_CMAKE_CONFIG_FILES], [ \ 132 cmake/CapnProtoConfig.cmake \ 133 cmake/CapnProtoConfigVersion.cmake \ 134 ]) 135 136 [CAPNP_PKG_CONFIG_FILES]="CAPNP_PKG_CONFIG_FILES" 137 [CAPNP_CMAKE_CONFIG_FILES]="CAPNP_CMAKE_CONFIG_FILES" 138 AC_SUBST([CAPNP_PKG_CONFIG_FILES]) 139 AC_SUBST([CAPNP_CMAKE_CONFIG_FILES]) 140 141 # Don't include security release in soname -- we want to replace old binaries 142 # in this case. 143 SO_VERSION=$(echo $VERSION | sed -e 's/^\([0-9]*[.][0-9]*[.][0-9]*\)\([.][0-9]*\)*\(-.*\)*$/\1\3/g') 144 AC_SUBST([SO_VERSION]) 145 146 # CapnProtoConfig.cmake.in needs these PACKAGE_* output variables. 147 PACKAGE_INIT="set([CAPNP_PKG_CONFIG_FILES] CAPNP_PKG_CONFIG_FILES)" 148 PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR="\${CMAKE_CURRENT_LIST_DIR}/../../../include" 149 AC_SUBST([PACKAGE_INIT]) 150 AC_SUBST([PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR]) 151 152 # CapnProtoConfigVersion.cmake.in needs PACKAGE_VERSION (already defined by AC_INIT) and 153 # CMAKE_SIZEOF_VOID_P output variables. 154 AC_CHECK_SIZEOF([void *]) 155 AC_SUBST(CMAKE_SIZEOF_VOID_P, $ac_cv_sizeof_void_p) 156 157 # Detect presence of zlib, if it was not specified explicitly. 158 AS_IF([test "$with_zlib" = check], [ 159 AC_CHECK_LIB(z, deflate, [:], [ 160 with_zlib=no 161 ]) 162 AC_CHECK_HEADER([zlib.h], [:], [ 163 with_zlib=no 164 ]) 165 AS_IF([test "$with_zlib" = no], [ 166 AC_MSG_WARN("could not find zlib -- won't build libkj-gzip") 167 ], [ 168 with_zlib=yes 169 ]) 170 ]) 171 AS_IF([test "$with_zlib" != no], [ 172 CXXFLAGS="$CXXFLAGS -DKJ_HAS_ZLIB" 173 ]) 174 AM_CONDITIONAL([BUILD_KJ_GZIP], [test "$with_zlib" != no]) 175 176 # Detect presence of OpenSSL, if it was not specified explicitly. 177 AS_IF([test "$with_openssl" = check], [ 178 AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [:], [ 179 with_openssl=no 180 ]) 181 AC_CHECK_LIB(ssl, OPENSSL_init_ssl, [:], [ 182 with_openssl=no 183 ], [-lcrypto]) 184 AC_CHECK_HEADER([openssl/ssl.h], [:], [ 185 with_openssl=no 186 ]) 187 AS_IF([test "$with_openssl" = no], [ 188 AC_MSG_WARN("could not find OpenSSL -- won't build libkj-tls") 189 ], [ 190 with_openssl=yes 191 ]) 192 ]) 193 AS_IF([test "$with_openssl" != no], [ 194 CXXFLAGS="$CXXFLAGS -DKJ_HAS_OPENSSL" 195 ]) 196 AM_CONDITIONAL([BUILD_KJ_TLS], [test "$with_openssl" != no]) 197 198 # CapnProtoConfig.cmake.in needs this variable. 199 AC_SUBST(WITH_OPENSSL, $with_openssl) 200 201 AM_CONDITIONAL([HAS_FUZZING_ENGINE], [test "x$LIB_FUZZING_ENGINE" != "x"]) 202 203 AC_CONFIG_FILES([Makefile] CAPNP_PKG_CONFIG_FILES CAPNP_CMAKE_CONFIG_FILES) 204 AC_OUTPUT