1dnl define macros 2m4_define([opendht_major_version], 1) 3m4_define([opendht_minor_version], 10) 4m4_define([opendht_patch_version], 1) 5m4_define([opendht_version], 6 [opendht_major_version.opendht_minor_version.opendht_patch_version]) 7 8AC_INIT(opendht, [opendht_version]) 9AC_CONFIG_AUX_DIR(ac) 10AM_INIT_AUTOMAKE([foreign subdir-objects]) 11AC_CONFIG_HEADERS([config.h]) 12AC_CONFIG_MACRO_DIR([m4]) 13AC_CANONICAL_HOST 14 15AC_SUBST(OPENDHT_MAJOR_VERSION, opendht_major_version) 16AC_SUBST(OPENDHT_MINOR_VERSION, opendht_minor_version) 17AC_SUBST(OPENDHT_PATCH_VERSION, opendht_patch_version) 18 19AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Build in debug mode, adds stricter warnings, disables optimization])) 20AS_IF([test "x$enable_debug" = "xyes"], 21 [CXXFLAGS="${CXXFLAGS} -g -Wno-return-type -Wall -Wextra -Wnon-virtual-dtor -O0 -pedantic-errors"], 22 [CXXFLAGS="${CXXFLAGS} -O3 -pedantic-errors"]) 23 24AC_PROG_CXX 25AM_PROG_AR 26 27dnl Check for logs 28AC_ARG_ENABLE([logs], [AS_HELP_STRING([--disable-logs], [Disable DHT logs])]) 29AS_IF([test "x$enable_logs" != "xno"], [ 30 AC_DEFINE([OPENDHT_LOG], [true], [Define if DHT logs are enabled]) 31], [ 32 AC_DEFINE([OPENDHT_LOG], [false], [Define if DHT logs are enabled]) 33]) 34 35dnl Check for indexation 36AC_ARG_ENABLE([indexation], [AS_HELP_STRING([--disable-indexation], [Disable DHT indexation])]) 37AM_CONDITIONAL(ENABLE_INDEXATION, test x$enable_indexation != "xno") 38AS_IF([test "x$enable_indexation" != "xno"], [ 39 AC_DEFINE([OPENDHT_INDEXATION], [1], [Define if DHT indexation is enabled]) 40]) 41 42dnl Check for Doxygen 43AC_ARG_ENABLE([doc], AS_HELP_STRING([--enable-doc], [Enable documentation generation (doxygen)])) 44AS_IF([test "x$enable_doc" = "xyes"], [ 45 AC_CHECK_PROGS([DOXYGEN], [doxygen]) 46 AS_IF([test -z "$DOXYGEN"], [AC_MSG_WARN([Doxygen not found - continuing without Doxygen support])]) 47]) 48AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"]) 49 50dnl Check for Python 51AC_ARG_ENABLE([python], [AS_HELP_STRING([--disable-python], [Disble python binding])]) 52AS_IF([test "x$enable_python" != "xno"], [ 53 AM_PATH_PYTHON([3.3],, [:]) 54 AS_IF([test -n "$PYTHON"],[ 55 echo 'import Cython' | $PYTHON 56 AS_IF([test $? == 0],[CYTHON=yes],[AC_MSG_WARN([Cython not found - continuing without python support])]) 57 AC_CHECK_PROGS([PIP], [pip3]) 58 AS_IF([test -z "$PIP"],[AC_MSG_WARN([pip not found - continuing without python uninstall support])]) 59 ]) 60 ]) 61AM_CONDITIONAL([USE_CYTHON], [test -n "$CYTHON"]) 62AM_CONDITIONAL([HAVE_PIP], [test -n "$PIP"]) 63 64case "${host_os}" in 65 "") 66 SYS=unknown 67 ;; 68 *android*) 69 SYS=android 70 ;; 71 linux*) 72 SYS=linux 73 ;; 74 darwin*) 75 SYS=darwin 76 ;; 77 mingw32*) 78 SYS=mingw32 79 WIN32=1 80 AC_DEFINE([_POSIX_SOURCE], [1], [IEEE Std 1003.1.]) 81 AC_DEFINE([_POSIX_C_SOURCE], [200809L], [IEEE Std 1003.1.]) 82 AC_DEFINE([_XOPEN_SOURCE], [700], [POSIX and XPG 7th edition]) 83 AC_DEFINE([_XOPEN_SOURCE_EXTENDED], [1], [XPG things and X/Open Unix extensions.]) 84 AC_DEFINE([_BSD_SOURCE], [1], [ISO C, POSIX, and 4.3BSD things.]) 85 LDFLAGS="${LDFLAGS} -lws2_32" 86 AC_SUBST(WINDOWS_ARCH) 87 AC_SUBST(PROGRAMFILES) 88 ;; 89 *) 90 SYS="${host_os}" 91 ;; 92esac 93 94AM_CONDITIONAL(WIN32, [test "x$SYS" = "xmingw32"]) 95AS_IF([test "x$SYS" = "xandroid"], 96 [], [LDFLAGS="${LDFLAGS} -lpthread"]) 97 98LT_INIT() 99LT_LANG(C++) 100 101AX_CXX_COMPILE_STDCXX(11,[noext],[mandatory]) 102 103PKG_PROG_PKG_CONFIG() 104 105AC_ARG_ENABLE([proxy_server], AS_HELP_STRING([--enable-proxy-server], [Enable proxy server ability]), proxy_server=yes, proxy_server=no) 106AM_CONDITIONAL(ENABLE_PROXY_SERVER, test x$proxy_server == xyes) 107 108AC_ARG_ENABLE([push_notifications], AS_HELP_STRING([--enable-push-notifications], [Enable push notifications support]), push_notifications=yes, push_notifications=no) 109AM_CONDITIONAL(ENABLE_PUSH_NOTIFICATIONS, test x$push_notifications == xyes) 110 111AC_ARG_ENABLE([proxy_server_identity], AS_HELP_STRING([--enable-proxy-server-identity], 112 [Enable proxy server ability]), proxy_server_identity=yes, proxy_server_identity=no) 113AM_CONDITIONAL(ENABLE_PROXY_SERVER_IDENTITY, test x$proxy_server_identity == xyes -a x$proxy_server == xyes) 114AC_ARG_ENABLE([proxy_server_identity], AS_HELP_STRING([--enable-proxy-server-identity], 115 [Enable proxy server ability]), proxy_server_identity=yes, proxy_server_identity=no) 116 117AC_ARG_ENABLE([proxy_client], AS_HELP_STRING([--enable-proxy-client], [Enable proxy client ability]), proxy_client=yes, proxy_client=no) 118AM_CONDITIONAL(ENABLE_PROXY_CLIENT, test x$proxy_client == xyes) 119 120AC_ARG_ENABLE([tests], AS_HELP_STRING([--enable-tests], [Enable tests]), build_tests=yes, build_tests=no) 121AM_CONDITIONAL(ENABLE_TESTS, test x$build_tests == xyes) 122AM_COND_IF([ENABLE_TESTS], [ 123 PKG_CHECK_MODULES([CppUnit], [cppunit >= 1.12]) 124]) 125 126AM_CONDITIONAL(PROXY_CLIENT_OR_SERVER, test x$proxy_client == xyes | test x$proxy_server == xyes) 127 128PKG_CHECK_MODULES([Nettle], [nettle >= 2.4]) 129PKG_CHECK_MODULES([GnuTLS], [gnutls >= 3.3]) 130PKG_CHECK_MODULES([MsgPack], [msgpack >= 1.2]) 131 132AC_ARG_WITH([jsoncpp], AS_HELP_STRING([--without-jsoncpp], [Build without JsonCpp support])) 133AS_IF([test "x$with_jsoncpp" != "xno"], 134 [PKG_CHECK_MODULES([JsonCpp], [jsoncpp >= 1.7.2], [have_jsoncpp=yes], [have_jsoncpp=no])], 135 [have_jsoncpp=no]) 136AS_IF([test "x$have_jsoncpp" = "xyes"], [ 137 AC_MSG_NOTICE([Using JsonCpp]) 138 CPPFLAGS+=" -DOPENDHT_JSONCPP=1" 139], [ 140 AC_MSG_NOTICE([Not using JsonCpp]) 141 AM_COND_IF(PROXY_CLIENT_OR_SERVER, AC_MSG_ERROR(["JsonCpp is required for proxy/push notification support"])) 142]) 143 144AM_COND_IF([PROXY_CLIENT_OR_SERVER], [ 145 AC_CHECK_LIB(restbed, exit,, AC_MSG_ERROR([Missing restbed files])) 146 LDFLAGS="${LDFLAGS} -lrestbed" 147]) 148 149CXXFLAGS="${CXXFLAGS} -DMSGPACK_DISABLE_LEGACY_NIL -DMSGPACK_DISABLE_LEGACY_CONVERT" 150 151dnl Check for Argon2 152AC_ARG_WITH([argon2], AS_HELP_STRING([--without-argon2], [Use included Argon2])) 153AS_IF([test "x$with_argon2" != "xno"], 154 [PKG_CHECK_MODULES([Argon2], [libargon2], [have_argon2=yes], [have_argon2=no])], 155 [have_argon2=no]) 156AS_IF([test "x$have_argon2" = "xyes"], [ 157 AC_MSG_NOTICE([Using system Argon2]) 158 AC_SUBST(argon2_lib, [", libargon2"]) 159], [ 160 AS_IF([test "x$with_argon2" = "xyes"], [ 161 AC_MSG_ERROR([Argon2 requested but not found]) 162 ],[ 163 AC_MSG_NOTICE([Using included Argon2]) 164 AC_SUBST(Argon2_CFLAGS, "-I\${top_srcdir}/argon2/src -I\${top_srcdir}/argon2/include") 165 AC_SUBST(Argon2_LIBS, "libargon2.la") 166 AC_SUBST(Argon2_LDFLAGS, "-L\${abs_top_srcdir}/argon2/src/.libs") 167 ]) 168]) 169 170AM_CONDITIONAL([WITH_INCLUDED_ARGON2], [test "x$have_argon2" = "xno"]) 171 172AC_ARG_ENABLE([tools], AS_HELP_STRING([--disable-tools],[Disable tools (CLI DHT node)]),,build_tools=yes) 173AM_CONDITIONAL(ENABLE_TOOLS, test x$build_tools == xyes) 174AM_COND_IF([ENABLE_TOOLS], [ 175 AC_CHECK_HEADERS([readline/readline.h readline/history.h], [], [ 176 AC_MSG_ERROR([unable to find readline.h]) 177 ]) 178]) 179 180AM_COND_IF(ENABLE_PROXY_SERVER, [CPPFLAGS+=" -DOPENDHT_PROXY_SERVER"], []) 181AM_COND_IF(ENABLE_PROXY_CLIENT, [CPPFLAGS+=" -DOPENDHT_PROXY_CLIENT"], []) 182AM_COND_IF(ENABLE_PUSH_NOTIFICATIONS, [CPPFLAGS+=" -DOPENDHT_PUSH_NOTIFICATIONS"], []) 183AM_COND_IF(ENABLE_PROXY_SERVER_IDENTITY, [CPPFLAGS+=" -DOPENDHT_PROXY_SERVER_IDENTITY"], []) 184 185AM_COND_IF([HAVE_DOXYGEN], [ 186 AC_CONFIG_FILES([doc/Doxyfile doc/Makefile]) 187]) 188 189dnl Configure setup.py if we build the python module 190AM_COND_IF([USE_CYTHON], [ 191 AC_SUBST(CURRENT_SOURCE_DIR, ".") 192 AC_SUBST(CURRENT_BINARY_DIR, ".") 193 AC_SUBST(PROJECT_SOURCE_DIR, "..") 194 AC_SUBST(PROJECT_BINARY_DIR, "../src/.libs") 195 AC_CONFIG_FILES([python/Makefile python/setup.py]) 196]) 197 198AC_CONFIG_FILES([Makefile 199 src/Makefile 200 tools/Makefile 201 tests/Makefile 202 opendht.pc]) 203AC_OUTPUT 204