blob: 0e05e66445c8aa05905c69e67fb3bd3076001bba [file] [log] [blame]
Jeff Thompson18f43e12013-11-21 12:45:12 -08001# To build using autotools, see the Development section of the file INSTALL.
Jeff Thompsonb7523002013-10-09 10:25:00 -07002
Jeff Thompsonff092f52013-06-19 13:38:12 -07003AC_PREREQ([2.59])
Yingdi Yu61ec2722014-01-20 14:22:32 -08004AC_INIT([ndn-cpp-dev], [0.2.1], [ndn-lib@lists.cs.ucla.edu], [ndn-cpp-dev], [https://github.com/named-data/ndn-cpp])
Jeff Thompsonff092f52013-06-19 13:38:12 -07005AM_INIT_AUTOMAKE([1.10 -Wall no-define foreign])
6
Jeff Thompson23cb7422013-10-09 16:11:47 -07007AC_CONFIG_MACRO_DIR([m4])
Jeff Thompson5d16a902013-10-10 11:15:14 -07008AC_CONFIG_SRCDIR([configure.ac])
Jeff Thompson6e229042013-10-10 11:09:49 -07009# Create config.h without prefixes. Put it in the include directory so CFLAGS will have -I./include .
10AC_CONFIG_HEADERS(include/config.h)
11# Add prefixes and output to a unique file name which will go into the ndn-cpp include install directory.
Yingdi Yu61ec2722014-01-20 14:22:32 -080012AX_PREFIX_CONFIG_H(include/ndn-cpp-dev/ndn-cpp-config.h, ndn-cpp)
Jeff Thompson47053ad2013-08-05 10:36:53 -070013AM_MAINTAINER_MODE
Jeff Thompson3b3aabf2013-06-21 16:50:20 -070014AM_PROG_AR
Jeff Thompson4f031642013-08-05 11:03:16 -070015AC_PROG_LIBTOOL
Jeff Thompson23cb7422013-10-09 16:11:47 -070016LT_PREREQ([2.2])
17LT_INIT()
Jeff Thompson4f031642013-08-05 11:03:16 -070018AC_PROG_CXX
Jeff Thompson1a1b4c02013-06-28 22:28:51 -070019AM_PROG_CC_C_O
Jeff Thompsonfcc4daa2013-10-01 14:52:23 -070020AC_PROG_OBJCXX
Jeff Thompsonff092f52013-06-19 13:38:12 -070021AC_LANG([C++])
Jeff Thompsonb18b6eb2013-10-11 18:28:50 -070022
23# Special case.
24case "$host" in
25 *-darwin* | *-macos10*)
26 if test -d /opt/local ; then
27 CFLAGS="$CFLAGS -I/opt/local/include"
28 CXXFLAGS="$CXXFLAGS -I/opt/local/include"
29 CPPFLAGS="$CPPFLAGS -I/opt/local/include"
30 LDFLAGS="$LDFLAGS -L/opt/local/lib"
31 elif test -d /sw ; then
32 CFLAGS="$CFLAGS -I/sw/include"
33 CXXFLAGS="$CXXFLAGS -I/sw/include"
34 CPPFLAGS="$CPPFLAGS -I/sw/include"
35 LDFLAGS="$LDFLAGS -L/sw/lib"
36 fi
37 ;;
38esac
39
Jeff Thompson32a23332013-10-07 18:39:00 -070040AC_TYPE_SIZE_T
41AC_TYPE_INT8_T
42AC_TYPE_INT16_T
43AC_TYPE_INT32_T
44AC_TYPE_INT64_T
45AC_TYPE_UINT8_T
46AC_TYPE_UINT16_T
47AC_TYPE_UINT32_T
48AC_TYPE_UINT64_T
Jeff Thompsonea946202013-10-18 14:35:32 -070049AC_CHECK_FUNCS([memcmp] [memcpy] [memset])
50AC_CHECK_FUNCS([strchr], :, AC_MSG_ERROR([*** strchr not found. Check 'config.log' for more details.]))
51AC_CHECK_FUNCS([sscanf], :, AC_MSG_ERROR([*** sscanf not found. Check 'config.log' for more details.]))
Jeff Thompsond32bab62013-10-18 14:55:26 -070052AC_CHECK_HEADERS([time.h], :, AC_MSG_ERROR([*** time.h not found. Check 'config.log' for more details.]))
Jeff Thompsonea946202013-10-18 14:35:32 -070053AC_CHECK_HEADERS([sys/time.h], :, AC_MSG_ERROR([*** sys/time.h not found. Check 'config.log' for more details.]))
54AC_CHECK_FUNCS([gettimeofday], :, AC_MSG_ERROR([*** gettimeofday not found. processEvents requires it. Check 'config.log' for more details.]))
Jeff Thompson6e229042013-10-10 11:09:49 -070055AC_C_INLINE
Jeff Thompsonff092f52013-06-19 13:38:12 -070056
Alexander Afanasyev9e92bfd2014-01-24 12:23:33 -080057# Unless --with-c++11 specified, do not enable C++11 features
Alexander Afanasyev0541cf42014-01-02 19:10:37 -080058AX_CXX_COMPILE_STDCXX_11(, optional)
Jeff Thompsonff092f52013-06-19 13:38:12 -070059
Alexander Afanasyev0541cf42014-01-02 19:10:37 -080060AC_ARG_WITH([system-boost],
61 AS_HELP_STRING(
Alexander Afanasyev9e92bfd2014-01-24 12:23:33 -080062 [--without-system-boost],
63 [do not attempt to use system-installed boost libraries and use the bundled version (ndnboost) when necessary.]
Alexander Afanasyev0541cf42014-01-02 19:10:37 -080064 ),
Alexander Afanasyev9e92bfd2014-01-24 12:23:33 -080065 [
66 if test "$withval" = "no"; then
67 want_system_boost="no"
68 fi
69 ],
70 [want_system_boost="yes"]
Alexander Afanasyev0541cf42014-01-02 19:10:37 -080071)
72
73AX_BOOST_BASE([1.42.0],
74 [
75 if test "$want_system_boost" == "yes" ; then
76 AC_DEFINE(USE_SYSTEM_BOOST,[1],[use system-installed boost libraries])
Alexander Afanasyevf7f878c2014-01-12 13:57:56 -080077 AM_CONDITIONAL(USE_SYSTEM_BOOST, true)
78 else
79 AM_CONDITIONAL(USE_SYSTEM_BOOST, false)
Alexander Afanasyev0541cf42014-01-02 19:10:37 -080080 fi
81 ],
Alexander Afanasyevf7f878c2014-01-12 13:57:56 -080082 [AM_CONDITIONAL(USE_SYSTEM_BOOST, false)]
Alexander Afanasyev0541cf42014-01-02 19:10:37 -080083)
Alexander Afanasyevfad679c2014-01-06 18:09:26 -080084AX_BOOST_ASIO
85
86AC_ARG_WITH([tests],
87 AS_HELP_STRING(
88 [--with-tests],
89 [Enable compilation of library tests (disabled by default).]
90 ),
91 [
92 want_tests="yes"
93 AM_CONDITIONAL(COMPILE_TESTS, true)
94 ],
95 [
96 want_tests="no"
97 AM_CONDITIONAL(COMPILE_TESTS, false)
98 ]
99)
100
Alexander Afanasyev9e92bfd2014-01-24 12:23:33 -0800101# @todo: These checks are not really optional
Alexander Afanasyevfad679c2014-01-06 18:09:26 -0800102AX_BOOST_SYSTEM
Yingdi Yu2d9c50f2014-01-21 18:25:00 -0800103AX_BOOST_FILESYSTEM
Alexander Afanasyevfad679c2014-01-06 18:09:26 -0800104AX_BOOST_UNIT_TEST_FRAMEWORK
105AM_CONDITIONAL(HAVE_BOOST_UNIT_TEST_FRAMEWORK, [test "x$ax_cv_boost_unit_test_framework" = "xyes"])
Jeff Thompsona28eed82013-08-22 16:21:10 -0700106
Jeff Thompsonea946202013-10-18 14:35:32 -0700107AC_MSG_CHECKING([for gmtime support])
108AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Jeff Thompsond32bab62013-10-18 14:55:26 -0700109 [[#include <time.h>]]
Jeff Thompsonea946202013-10-18 14:35:32 -0700110 [[#include <sys/time.h>]]
111 [[struct timeval tv;]]
112 [[int result1 = gettimeofday(&tv, 0);]]
113 [[time_t time1 = time(0);]]
114 [[struct tm* tm1 = gmtime(&time1);]]
115 [[time_t time2 = timegm(tm1);]])
116], [
117 AC_MSG_RESULT([yes])
118 AC_DEFINE_UNQUOTED([HAVE_GMTIME_SUPPORT], 1, [1 if have sys/time gmtime support including timegm.])
119], [
120 AC_MSG_RESULT([no])
121 AC_DEFINE_UNQUOTED([HAVE_GMTIME_SUPPORT], 0, [1 if have sys/time gmtime support including timegm.])
122])
123
Alexander Afanasyev0d3671a2014-01-02 20:09:59 -0800124# Require openssl (libcrypto).
125AX_CHECK_OPENSSL([], [AC_MSG_FAILURE([can't find openssl crypto lib])])
Jeff Thompsond0f62e12013-10-09 17:41:25 -0700126
Alexander Afanasyevc5bb2ad2014-01-06 16:03:34 -0800127AX_LIB_CRYPTOPP([], [AC_MSG_FAILURE([can't find crypto++ library])])
128
Jeff Thompsonbb6b5682013-10-09 18:22:38 -0700129# Conditionally use libsqlite3. AX_LIB_SQLITE3 defines HAVE_SQLITE3 in confdefs.h .
Jeff Thompsond0f62e12013-10-09 17:41:25 -0700130AX_LIB_SQLITE3()
Jeff Thompsonbb6b5682013-10-09 18:22:38 -0700131if grep -q "#define HAVE_SQLITE3" confdefs.h ; then
Alexander Afanasyev0d3671a2014-01-02 20:09:59 -0800132 AC_CHECK_LIB([sqlite3], [sqlite3_open], [ ], # space necessar to prevent updating LIBS
Jeff Thompsonf21e2242013-10-09 19:01:49 -0700133 [AC_MSG_FAILURE([have sqlite2 headers but no libsqlite3])])
Alexander Afanasyev38403b72014-01-24 12:44:27 -0800134else
135 AC_MSG_ERROR(Missing required libsqlite3 library)
Jeff Thompsond0f62e12013-10-09 17:41:25 -0700136fi
137
Alexander Afanasyev38403b72014-01-24 12:44:27 -0800138
Jeff Thompsonf21e2242013-10-09 19:01:49 -0700139# Conditionally use the OSX Security framework .
140AC_MSG_CHECKING([for OSX Security framework])
Jeff Thompson9cf9dfb2013-10-04 16:36:52 -0700141AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
142 [[#include <CoreFoundation/CoreFoundation.h>]]
143 [[#include <Security/Security.h>]]
144 [[#include <CoreServices/CoreServices.h>]]
145 [[void test() { SecKeychainRef x; }]])
146], [
147 AC_MSG_RESULT([yes])
Alexander Afanasyev0d3671a2014-01-02 20:09:59 -0800148 AC_DEFINE_UNQUOTED([HAVE_OSX_SECURITY], 1, [1 if have the OSX framework.])
Alexander Afanasyevd155da42014-01-06 16:03:47 -0800149 AM_CONDITIONAL(HAVE_OSX_SECURITY, true)
Alexander Afanasyev0d3671a2014-01-02 20:09:59 -0800150
151 OSX_SECURITY_LIBS="-framework Security"
152 AC_SUBST([OSX_SECURITY_LIBS])
Jeff Thompson9cf9dfb2013-10-04 16:36:52 -0700153], [
154 AC_MSG_RESULT([no])
Alexander Afanasyevd155da42014-01-06 16:03:47 -0800155 AM_CONDITIONAL(HAVE_OSX_SECURITY, false)
Jeff Thompson9cf9dfb2013-10-04 16:36:52 -0700156])
157
Jeff Thompsonca45e552013-06-26 17:40:06 -0700158DX_HTML_FEATURE(ON)
159DX_CHM_FEATURE(OFF)
160DX_CHI_FEATURE(OFF)
161DX_MAN_FEATURE(OFF)
162DX_RTF_FEATURE(OFF)
163DX_XML_FEATURE(OFF)
164DX_PDF_FEATURE(OFF)
165DX_PS_FEATURE(OFF)
166DX_INIT_DOXYGEN([$PACKAGE_NAME],[Doxyfile])
167
Jeff Thompson6e229042013-10-10 11:09:49 -0700168AC_CONFIG_FILES([Makefile
Alexander Afanasyev7eb64f12014-01-02 18:39:49 -0800169 include/Makefile
Alexander Afanasyevc4b75982014-01-09 14:51:45 -0800170 examples/Makefile
Alexander Afanasyev303b3502014-01-07 12:02:59 -0800171 tools/Makefile
Alexander Afanasyevfad679c2014-01-06 18:09:26 -0800172 tests/Makefile
Alexander Afanasyev06e9d252014-01-18 16:52:18 -0800173 tests_boost/Makefile
174 libndn-cpp-dev.pc])
Jeff Thompsonff092f52013-06-19 13:38:12 -0700175AC_OUTPUT