configure.ac 1.95 KB
Newer Older
Kenton Varda's avatar
Kenton Varda committed
1 2
## Process this file with autoconf to produce configure.

3
AC_INIT([Capn Proto],[0.4-dev],[capnproto@googlegroups.com],[capnproto-c++])
Kenton Varda's avatar
Kenton Varda committed
4

5
AC_CONFIG_SRCDIR([src/capnp/layout.c++])
Kenton Varda's avatar
Kenton Varda committed
6 7 8 9 10 11 12 13 14 15 16
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])

# autoconf's default CXXFLAGS are usually "-g -O2".  A far more reasonable
# default is -O2 -NDEBUG.
AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"],
      [CFLAGS="-O2 -DNDEBUG"])
AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
      [CXXFLAGS="-O2 -DNDEBUG"])

17
AM_INIT_AUTOMAKE([tar-ustar])
Kenton Varda's avatar
Kenton Varda committed
18

19 20 21 22 23 24
AC_ARG_WITH([external-capnp],
  [AS_HELP_STRING([--with-external-capnp],
    [use the system capnp binary (or the one specified with $CAPNP) instead of compiling a new
     one (useful for cross-compiling)])],
  [external_capnp=yes],[external_capnp=no])

Kenton Varda's avatar
Kenton Varda committed
25 26 27 28
# Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_LANG([C++])
29
AX_CXX_COMPILE_STDCXX_11
Kenton Varda's avatar
Kenton Varda committed
30
ACX_PTHREAD
31
AC_PROG_LIBTOOL
Kenton Varda's avatar
Kenton Varda committed
32

33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
AS_IF([test "$external_capnp" != "no"], [
	AS_IF([test "x$CAPNP" = "x"], [CAPNP="capnp"], [with_capnp=yes])
	AS_IF([test "x$CAPNPC_CXX" = "x"], [
	  # CAPNPC_CXX was not specified.  Choose a reasonable default.
	  AS_CASE([$CAPNP], [*/*], [
	    # $CAPNP contains a slash, so it's not on $PATH.  Assume capnpc-c++ is not either, but is
	    # in the same directory.
	    CAPNPC_CXX=`dirname $CAPNP`/capnpc-c++
	  ], [
	    # $CAPNP is on $PATH, so tell it to find the plugin on $PATH as well.
	    CAPNPC_CXX="c++"
	  ])
	])
	AC_SUBST([CAPNP])
	AC_SUBST([CAPNPC_CXX])
])
AM_CONDITIONAL([USE_EXTERNAL_CAPNP], [test "$external_capnp" != "no"])

Kenton Varda's avatar
Kenton Varda committed
51
LIBS="$PTHREAD_LIBS $LIBS"
52
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
Kenton Varda's avatar
Kenton Varda committed
53

54
# AX_CXX_COMPILE_STDCXX_11 may have modified CXX, and we need gtest to use these modifications as
55 56 57
# well (especially -stdlib).  Note that this may cause ac_configure_args to contain CXX= twice, but
# the latter one should override the former.
ac_configure_args="$ac_configure_args 'CXX=$CXX'"
58 59
AC_CONFIG_SUBDIRS([gtest])

Kenton Varda's avatar
Kenton Varda committed
60 61
AC_CONFIG_FILES([Makefile])
AC_OUTPUT