mirror of
https://github.com/ntop/n2n.git
synced 2024-09-19 16:41:11 +02:00
Autoconf simplification (#927)
* Convert zstd feature to default disable * All autoconf test use one standard template To simplify the testing, cross-compilation and repeatable build process, no configure options are automatically probed for - they all default to off and are all using the same template. The --with-x options should be deprecated and replaced with --enable-x because there is no syntax checking for --with options in autoconf. There are still some differences between the config options, but this should provide a starting point. * Remove unused code from the autoconf * Remove warnings from default build * Avoid calling port mapping functions if none are enabled * Start with all builds in neutral config * Add more missing code guards * Adjust code guard location to placate cmake
This commit is contained in:
parent
da9ba27b0a
commit
4f568b03c1
4
.github/workflows/tests.yml
vendored
4
.github/workflows/tests.yml
vendored
|
@ -87,7 +87,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
export CFLAGS="-fprofile-arcs -ftest-coverage"
|
export CFLAGS="-fprofile-arcs -ftest-coverage"
|
||||||
export LDFLAGS="--coverage"
|
export LDFLAGS="--coverage"
|
||||||
./configure --with-zstd
|
./configure
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Run embedded tests
|
- name: Run embedded tests
|
||||||
|
@ -158,7 +158,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
export CFLAGS="-fprofile-arcs -ftest-coverage"
|
export CFLAGS="-fprofile-arcs -ftest-coverage"
|
||||||
export LDFLAGS="--coverage"
|
export LDFLAGS="--coverage"
|
||||||
./configure --with-zstd
|
./configure
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Run embedded tests
|
- name: Run embedded tests
|
||||||
|
|
166
configure.ac
166
configure.ac
|
@ -15,87 +15,116 @@ N2N_LIBS=
|
||||||
|
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
|
|
||||||
AC_ARG_WITH(edgex, [ --with-edgex Build for Ubiquity-X])
|
# TODO: ideally, should use AC_ARG_ENABLE
|
||||||
|
AC_ARG_WITH([edgex],
|
||||||
if test "${with_edgex+set}" = set; then
|
AS_HELP_STRING([--with-edgex], [Build for Ubiquity-X]),
|
||||||
|
[], [with_edgex=no])
|
||||||
|
AS_IF([test "x$with_edgex" != "xno"],
|
||||||
|
[
|
||||||
|
AC_MSG_NOTICE([Please contact us with your use case])
|
||||||
CC=mipsel-linux-gnu-gcc
|
CC=mipsel-linux-gnu-gcc
|
||||||
AR=mipsel-linux-gnu-arzls
|
AR=mipsel-linux-gnu-arzls
|
||||||
fi
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
# TODO: ideally, should use AC_ARG_ENABLE
|
||||||
AC_ARG_WITH([zstd],
|
AC_ARG_WITH([zstd],
|
||||||
[AS_HELP_STRING([--with-zstd],
|
AS_HELP_STRING([--with-zstd], [use zstd library]),
|
||||||
[enable support for zstd])],
|
[], [with_zstd=no])
|
||||||
[],
|
AS_IF([test "x$with_zstd" != "xno"],
|
||||||
[with_zstd=no])
|
[AC_CHECK_LIB([zstd], [ZSTD_compress],
|
||||||
if test "x$with_zstd" != xno; then
|
[
|
||||||
AC_CHECK_LIB([zstd], [ZSTD_compress])
|
AC_DEFINE([N2N_HAVE_ZSTD], [1], [Have ZSTD support])
|
||||||
if test "x$ac_cv_lib_zstd_ZSTD_compress" != xyes; then
|
|
||||||
AC_MSG_RESULT(Building n2n without ZSTD support)
|
|
||||||
else
|
|
||||||
AC_DEFINE([N2N_HAVE_ZSTD], [], [Have ZSTD support])
|
|
||||||
N2N_LIBS="-lzstd ${N2N_LIBS}"
|
N2N_LIBS="-lzstd ${N2N_LIBS}"
|
||||||
fi
|
],
|
||||||
fi
|
[AC_MSG_ERROR([zstd library not found])]
|
||||||
|
)],
|
||||||
|
)
|
||||||
|
|
||||||
|
# TODO: ideally, should use AC_ARG_ENABLE
|
||||||
AC_ARG_WITH([openssl],
|
AC_ARG_WITH([openssl],
|
||||||
[AS_HELP_STRING([--with-openssl],
|
[AS_HELP_STRING([--with-openssl], [enable support for OpenSSL])],
|
||||||
[enable support for OpenSSL])],
|
[], [with_openssl=no])
|
||||||
[],
|
AS_IF([test "x$with_openssl" != xno],
|
||||||
[with_openssl=no])
|
[AC_CHECK_LIB([crypto], [EVP_CIPHER_CTX_reset],
|
||||||
if test "x$with_openssl" != xno; then
|
[
|
||||||
OLD_CFLAGS="${CFLAGS}"
|
AC_DEFINE([HAVE_OPENSSL_1_1], [1], [OpenSSL 1.1 is present])
|
||||||
OLD_LDFLAGS="${LDFLAGS}"
|
|
||||||
CFLAGS="${CFLAGS} -I/usr/local/opt/openssl@1.1/include"
|
|
||||||
LDFLAGS="${LDFLAGS} -L/usr/local/opt/openssl@1.1/lib/"
|
|
||||||
AC_CHECK_LIB([crypto], [EVP_CIPHER_CTX_reset])
|
|
||||||
if test "x$ac_cv_lib_crypto_EVP_CIPHER_CTX_reset" != xyes; then
|
|
||||||
AC_MSG_RESULT(OpenSSL 1.1 not present)
|
|
||||||
CFLAGS="${OLD_CFLAGS}"
|
|
||||||
LDFLAGS="${OLD_LDFLAGS}"
|
|
||||||
else
|
|
||||||
AC_DEFINE([HAVE_OPENSSL_1_1], [], [OpenSSL 1.1 is present])
|
|
||||||
N2N_LIBS="-lcrypto ${N2N_LIBS}"
|
N2N_LIBS="-lcrypto ${N2N_LIBS}"
|
||||||
fi
|
],
|
||||||
fi
|
[AC_MSG_ERROR([openssl library not found])]
|
||||||
|
)],
|
||||||
|
)
|
||||||
|
|
||||||
AC_CHECK_LIB([miniupnpc], [upnpDiscover], miniupnp=true)
|
AC_ARG_ENABLE([miniupnp],
|
||||||
|
[AS_HELP_STRING([--enable-miniupnp], [support for miniupnp])],
|
||||||
if test x$miniupnp != x; then
|
[], [enable_miniupnp=no])
|
||||||
AC_DEFINE([HAVE_MINIUPNP], [], [Have miniupnp library])
|
AS_IF([test "x$enable_miniupnp" != xno],
|
||||||
|
[AC_CHECK_LIB([miniupnpc], [upnpDiscover],
|
||||||
|
[
|
||||||
|
AC_DEFINE([HAVE_MINIUPNP], [1], [Have miniupnp library])
|
||||||
|
AC_DEFINE([HAVE_PORT_FORWARDING],[1],[upnp libs are used])
|
||||||
N2N_LIBS="-lminiupnpc ${N2N_LIBS}"
|
N2N_LIBS="-lminiupnpc ${N2N_LIBS}"
|
||||||
fi
|
],
|
||||||
|
[AC_MSG_ERROR([miniupnp library not found])]
|
||||||
|
)],
|
||||||
|
)
|
||||||
|
|
||||||
AC_CHECK_LIB([natpmp], [initnatpmp], natpmp=true)
|
AC_ARG_ENABLE([natpmp],
|
||||||
|
[AS_HELP_STRING([--enable-natpmp], [support for natpmp])],
|
||||||
if test x$natpmp != x; then
|
[], [enable_natpmp=no])
|
||||||
AC_DEFINE([HAVE_NATPMP], [], [Have natpmp library])
|
AS_IF([test "x$enable_natpmp" != xno],
|
||||||
|
[AC_CHECK_LIB([natpmp], [initnatpmp],
|
||||||
|
[
|
||||||
|
AC_DEFINE([HAVE_NATPMP], [1], [Have natpmp library])
|
||||||
|
AC_DEFINE([HAVE_PORT_FORWARDING],[1],[upnp libs are used])
|
||||||
N2N_LIBS="-lnatpmp ${N2N_LIBS}"
|
N2N_LIBS="-lnatpmp ${N2N_LIBS}"
|
||||||
fi
|
],
|
||||||
|
[AC_MSG_ERROR([natpmp library not found])]
|
||||||
|
)],
|
||||||
|
)
|
||||||
|
|
||||||
AC_CHECK_LIB([pcap], [pcap_open_live], pcap=true)
|
AC_ARG_ENABLE([pcap],
|
||||||
|
[AS_HELP_STRING([--enable-pcap], [support for pcap])],
|
||||||
if test x$pcap != x; then
|
[], [enable_pcap=no])
|
||||||
AC_DEFINE([N2N_HAVE_PCAP], [], [Have PCAP library])
|
AS_IF([test "x$enable_pcap" != xno],
|
||||||
|
[AC_CHECK_LIB([pcap], [pcap_open_live],
|
||||||
|
[
|
||||||
|
AC_DEFINE([N2N_HAVE_PCAP], [1], [Have PCAP library])
|
||||||
|
N2N_LIBS="-lpcap ${N2N_LIBS}"
|
||||||
ADDITIONAL_TOOLS="$ADDITIONAL_TOOLS n2n-decode"
|
ADDITIONAL_TOOLS="$ADDITIONAL_TOOLS n2n-decode"
|
||||||
fi
|
AC_CHECK_LIB([pcap], [pcap_set_immediate_mode],
|
||||||
|
AC_DEFINE([HAVE_PCAP_IMMEDIATE_MODE], [1], [Have pcap_immediate_mode])
|
||||||
|
)
|
||||||
|
],
|
||||||
|
[AC_MSG_ERROR([pcap library not found])]
|
||||||
|
)],
|
||||||
|
)
|
||||||
|
|
||||||
AC_CHECK_LIB([pcap], [pcap_set_immediate_mode], pcap_immediate_mode=true)
|
AC_ARG_ENABLE([cap],
|
||||||
|
[AS_HELP_STRING([--enable-cap], [support for cap])],
|
||||||
if test x$pcap_immediate_mode != x; then
|
[], [enable_cap=no])
|
||||||
AC_DEFINE([HAVE_PCAP_IMMEDIATE_MODE], [], [Have pcap_immediate_mode])
|
AS_IF([test "x$enable_cap" != xno],
|
||||||
fi
|
[AC_CHECK_LIB([cap], [cap_get_proc],
|
||||||
|
[
|
||||||
AC_CHECK_LIB([cap], [cap_get_proc], cap=true)
|
|
||||||
if test x$cap != x; then
|
|
||||||
N2N_LIBS="${N2N_LIBS} -lcap"
|
|
||||||
AC_DEFINE([HAVE_LIBCAP],[1],[Support for linux capabilities])
|
AC_DEFINE([HAVE_LIBCAP],[1],[Support for linux capabilities])
|
||||||
fi
|
N2N_LIBS="${N2N_LIBS} -lcap"
|
||||||
|
],
|
||||||
|
[AC_MSG_ERROR([cap library not found])]
|
||||||
|
)],
|
||||||
|
)
|
||||||
|
|
||||||
AC_CHECK_LIB([pthread], [pthread_mutex_trylock], pthread=true)
|
AC_ARG_ENABLE([pthread],
|
||||||
if test x$pthread != x; then
|
[AS_HELP_STRING([--enable-pthread], [support for pthread])],
|
||||||
|
[], [enable_pthread=no])
|
||||||
|
AS_IF([test "x$enable_pthread" != xno],
|
||||||
|
[AC_CHECK_LIB([pthread], [pthread_mutex_trylock],
|
||||||
|
[
|
||||||
|
AC_DEFINE([HAVE_PTHREAD],[1],[pthread is present])
|
||||||
LDFLAGS="${LDFLAGS} -pthread"
|
LDFLAGS="${LDFLAGS} -pthread"
|
||||||
AC_DEFINE([HAVE_PTHREAD],[],[pthread is present])
|
],
|
||||||
fi
|
[AC_MSG_ERROR([pthread library not found])]
|
||||||
|
)],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
MACHINE=`uname -m`
|
MACHINE=`uname -m`
|
||||||
|
@ -114,22 +143,11 @@ dnl> wget -O config.guess 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=bl
|
||||||
fi
|
fi
|
||||||
AC_DEFINE_UNQUOTED(PACKAGE_OSNAME, "${OSNAME}", [OS name])
|
AC_DEFINE_UNQUOTED(PACKAGE_OSNAME, "${OSNAME}", [OS name])
|
||||||
|
|
||||||
if test $MACHINE = "x86_64"; then
|
|
||||||
EXTN="amd64"
|
|
||||||
else
|
|
||||||
if test $MACHINE = "i686"; then
|
|
||||||
EXTN="i386"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
DATE=`date +"%Y-%m-%d"`
|
|
||||||
|
|
||||||
AC_SUBST(CC)
|
AC_SUBST(CC)
|
||||||
AC_SUBST(AR)
|
AC_SUBST(AR)
|
||||||
AC_SUBST(CFLAGS)
|
AC_SUBST(CFLAGS)
|
||||||
AC_SUBST(LDFLAGS)
|
AC_SUBST(LDFLAGS)
|
||||||
AC_SUBST(N2N_VERSION)
|
AC_SUBST(N2N_VERSION)
|
||||||
AC_SUBST(N2N_DEFINES)
|
|
||||||
AC_SUBST(N2N_LIBS)
|
AC_SUBST(N2N_LIBS)
|
||||||
AC_SUBST(ADDITIONAL_TOOLS)
|
AC_SUBST(ADDITIONAL_TOOLS)
|
||||||
AC_CONFIG_HEADERS(include/config.h)
|
AC_CONFIG_HEADERS(include/config.h)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef _N2N_PORT_MAPPING_H_
|
#ifndef _N2N_PORT_MAPPING_H_
|
||||||
#define _N2N_PORT_MAPPING_H_
|
#define _N2N_PORT_MAPPING_H_
|
||||||
|
|
||||||
|
#ifdef HAVE_PORT_FORWARDING
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef HAVE_MINIUPNP
|
#ifdef HAVE_MINIUPNP
|
||||||
|
@ -26,4 +28,5 @@
|
||||||
void n2n_chg_port_mapping (struct n2n_edge *eee, const uint16_t port);
|
void n2n_chg_port_mapping (struct n2n_edge *eee, const uint16_t port);
|
||||||
|
|
||||||
|
|
||||||
|
#endif // HAVE_PORT_FORWARDING
|
||||||
#endif // _N2N_PORT_MAPPING_H_
|
#endif // _N2N_PORT_MAPPING_H_
|
||||||
|
|
|
@ -30,8 +30,10 @@ int resolve_create_thread (n2n_resolve_parameter_t **param, struct peer_info *sn
|
||||||
int resolve_check (n2n_resolve_parameter_t *param, uint8_t resolution_request, time_t now);
|
int resolve_check (n2n_resolve_parameter_t *param, uint8_t resolution_request, time_t now);
|
||||||
int resolve_cancel_thread (n2n_resolve_parameter_t *param);
|
int resolve_cancel_thread (n2n_resolve_parameter_t *param);
|
||||||
|
|
||||||
|
#ifdef HAVE_PORT_FORWARDING
|
||||||
int port_map_create_thread (n2n_port_map_parameter_t **param, uint16_t mgmt_port);
|
int port_map_create_thread (n2n_port_map_parameter_t **param, uint16_t mgmt_port);
|
||||||
int port_map_cancel_thread (n2n_port_map_parameter_t *param);
|
int port_map_cancel_thread (n2n_port_map_parameter_t *param);
|
||||||
|
#endif
|
||||||
|
|
||||||
static const char * supernode_ip (const n2n_edge_t * eee);
|
static const char * supernode_ip (const n2n_edge_t * eee);
|
||||||
static void send_register (n2n_edge_t *eee, const n2n_sock_t *remote_peer, const n2n_mac_t peer_mac, n2n_cookie_t cookie);
|
static void send_register (n2n_edge_t *eee, const n2n_sock_t *remote_peer, const n2n_mac_t peer_mac, n2n_cookie_t cookie);
|
||||||
|
@ -332,12 +334,12 @@ int supernode_connect (n2n_edge_t *eee) {
|
||||||
eee->cb.sock_opened(eee);
|
eee->cb.sock_opened(eee);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_MINIUPNP) || defined(HAVE_NATPMP)
|
#ifdef HAVE_PORT_FORWARDING
|
||||||
if(eee->conf.port_forwarding)
|
if(eee->conf.port_forwarding)
|
||||||
// REVISIT: replace with mgmt port notification to listener for mgmt port
|
// REVISIT: replace with mgmt port notification to listener for mgmt port
|
||||||
// subscription support
|
// subscription support
|
||||||
n2n_chg_port_mapping(eee, eee->conf.preferred_sock.port);
|
n2n_chg_port_mapping(eee, eee->conf.preferred_sock.port);
|
||||||
#endif // HAVE_MINIUPNP || HAVE_NATPMP
|
#endif // HAVE_PORT_FORWARDING
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,7 +493,7 @@ n2n_edge_t* edge_init (const n2n_edge_conf_t *conf, int *rv) {
|
||||||
if(resolve_create_thread(&(eee->resolve_parameter), eee->conf.supernodes) == 0) {
|
if(resolve_create_thread(&(eee->resolve_parameter), eee->conf.supernodes) == 0) {
|
||||||
traceEvent(TRACE_NORMAL, "successfully created resolver thread");
|
traceEvent(TRACE_NORMAL, "successfully created resolver thread");
|
||||||
}
|
}
|
||||||
#if defined(HAVE_MINIUPNP) || defined(HAVE_NATPMP)
|
#ifdef HAVE_PORT_FORWARDING
|
||||||
if(eee->conf.port_forwarding)
|
if(eee->conf.port_forwarding)
|
||||||
if(port_map_create_thread(&eee->port_map_parameter, eee->conf.mgmt_port) == 0) {
|
if(port_map_create_thread(&eee->port_map_parameter, eee->conf.mgmt_port) == 0) {
|
||||||
traceEvent(TRACE_NORMAL, "successfully created port mapping thread");
|
traceEvent(TRACE_NORMAL, "successfully created port mapping thread");
|
||||||
|
@ -3206,7 +3208,7 @@ int run_edge_loop (n2n_edge_t *eee) {
|
||||||
void edge_term (n2n_edge_t * eee) {
|
void edge_term (n2n_edge_t * eee) {
|
||||||
|
|
||||||
resolve_cancel_thread(eee->resolve_parameter);
|
resolve_cancel_thread(eee->resolve_parameter);
|
||||||
#if defined(HAVE_MINIUPNP) || defined(HAVE_NATPMP)
|
#ifdef HAVE_PORT_FORWARDING
|
||||||
if(eee->conf.port_forwarding)
|
if(eee->conf.port_forwarding)
|
||||||
port_map_cancel_thread(eee->port_map_parameter);
|
port_map_cancel_thread(eee->port_map_parameter);
|
||||||
#endif // HAVE_MINIUPNP || HAVE_NATPMP
|
#endif // HAVE_MINIUPNP || HAVE_NATPMP
|
||||||
|
|
|
@ -304,9 +304,9 @@ int supernode2sock (n2n_sock_t *sn, const n2n_sn_name_t addrIn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_PTHREAD
|
||||||
N2N_THREAD_RETURN_DATATYPE resolve_thread(N2N_THREAD_PARAMETER_DATATYPE p) {
|
N2N_THREAD_RETURN_DATATYPE resolve_thread(N2N_THREAD_PARAMETER_DATATYPE p) {
|
||||||
|
|
||||||
#ifdef HAVE_PTHREAD
|
|
||||||
n2n_resolve_parameter_t *param = (n2n_resolve_parameter_t*)p;
|
n2n_resolve_parameter_t *param = (n2n_resolve_parameter_t*)p;
|
||||||
n2n_resolve_ip_sock_t *entry, *tmp_entry;
|
n2n_resolve_ip_sock_t *entry, *tmp_entry;
|
||||||
time_t rep_time = N2N_RESOLVE_INTERVAL / 10;
|
time_t rep_time = N2N_RESOLVE_INTERVAL / 10;
|
||||||
|
@ -351,8 +351,8 @@ N2N_THREAD_RETURN_DATATYPE resolve_thread(N2N_THREAD_PARAMETER_DATATYPE p) {
|
||||||
// unlock access
|
// unlock access
|
||||||
pthread_mutex_unlock(¶m->access);
|
pthread_mutex_unlock(¶m->access);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int resolve_create_thread (n2n_resolve_parameter_t **param, struct peer_info *sn_list) {
|
int resolve_create_thread (n2n_resolve_parameter_t **param, struct peer_info *sn_list) {
|
||||||
|
@ -394,6 +394,8 @@ int resolve_create_thread (n2n_resolve_parameter_t **param, struct peer_info *sn
|
||||||
pthread_mutex_init(&((*param)->access), NULL);
|
pthread_mutex_init(&((*param)->access), NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_PORT_FORWARDING
|
||||||
|
|
||||||
#include "n2n.h"
|
#include "n2n.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -464,7 +466,6 @@ static int n2n_natpmp_del_port_mapping (const uint16_t port) {
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
static void n2n_set_port_mapping (const uint16_t port) {
|
static void n2n_set_port_mapping (const uint16_t port) {
|
||||||
|
|
||||||
#ifdef HAVE_NATPMP
|
#ifdef HAVE_NATPMP
|
||||||
|
@ -618,9 +619,10 @@ int port_map_create_thread (n2n_port_map_parameter_t **param, uint16_t mgmt_port
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -633,3 +635,5 @@ void port_map_cancel_thread (n2n_port_map_parameter_t *param) {
|
||||||
free(param);
|
free(param);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // HAVE_PORT_FORWARDING
|
||||||
|
|
Loading…
Reference in New Issue
Block a user