freewtp/configure.ac
vemax78 025880583c Changed the management of the wireless interfaces, from creation to usage.
The virtual interfaces are created at the startup of the wtp to reduce the time
required to configure a wireless interface.
Applied some patches to build the WTP on OpenWRT trunk
2014-02-08 18:03:38 +01:00

361 lines
9.4 KiB
Plaintext

# SmartCAPWAP -- An Open Source CAPWAP WTP / AC
#
# Copyright (C) 2012-2013 Massimo Vellucci <vemax78@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (see the file COPYING included with this
# distribution); if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
AC_PREREQ(2.60)
m4_include(version.m4)
AC_INIT([PRODUCT_NAME], [PRODUCT_VERSION], [PRODUCT_BUGREPORT], [PRODUCT_TARNAME])
AC_CONFIG_AUX_DIR([.])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE
AC_USE_SYSTEM_EXTENSIONS
# cross-compile macros
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
#
AC_COPYRIGHT("SmartCapwap by Massimo Vellucci <vemax78@gmail.com>")
AC_REVISION($Revision: 1.0 $)
#
AC_ARG_ENABLE(
[dtls],
[AS_HELP_STRING([--disable-dtls], [disable DTLS support @<:@default=yes@:>@])],
,
[enable_dtls="yes"]
)
AC_ARG_ENABLE(
[debug],
[AS_HELP_STRING([--disable-debug], [disable debug support @<:@default=yes@:>@])],
,
[enable_debug="yes"]
)
AC_ARG_ENABLE(
[logging],
[AS_HELP_STRING([--disable-logging], [disable logging support @<:@default=yes@:>@])],
,
[enable_logging="yes"]
)
AC_ARG_ENABLE(
[ac],
[AS_HELP_STRING([--disable-ac], [disable ac support @<:@default=yes@:>@])],
,
[enable_ac="yes"]
)
AC_ARG_ENABLE(
[wtp],
[AS_HELP_STRING([--disable-wtp], [disable wtp support @<:@default=yes@:>@])],
,
[enable_wtp="yes"]
)
AC_ARG_WITH(
[ssl-library],
[AS_HELP_STRING([--with-ssl-library=library], [build with the given crypto library, TYPE=openssl|cyassl @<:@default=openssl@:>@])],
[
case "${withval}" in
openssl|cyassl) ;;
*) AC_MSG_ERROR([bad value ${withval} for --with-crypto-library]) ;;
esac
],
[with_ssl_library="openssl"]
)
AC_ARG_WITH(
[mem-check],
[AS_HELP_STRING([--with-mem-check=TYPE], [build with debug memory checking, TYPE=no|internal|valgrind @<:@default=internal@:>@])],
[
case "${withval}" in
valgrind|internal|no) ;;
*) AC_MSG_ERROR([bad value ${withval} for --mem-check]) ;;
esac
],
[with_mem_check="internal"]
)
# WTP drivers wifi binding
AC_ARG_ENABLE(
[wifi-drivers-nl80211],
[AS_HELP_STRING([--disable-wifi-drivers-nl80211], [disable WTP support for nl80211 wifi binding @<:@default=yes@:>@])],
,
[enable_wifi_drivers_nl80211="yes"]
)
# specify output header file
AM_CONFIG_HEADER(build/config.h)
#
old_CFLAGS="${CFLAGS}"
AC_PROG_CC([gcc])
CFLAGS="${old_CFLAGS}"
#
AM_CONDITIONAL([DEBUG_BUILD], [test "$enable_debug" = yes])
if test "${enable_debug}" = "yes"; then
CFLAGS="${CFLAGS} -DDEBUG -Wall -Werror -g -O0"
AC_CHECK_HEADERS([execinfo.h], [have_backtrace="yes"],[])
if test "x${have_backtrace}" = "xyes"; then
AC_DEFINE([USE_DEBUG_BACKTRACE], [1], [Use debug backtrace])
fi
else
CFLAGS="${CFLAGS} -O2"
AC_DEFINE([DISABLE_LOGGING_DEBUG], [1], [Disable logging debug])
fi
#
AC_PROG_INSTALL
AC_LANG(C)
AC_HEADER_STDC
# Check LIBCONFIG library
AC_CHECK_HEADER([libconfig.h], [], [AC_MSG_ERROR(You need the libconfig headers)])
AC_CHECK_LIB([config], [config_init], [CONFIG_LIBS="-lconfig"], [AC_MSG_ERROR(You need the libconfig library)])
# Check LIBCONFIG config_lookup_int() param type
LIBCONFIG_LOOKUP_INT_ARG=int
AC_MSG_CHECKING([what type of argument config_lookup_int() is expecting])
saved_CFLAGS="${CFLAGS}"
saved_LIBS="${LIBS}"
saved_LDFLAGS="${LDFLAGS}"
CFLAGS="$CFLAGS $LIBCONFIG_CFLAGS -Werror"
LIBS="$LIBS $CONFIG_LIBS"
LDFLAGS="$LDFLAGS $LIBCONFIG_LDFLAGS"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[
#include <libconfig.h>
],
[
int check;
config_t config;
(void)config_lookup_int(&config, "check", &check);
]
)],
[
AC_MSG_RESULT([int])
LIBCONFIG_LOOKUP_INT_ARG=int
],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[
#include <libconfig.h>
],
[
long check;
config_t config;
(void)config_lookup_int(&config, "check", &check);
]
)],
[
AC_MSG_RESULT([long])
LIBCONFIG_LOOKUP_INT_ARG=long
],
[
AC_MSG_RESULT([unknown])
AC_MSG_ERROR([failed to determine config_lookup_int() argument type])
]
)]
)
CFLAGS="$saved_CFLAGS"
LIBS="$saved_LIBS"
LDFLAGS="$saved_LDFLAGS"
AC_DEFINE_UNQUOTED([LIBCONFIG_LOOKUP_INT_ARG], [$LIBCONFIG_LOOKUP_INT_ARG], [config_lookup_int() argument type])
# Check PTHREAD library
AC_CHECK_HEADER([pthread.h], [], [AC_MSG_ERROR(You need the pthread headers)])
AC_CHECK_LIB([pthread], [pthread_create], [PTHREAD_LIBS="-lpthread"], [AC_MSG_ERROR(You need the pthread library)])
# Check XML2 library
PKG_CHECK_MODULES(
[LIBXML2],
[libxml-2.0 >= 2.6]
)
# Check JSON library
if test "${enable_ac}" = "yes"; then
PKG_CHECK_MODULES(
[LIBJSON],
[json-c >= 0.11],
[],
[PKG_CHECK_MODULES(
[LIBJSON],
[json >= 0.9],
[],
[AC_MSG_ERROR(You need the libjson)]
)]
)
fi
# Check nl80211
if test "${enable_wifi_drivers_nl80211}" = "yes"; then
PKG_CHECK_MODULES(
[LIBNL],
[libnl-1],
[AC_DEFINE([HAVE_LIBNL_10], [1], [Use libnl-1.0 library])],
[PKG_CHECK_MODULES(
[LIBNL],
[libnl-tiny],
[AC_DEFINE([HAVE_LIBNL_TINY], [1], [Use libnl-tiny library])],
[AC_MSG_ERROR(You need the libnl or libnl-tiny)]
)]
)
AC_CHECK_HEADERS([netlink/genl/genl.h netlink/genl/family.h netlink/genl/ctrl.h], [], [AC_MSG_ERROR(You need the netlink header)])
AC_CHECK_HEADER([linux/nl80211.h], [], [AC_MSG_ERROR(You need the nl80211 header)])
AC_DEFINE([ENABLE_WIFI_DRIVERS_NL80211], [1], [Enable WTP support for nl80211 wifi binding])
fi
AM_CONDITIONAL([BUILD_WTP_WIFI_DRIVERS_NL80211], [test "${enable_wifi_drivers_nl80211}" = "yes"])
# Check SSL library
if test "${with_ssl_library}" = "openssl"; then
PKG_CHECK_MODULES(
[OPENSSL_CRYPTO],
[libcrypto >= 1.0.0],
[have_openssl_crypto="yes"],
[AC_CHECK_LIB(
[crypto],
[RSA_new],
[
have_openssl_crypto="yes"
OPENSSL_CRYPTO_LIBS="-lcrypto"
]
)]
)
PKG_CHECK_MODULES(
[OPENSSL_SSL],
[libssl >= 1.0.0],
[have_openssl_ssl="yes"],
[AC_CHECK_LIB(
[ssl],
[SSL_CTX_new],
[
have_openssl_ssl="yes"
OPENSSL_SSL_LIBS="-lssl"
]
)]
)
if test "x${have_openssl_ssl}" = "xyes"; then
have_openssl_engine="yes"
OPENSSL_SSL_LIBS="${OPENSSL_SSL_LIBS} -ldl"
#saved_CFLAGS="${CFLAGS}"
#saved_LIBS="${LIBS}"
#CFLAGS="${CFLAGS} ${OPENSSL_SSL_CFLAGS}"
#LIBS="${LIBS} ${OPENSSL_SSL_LIBS}"
#AC_CHECK_FUNC([SSL_CTX_set_cookie_generate_cb], , [AC_MSG_ERROR([${with_ssl_library} SSL_CTX_set_cookie_generate_cb function is required but missing])])
#AC_CHECK_FUNC([SSL_CTX_set_cookie_verify_cb], , [AC_MSG_ERROR([${with_ssl_library} SSL_CTX_set_cookie_verify_cb function is required but missing])])
#CFLAGS="${saved_CFLAGS}"
#LIBS="${saved_LIBS}"
fi
elif test "${with_ssl_library}" = "cyassl"; then
AC_CHECK_HEADER([cyassl/ssl.h], [], [AC_MSG_ERROR(You need the cyassl headers)])
AC_CHECK_HEADER([cyassl/openssl/ssl.h], [], [AC_MSG_ERROR(You need the cyassl opensslextra headers)])
AC_CHECK_LIB([cyassl], [CyaSSL_Init], [], [AC_MSG_ERROR(You need the cyassl library)])
have_cyassl_engine="yes"
have_cyassl_ssl="yes"
fi
case "${with_ssl_library}" in
openssl)
have_crypto_engine="${have_openssl_engine}"
have_crypto_crypto="${have_openssl_crypto}"
have_crypto_ssl="${have_openssl_ssl}"
SSL_CFLAGS="${OPENSSL_CRYPTO_CFLAGS} ${OPENSSL_SSL_CFLAGS}"
SSL_LIBS="${OPENSSL_SSL_LIBS}"
test "x${have_crypto_engine}" = "xyes" && AC_DEFINE([HAVE_OPENSSL_ENGINE], [1], [Use ssl library])
;;
cyassl)
have_crypto_engine="${have_cyassl_engine}"
have_crypto_crypto="${have_cyassl_ssl}"
have_crypto_ssl="${have_cyassl_ssl}"
SSL_CFLAGS=""
SSL_LIBS="-lcyassl"
test "x${have_crypto_engine}" = "xyes" && AC_DEFINE([HAVE_CYASSL_ENGINE], [1], [Use ssl library])
;;
esac
if test "${enable_dtls}" = "yes"; then
test "x${have_crypto_engine}" != "xyes" && AC_MSG_ERROR([${with_ssl_library} engine is required but missing])
test "x${have_crypto_ssl}" != "xyes" && AC_MSG_ERROR([${with_ssl_library} ssl is required but missing])
test "x${have_crypto_crypto}" != "xyes" && AC_MSG_ERROR([${with_ssl_library} crypto is required but missing])
AC_DEFINE([ENABLE_DTLS], [1], [Enable DTLS])
fi
# Check UDPLite
AC_CHECK_HEADERS([netinet/udplite.h])
# Memory check
case "${with_mem_check}" in
internal)
LIBS="${LIBS} -rdynamic"
AC_DEFINE([USE_INTERNAL_MEMCHECK], [1], [Use internal memory debugging])
;;
valgrind)
AC_CHECK_HEADER(
[valgrind/memcheck.h],
[
CFLAGS="${CFLAGS} -g -fno-inline"
AC_DEFINE([USE_VALGRIND_MEMCHECK], [1], [Use valgrind memory debugging library])
],
[AC_MSG_ERROR([valgrind headers not found.])]
)
;;
esac
#
AM_CONDITIONAL([BUILD_AC], [test "${enable_ac}" = "yes"])
AM_CONDITIONAL([BUILD_WTP], [test "${enable_wtp}" = "yes"])
#
test "${enable_logging}" = "yes" && AC_DEFINE([ENABLE_LOGGING], [1], [Enable logging])
#
AM_CONDITIONAL([BUILD_DEBUG], [test "${enable_debug}" = "yes"])
AM_CONDITIONAL([DTLS_ENABLED], [test "${enable_dtls}" = "yes"])
#
AC_SUBST([SSL_CFLAGS])
AC_SUBST([SSL_LIBS])
AC_SUBST([CONFIG_LIBS])
AC_SUBST([PTHREAD_LIBS])
#
AC_CONFIG_FILES([
Makefile
build/Makefile
build/ac/Makefile
build/wtp/Makefile
])
AC_OUTPUT