From 8f58e5a3ec0e4a15fc8ae0911cc864f5dbf86c6e Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Fri, 18 Aug 2017 15:56:55 +0200 Subject: build: Revise the build system This revises the build system to have configuration per system component. System settings can now be set using cmake. The standard compliance defines were removed from configuration header and are set in the sources where needed. Also some small code refactors, such as moving the data for shims out of the ipcp structure to the respective shims were performed. --- include/ouroboros/CMakeLists.txt | 4 -- include/ouroboros/config.h.in | 88 ----------------------------------- include/ouroboros/endian.h | 51 ++++++-------------- include/ouroboros/wrap/CMakeLists.txt | 9 ++-- 4 files changed, 19 insertions(+), 133 deletions(-) delete mode 100644 include/ouroboros/config.h.in (limited to 'include') diff --git a/include/ouroboros/CMakeLists.txt b/include/ouroboros/CMakeLists.txt index 8f57d4d7..e39759fd 100644 --- a/include/ouroboros/CMakeLists.txt +++ b/include/ouroboros/CMakeLists.txt @@ -1,7 +1,3 @@ -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" - "${CMAKE_CURRENT_BINARY_DIR}/config.h") - set(HEADER_FILES cacep.h cdap.h diff --git a/include/ouroboros/config.h.in b/include/ouroboros/config.h.in deleted file mode 100644 index d5871624..00000000 --- a/include/ouroboros/config.h.in +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2017 - * - * Configuration information - * - * Dimitri Staessens - * Sander Vrijders - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., http://www.fsf.org/about/contact/. - */ - -#ifndef OUROBOROS_CONFIG -#define OUROBOROS_CONFIG - -#define PROJECT_NAME "@CMAKE_PROJECT_NAME@" -#define PROJECT_VERSION "@PACKAGE_VERSION@" -#define INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@" -#define _POSIX_C_SOURCE 200809L -#define __XSI_VISIBLE 500 -#ifdef __FreeBSD__ -#define __BSD_VISIBLE 1 -#endif -#ifdef __APPLE__ -#define _BSD_SOURCE -#define _DARWIN_C_SOURCE -#endif -#define IPCP_SHIM_UDP_EXEC "@IPCP_SHIM_UDP_TARGET@" -#define IPCP_SHIM_ETH_LLC_EXEC "@IPCP_SHIM_ETH_LLC_TARGET@" -#define IPCP_NORMAL_EXEC "@IPCP_NORMAL_TARGET@" -#define IPCP_LOCAL_EXEC "@IPCP_LOCAL_TARGET@" -#cmakedefine HAVE_ROBUST_MUTEX -#cmakedefine HAVE_SYS_RANDOM -#cmakedefine HAVE_LIBGCRYPT -#cmakedefine HAVE_OPENSSL -#cmakedefine HAVE_NETMAP -#cmakedefine HAVE_BPF -#define AP_MAX_FLOWS 2048 -#define AP_RES_FDS 64 -#define AP_MAX_FQUEUES 64 -#define SHM_RDRB_BLOCK_SIZE sysconf(_SC_PAGESIZE) -#define SHM_RDRB_MULTI_BLOCK -#define SHM_RDRB_NAME "/ouroboros.rdrb" -#define LOCKFILE_NAME "/ouroboros.lockfile" -#define SHM_BUFFER_SIZE 1 << 14 -#define DU_BUFF_HEADSPACE 128 -#define DU_BUFF_TAILSPACE 0 -#define SHM_RBUFF_LOCKLESS 0 -#define SHM_RBUFF_PREFIX "/ouroboros.rbuff." -#define SHM_FLOW_SET_PREFIX "/ouroboros.sets." -#define IRMD_MAX_FLOWS 4096 -/* IRMD dynamic threadpooling */ -#define IRMD_MIN_THREADS 16 -#define IRMD_ADD_THREADS 32 -/* IPCP dynamic threadpooling */ -#define IPCP_MIN_THREADS 4 -#define IPCP_ADD_THREADS 16 -#define IPCP_SCHED_THREADS 2 -#define IPCPD_MAX_CONNS IRMD_MAX_FLOWS -#ifdef __APPLE__ -#define PTHREAD_COND_CLOCK CLOCK_REALTIME -#else -#define PTHREAD_COND_CLOCK CLOCK_MONOTONIC -#endif -#define PFT_SIZE 1 << 12 -/* Timeout values */ -#define IRMD_ACCEPT_TIMEOUT 100 -#define IRMD_REQ_ARR_TIMEOUT 500 -#define IRMD_FLOW_TIMEOUT 5000 -#define IPCP_ACCEPT_TIMEOUT 100 -#define SOCKET_TIMEOUT 1000 -#define BOOTSTRAP_TIMEOUT 5000 -#define ENROLL_TIMEOUT 60000 -#define REG_TIMEOUT 10000 -#define QUERY_TIMEOUT 3000 -#define CDAP_REPLY_TIMEOUT 1000 - -#endif /* OUROBOROS_CONFIG */ diff --git a/include/ouroboros/endian.h b/include/ouroboros/endian.h index 18df0e99..00c7e043 100644 --- a/include/ouroboros/endian.h +++ b/include/ouroboros/endian.h @@ -24,42 +24,18 @@ #define OUROBOROS_ENDIAN_H #if defined(__linux__) || defined(__CYGWIN__) || \ - (defined(__MACH__) && !defined(__APPLE__)) - -#ifndef _BSD_SOURCE -#define _BSD_SOURCE -#endif -#ifndef __USE_BSD -#define __USE_BSD -#endif -#ifndef _DEFAULT_SOURCE + (defined(__MACH__) && !defined(__APPLE__)) #define _DEFAULT_SOURCE -#endif - #include -#include - -#define betoh16(x) be16toh(x) -#define letoh16(x) le16toh(x) -#define betoh32(x) be32toh(x) -#define letoh32(x) le32toh(x) -#define betoh64(x) be64toh(x) -#define letoh64(x) le64toh(x) - -#elif defined(__NetBSD__) || defined(__FreeBSD__) - +#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) #include - -#define betoh16(x) be16toh(x) -#define letoh16(x) le16toh(x) -#define betoh32(x) be32toh(x) -#define letoh32(x) le32toh(x) -#define betoh64(x) be64toh(x) -#define letoh64(x) le64toh(x) - #elif defined(__APPLE__) - #include +#else +#error OS currently not supported +#endif + +#if defined (__APPLE__) #define htobe16(x) OSSwapHostToBigInt16(x) #define htole16(x) OSSwapHostToLittleInt16(x) @@ -76,13 +52,14 @@ #define betoh64(x) OSSwapBigToHostInt64(x) #define letoh64(x) OSSwapLittleToHostInt64(x) -#elif defined(__OpenBSD__) - -#include +#elif !defined(__OpenBSD__) -#else - -#error OS currently not supported +#define betoh16(x) be16toh(x) +#define letoh16(x) le16toh(x) +#define betoh32(x) be32toh(x) +#define letoh32(x) le32toh(x) +#define betoh64(x) be64toh(x) +#define letoh64(x) le64toh(x) #endif diff --git a/include/ouroboros/wrap/CMakeLists.txt b/include/ouroboros/wrap/CMakeLists.txt index eb44ed33..435b3b70 100644 --- a/include/ouroboros/wrap/CMakeLists.txt +++ b/include/ouroboros/wrap/CMakeLists.txt @@ -1,10 +1,9 @@ -find_package(SWIG) - include_directories(${CMAKE_SOURCE_DIR}/include) include_directories(${CMAKE_BINARY_DIR}/include) +find_package(SWIG) if (NOT SWIG_FOUND) - message(STATUS "SWIG not found: Bindings for other languages disabled.") + message(STATUS "SWIG not found: Bindings for other languages disabled") else () include(${SWIG_USE_FILE}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) @@ -12,7 +11,7 @@ else () find_package(PythonLibs) if (NOT PYTHONLIBS_FOUND) - message(STATUS "Python not found: Python bindings will not be built.") + message(STATUS "Python not found: Python bindings will not be built") else () include_directories(${PYTHON_INCLUDE_PATH}) @@ -55,3 +54,5 @@ else () DESTINATION ${PYTHON_MODULE_PATH}) endif () endif () + +mark_as_advanced(SWIG_EXECUTABLE) -- cgit v1.2.3