diff --git a/.ci/build-project.ps1 b/.ci/build-project.ps1 deleted file mode 100644 index b0d7643..0000000 --- a/.ci/build-project.ps1 +++ /dev/null @@ -1,45 +0,0 @@ -# Build project. -# -# The script assumes that it will be called from inside the project directory. -# -# Usage: .ci\build-project.ps1 [vcpkg-directory [build-directory-name]] -# - vcpkg-directory: Optional full path to Vcpkg directory. Default: $HOME\vcpkg -# - build-directory-name: Optional name of build directory. Default: build. -# Can only be set of vcpkg-directory is set as well. -# -# Example 1: .ci\build-project.ps1 -# Example 2: .ci\build-project.ps1 $HOME\vcpkg-clang -# Example 3: .ci\build-project.ps1 $HOME\vcpkg-clang build-clang - -$ErrorActionPreference="Stop" - -$VCPKG_DIR=$args[0] -$BUILD_DIR=$args[1] - -if ($null -eq $VCPKG_DIR) { $VCPKG_DIR="$HOME\vcpkg" } -if ($null -eq $BUILD_DIR) { $BUILD_DIR="build" } - -# only pass toolchain file to CMake if Vcpkg is installed -if (Test-Path "$VCPKG_DIR" -PathType Container) { - $TOOLCHAIN="$VCPKG_DIR\scripts\buildsystems\vcpkg.cmake" -} else { - $TOOLCHAIN="False" -} - -Write-Host "---- build-project.ps1 ----" -Write-Host "VCPKG_DIR: $VCPKG_DIR" -Write-Host "BUILD_DIR: $BUILD_DIR" -Write-Host "CMAKE_TOOLCHAIN_FILE: $TOOLCHAIN" -Write-Host "---------------------------" - -if (-not (Get-Command cmake -ErrorAction SilentlyContinue)) { - New-Alias -Name cmake -Value "$Env:ProgramFiles\CMake\bin\cmake.exe" -} - -New-Item -Name $BUILD_DIR -ItemType Directory -Push-Location $BUILD_DIR -$ErrorActionPreference = "Stop"; -cmake -DCMAKE_BUILD_TYPE=Release -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" .. -cmake --build . --config Release -if ($LASTEXITCODE) { Throw "BUILD FAILED!" } -Pop-Location \ No newline at end of file diff --git a/.ci/install-vcpkg.ps1 b/.ci/install-vcpkg.ps1 deleted file mode 100644 index a9f4bc1..0000000 --- a/.ci/install-vcpkg.ps1 +++ /dev/null @@ -1,38 +0,0 @@ - -# Build Vcpkg and install dependency packages. -# -# Usage: .ci\install-vcpkg.ps1 [vcpkg directory name] -# - project directory: Path to the project sources where the .vcpkg file is located. -# - vcpkg directory name: optional name of directory where Vcpkg will be clone'd into -# -# Example 1: .ci\install-vcpkg.ps1 $Env:GITHUB_WORKSPACE -# Example 2: .ci\install-vcpkg.ps1 $Env:APPVEYOR_BUILD_FOLDER vcpkg-msvc - -$ErrorActionPreference="Stop" - -if ($args.Count -lt 1) { Exit 1 } - -$PROJECT_DIR=$args[0] -$VCPKG_DIR=$args[1] - -if ($null -eq $VCPKG_DIR) { $VCPKG_DIR="vcpkg" } - -# do nothing if .vcpkg file doesn't exist -if (-not (Test-Path "$PROJECT_DIR\.vcpkg" -PathType Leaf)) { Write-Host ".vcpkg file does not exist, skipping Vcpkg installation."; Exit 0 } - -Write-Host "---- install-vcpkg.ps1 ----" -Write-Host "PROJECT_DIR: $PROJECT_DIR" -Write-Host "VCPKG_DIR: $VCPKG_DIR" -Write-Host "---------------------------" - -if (-not (Get-Command git -ErrorAction SilentlyContinue)) { - New-Alias -Name git -Value "$Env:ProgramFiles\Git\bin\git.exe" -} - -Push-Location "$HOME" -git clone --quiet --depth 1 https://github.com/Microsoft/vcpkg.git $VCPKG_DIR -Set-Location $VCPKG_DIR -.\bootstrap-vcpkg.bat -disableMetrics -$packages = Get-Content "$PROJECT_DIR\.vcpkg" -.\vcpkg.exe install --triplet x64-windows $packages -Pop-Location \ No newline at end of file diff --git a/.circleci/config.yml b/.circleci/config.yml index 56bec80..f3b2a56 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,29 +14,13 @@ jobs: name: Install Software command: | sudo apt-get update - sudo apt-get install -y cmake build-essential - mkdir build - cd build - cmake .. + sudo apt-get install -y build-essential + ./autogen.sh + ./configure + make build-dep make - windows-msvc: - executor: win/default - steps: - - checkout - - run: - name: Download CMake - # yamllint disable rule:line-length - command: | - $ProgressPreference = "SilentlyContinue" - Invoke-WebRequest -URI https://github.com/Kitware/CMake/releases/download/v3.16.4/cmake-3.16.4-win64-x64.zip -OutFile $Env:HOMEPATH\cmake-3.16.4-win64-x64.zip - Expand-Archive $Env:HOMEPATH\cmake-3.16.4-win64-x64.zip -DestinationPath "$Env:ProgramFiles" - Rename-Item "$Env:ProgramFiles\cmake-3.16.4-win64-x64" -NewName CMake - # yamllint enable rule:line-length - - run: .ci\install-vcpkg.ps1 "$Env:CIRCLE_WORKING_DIRECTORY" - - run: .ci\build-project.ps1 workflows: version: 2 run-all: jobs: - linux-gcc - - windows-msvc diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml deleted file mode 100644 index bd04bd9..0000000 --- a/.github/workflows/cmake.yml +++ /dev/null @@ -1,82 +0,0 @@ ---- -name: CMake - -# yamllint disable-line rule:truthy -on: - push: - pull_request: - -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Release - -jobs: - build: - # The CMake configure and build commands are platform agnostic and should - # work equally well on Windows or Mac. You can convert this to a matrix - # build if you need cross-platform coverage. - # yamllint disable-line rule:line-length - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - - os: ubuntu-latest - - os: windows-latest - - os: macos-latest - - steps: - - uses: actions/checkout@v2 - with: - submodules: true - fetch-depth: 0 - - - name: Fix Checkout - run: | - git fetch --force --tags - - - name: Create Build Environment - # Some projects don't allow in-source building, so create a separate - # build directory. We'll use this as our working directory for all - # subsequent commands - run: cmake -E make_directory ${{github.workspace}}/build - - - name: Configure CMake - # Use a bash shell so we can use the same syntax for environment - # variable access regardless of the host operating system - shell: bash - working-directory: ${{github.workspace}}/build - # Note the current convention is to use the -S and -B options here to - # specify source and build directories, but this is only available - # with CMake 3.13 and higher. The CMake binaries on the Github Actions - # machines are (as of this writing) 3.12 - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE - - - name: Build - working-directory: ${{github.workspace}}/build - shell: bash - # Execute the build. You can specify a specific target - # with "--target " - run: cmake --build . --config $BUILD_TYPE - - - name: Test - working-directory: ${{github.workspace}}/build - shell: bash - # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more - # detail - run: ctest -C $BUILD_TYPE - - - if: ${{ failure() }} - name: Upload test data - uses: actions/upload-artifact@v2 - with: - name: tests-out - path: tests - - - if: ${{ failure() }} - name: Upload cmake test output - uses: actions/upload-artifact@v2 - with: - name: tests-out - path: build/Testing diff --git a/.gitignore b/.gitignore index 9f436b7..caf8f6f 100644 --- a/.gitignore +++ b/.gitignore @@ -23,7 +23,6 @@ tools/n2n-route build .idea .vscode -cmake-build-default packages/debian/debian/changelog packages/debian/debian/control packages/debian/debian/files @@ -34,8 +33,6 @@ packages/etc/systemd/system/edge@.service packages/etc/systemd/system/supernode.service *dSYM* -cmake-build-*/ - # Binaries built to run tests tools/tests-auth tools/tests-compress diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index f176c59..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,333 +0,0 @@ -project(n2n) -cmake_minimum_required(VERSION 2.6) -include(CheckFunctionExists) -SET(CMAKE_VERBOSE_MAKEFILE ON) - -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - -# N2n release information -execute_process( - COMMAND scripts/version.sh - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - OUTPUT_VARIABLE PACKAGE_VERSION - RESULT_VARIABLE GIT_ERROR_CODE -) -if (NOT GIT_ERROR_CODE EQUAL 0) - # - if we can run version.sh and it exits with an error that is signaling - # a build failure. - # - if we are on windows with no MSYS or Cygwin, we cannot run version.sh - # which is the fallback case handled below - # TODO: Distinguish between these two cases - - # Fallback to just using the non dynamic short version string - file(STRINGS VERSION PACKAGE_VERSION) -endif (NOT GIT_ERROR_CODE EQUAL 0) - -string(STRIP "${PACKAGE_VERSION}" PACKAGE_VERSION) -MESSAGE(STATUS "Build for version: ${PACKAGE_VERSION}") - -add_definitions(-DCMAKE_BUILD) -add_definitions(-DPACKAGE_OSNAME="${CMAKE_SYSTEM_NAME}") -add_definitions(-DPACKAGE_VERSION="${PACKAGE_VERSION}") - -# third-party directory -set(THIRD_PARTY_DIR ${CMAKE_SOURCE_DIR}/thirdparty) - -# Build information -OPTION(BUILD_SHARED_LIBS "BUILD Shared Library" OFF) - -# N2n specific params -OPTION(N2N_OPTION_USE_PTHREAD "USE PTHREAD Library" OFF) -OPTION(N2N_OPTION_USE_OPENSSL "USE OPENSSL Library" OFF) -OPTION(N2N_OPTION_USE_CAPLIB "USE CAP Library" OFF) -OPTION(N2N_OPTION_USE_PCAPLIB "USE PCAP Library" OFF) -OPTION(N2N_OPTION_USE_ZSTD "USE ZSTD Library" OFF) -OPTION(N2N_OPTION_USE_PORTMAPPING "USE MINIUPNP and NATPMP Libraries" OFF) - - -if(N2N_OPTION_USE_PTHREAD) - find_library(PTHREAD_LIB pthread) - if(NOT PTHREAD_LIB) - MESSAGE(FATAL_ERROR "libpthread not found.") - endif(NOT PTHREAD_LIB) - MESSAGE(STATUS "Using libpthread.") - ADD_DEFINITIONS("-DHAVE_PTHREAD") -endif(N2N_OPTION_USE_PTHREAD) - -if(N2N_OPTION_USE_OPENSSL) - find_package(OpenSSL QUIET) - if(NOT OPENSSL_FOUND) - MESSAGE(FATAL_ERROR "OpenSSL not found.") - endif(NOT OPENSSL_FOUND) - MESSAGE(STATUS "Found OpenSSL ${OPENSSL_VERSION}") - string(COMPARE GREATER "${OPENSSL_VERSION}" "1.1" OPENSSL_V11) - if(NOT OPENSSL_V11) - MESSAGE(FATAL_ERROR "OpenSSL too old") - endif() - include_directories(${OPENSSL_INCLUDE_DIR}) - add_definitions(-DHAVE_OPENSSL_1_1) -endif(N2N_OPTION_USE_OPENSSL) - -if(N2N_OPTION_USE_ZSTD) - find_library(LIBZSTD zstd) - if(NOT LIBZSTD) - MESSAGE(FATAL_ERROR "libzstd not found.") - endif(NOT LIBZSTD) - MESSAGE(STATUS "Using libztd.") - add_definitions(-DHAVE_ZSTD) -endif(N2N_OPTION_USE_ZSTD) - -if(N2N_OPTION_USE_PCAPLIB) - find_library(PCAP_LIB pcap) - if(NOT PCAP_LIB) - MESSAGE(FATAL_ERROR "libpcap not found.") - endif(NOT PCAP_LIB) - - # Set var needed for check_function_exists() - set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIB}) - - # TODO - # - pcap_set_immediate_mode has been available since libpcap 1.5 in 2013 - # probably should remove this check - check_function_exists(pcap_set_immediate_mode HAVE_PCAP_IMMEDIATE_MODE) - IF(NOT HAVE_PCAP_IMMEDIATE_MODE) - MESSAGE(FATAL_ERROR "libpcap not support pcap_set_immediate_mode()") - ENDIF(NOT HAVE_PCAP_IMMEDIATE_MODE) - MESSAGE(STATUS "Using libpcap.") - - ADD_DEFINITIONS("-DHAVE_PCAP_IMMEDIATE_MODE") - add_executable(n2n-decode tools/n2n-decode.c) - target_link_libraries(n2n-decode n2n pcap) - install(TARGETS n2n-decode RUNTIME DESTINATION bin) - -endif(N2N_OPTION_USE_PCAPLIB) - -if(N2N_OPTION_USE_CAPLIB) - # Linux Capabilities - find_library(CAP_LIB cap) - if(NOT CAP_LIB) - MESSAGE(FATAL_ERROR "libcap not found.") - endif(NOT CAP_LIB) - MESSAGE(STATUS "Using libcap.") - - ADD_DEFINITIONS("-DHAVE_LIBCAP") - -endif(N2N_OPTION_USE_CAPLIB) - -if(N2N_OPTION_USE_PORTMAPPING) - ADD_DEFINITIONS("-DHAVE_MINIUPNP") - include_directories(${THIRD_PARTY_DIR}/miniupnp/miniupnpc/include) - add_subdirectory(${THIRD_PARTY_DIR}/miniupnp/miniupnpc lib_miniupnpc) - link_directories(${PROJECT_BINARY_DIR}/lib_miniupnpc) - - ADD_DEFINITIONS("-DHAVE_NATPMP") - include_directories(${THIRD_PARTY_DIR}/libnatpmp) - add_subdirectory(${THIRD_PARTY_DIR}/libnatpmp libnatpmp) - link_directories(${PROJECT_BINARY_DIR}/libnatpmp) - - # TODO: - # - this is the odd one out, is it needed? - include_directories(${PROJECT_BINARY_DIR}/lib_miniupnpc) -endif(N2N_OPTION_USE_PORTMAPPING) - - -if(NOT DEFINED CMAKE_BUILD_TYPE) -set(CMAKE_BUILD_TYPE None) -endif(NOT DEFINED CMAKE_BUILD_TYPE) -#set(CMAKE_BUILD_TYPE Debug) -#set(CMAKE_BUILD_TYPE Release) - -if (DEFINED UNIX) -# None -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wshadow -Wpointer-arith -Wmissing-declarations -Wnested-externs") -set(CMAKE_CXX_FLAGS "-Wall -Wshadow -Wpointer-arith -Wmissing-declarations -Wnested-externs") -# Debug -set(CMAKE_C_FLAGS_DEBUG "-g") -set(CMAKE_CXX_FLAGS_DEBUG "-g") -# Release -set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") -endif(DEFINED UNIX) - -# Static target. -#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static") - - -INCLUDE_DIRECTORIES(.) -INCLUDE_DIRECTORIES(include) -if(DEFINED WIN32) - INCLUDE_DIRECTORIES(win32) -# Customize include. -# INCLUDE_DIRECTORIES("D:/Program Files/MinGW/opt/include/" "D:/Program Files/MinGW/x86_64-w64-mingw32/include/") -# Customize library. -# LINK_DIRECTORIES("D:/Program Files/MinGW/opt/lib/" "D:/Program Files/MinGW/x86_64-w64-mingw32/lib/") -endif(DEFINED WIN32) - - -#aux_source_directory(./src N2N_DIR_SRCS) -#add_library(n2n STATIC ${N2N_DIR_SRCS}) -add_library(n2n STATIC - src/n2n.c - src/edge_management.c - src/edge_utils.c - src/sn_management.c - src/sn_utils.c - src/wire.c - src/hexdump.c - src/minilzo.c - src/tf.c - src/cc20.c - src/transform_null.c - src/transform_tf.c - src/transform_aes.c - src/transform_cc20.c - src/transform_speck.c - src/transform_lzo.c - src/transform_zstd.c - src/aes.c - src/speck.c - src/random_numbers.c - src/management.c - src/pearson.c - src/header_encryption.c - src/tuntap_freebsd.c - src/tuntap_netbsd.c - src/tuntap_linux.c - src/tuntap_osx.c - src/n2n_regex.c - src/network_traffic_filter.c - src/sn_selection.c - src/auth.c - src/curve25519.c - src/n2n_port_mapping.c - src/json.c) - - -if(DEFINED WIN32) - add_library(edge_utils_win32 src/edge_utils_win32.c) - add_subdirectory(win32) - target_link_libraries(n2n edge_utils_win32 n2n_win32 iphlpapi netapi32) -endif(DEFINED WIN32) - -add_executable(edge src/edge.c) -target_link_libraries(edge n2n) - -add_executable(supernode src/supernode.c) -target_link_libraries(supernode n2n) - -add_executable(example_edge_embed_quick_edge_init src/example_edge_embed_quick_edge_init.c) -target_link_libraries(example_edge_embed_quick_edge_init n2n) - -add_executable(example_edge_embed src/example_edge_embed.c) -target_link_libraries(example_edge_embed n2n) - -add_executable(example_sn_embed src/example_sn_embed.c) -target_link_libraries(example_sn_embed n2n) - -if(N2N_OPTION_USE_PTHREAD) - target_link_libraries(n2n pthread) -endif(N2N_OPTION_USE_PTHREAD) - -if(N2N_OPTION_USE_OPENSSL) -# target_link_libraries(n2n crypto) - target_link_libraries(n2n ${OPENSSL_LIBRARIES}) -endif(N2N_OPTION_USE_OPENSSL) - -if(N2N_OPTION_USE_ZSTD) - target_link_libraries(n2n ${LIBZSTD}) -endif(N2N_OPTION_USE_ZSTD) - -if(N2N_OPTION_USE_CAPLIB) - target_link_libraries(edge cap) -endif(N2N_OPTION_USE_CAPLIB) - -if(N2N_OPTION_USE_PORTMAPPING) - target_link_libraries(n2n libminiupnpc-static) - target_link_libraries(n2n natpmp) -endif(N2N_OPTION_USE_PORTMAPPING) - -install(TARGETS edge supernode - RUNTIME DESTINATION sbin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - ) - - -# Tools -add_executable(n2n-benchmark tools/n2n-benchmark.c) -target_link_libraries(n2n-benchmark n2n) -add_executable(n2n-keygen tools/n2n-keygen.c) -target_link_libraries(n2n-keygen n2n) -add_executable(n2n-route tools/n2n-route.c) -target_link_libraries(n2n-route n2n) -add_executable(n2n-portfwd tools/n2n-portfwd.c) -target_link_libraries(n2n-portfwd n2n) - -add_executable(tests-auth tools/tests-auth.c) -target_link_libraries(tests-auth n2n) -add_executable(tests-compress tools/tests-compress.c) -target_link_libraries(tests-compress n2n) -add_executable(tests-elliptic tools/tests-elliptic.c) -target_link_libraries(tests-elliptic n2n) -add_executable(tests-hashing tools/tests-hashing.c) -target_link_libraries(tests-hashing n2n) -add_executable(tests-transform tools/tests-transform.c) -target_link_libraries(tests-transform n2n) -add_executable(tests-wire tools/tests-wire.c) -target_link_libraries(tests-wire n2n) - -install(TARGETS n2n-benchmark RUNTIME DESTINATION bin) - -# Documentation -if(DEFINED UNIX) -add_dependencies(n2n doc) -file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/doc) -add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/doc/edge.8.gz - COMMAND gzip -c ${PROJECT_SOURCE_DIR}/edge.8 > ${PROJECT_BINARY_DIR}/doc/edge.8.gz - DEPENDS ${PROJECT_SOURCE_DIR}/edge.8 - ) - -add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/doc/supernode.1.gz - COMMAND gzip -c ${PROJECT_SOURCE_DIR}/supernode.1 > ${PROJECT_BINARY_DIR}/doc/supernode.1.gz - DEPENDS ${PROJECT_SOURCE_DIR}/supernode.1 - ) - -add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/doc/n2n.7.gz - COMMAND gzip -c ${PROJECT_SOURCE_DIR}/n2n.7 > ${PROJECT_BINARY_DIR}/doc/n2n.7.gz - DEPENDS ${PROJECT_SOURCE_DIR}/n2n.7 - ) - -add_custom_target(doc DEPENDS ${PROJECT_BINARY_DIR}/doc/edge.8.gz - ${PROJECT_BINARY_DIR}/doc/supernode.1.gz - ${PROJECT_BINARY_DIR}/doc/n2n.7.gz - ) - -set_source_files_properties(${PROJECT_BINARY_DIR}/doc/edge.8.gz - ${PROJECT_BINARY_DIR}/doc/supernode.1.gz - ${PROJECT_BINARY_DIR}/doc/n2n.7.gz - PROPERTIES GENERATED 1) - -install(FILES ${PROJECT_BINARY_DIR}/doc/edge.8.gz - DESTINATION /usr/share/man/man8) -install(FILES ${PROJECT_BINARY_DIR}/doc/supernode.1.gz - DESTINATION /usr/share/man/man1) -install(FILES ${PROJECT_BINARY_DIR}/doc/n2n.7.gz - DESTINATION /usr/share/man/man7) -endif(DEFINED UNIX) - -if (CMAKE_SYSTEM_NAME STREQUAL Linux) - -# TODO: -# - Add the right dependancy so that the tests binaries get built first -enable_testing() -add_test(NAME unit - COMMAND ${CMAKE_COMMAND} -E env - TOPDIR=${PROJECT_SOURCE_DIR} BINDIR=${PROJECT_BINARY_DIR} - ${PROJECT_SOURCE_DIR}/scripts/test_harness.sh ${PROJECT_SOURCE_DIR}/tests/tests_units.list -) -add_test(NAME integration - COMMAND ${CMAKE_COMMAND} -E env - TOPDIR=${PROJECT_SOURCE_DIR} BINDIR=${PROJECT_BINARY_DIR} - ${PROJECT_SOURCE_DIR}/scripts/test_harness.sh ${PROJECT_SOURCE_DIR}/tests/tests_integration.list -) -endif() diff --git a/README.md b/README.md index 2880344..f1fe589 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ make make install ``` -For Windows, MacOS, CMake, optimizations and general building options, please check out [Building documentation](doc/Building.md) for compilation and running. +For Windows, MacOS, optimizations and general building options, please check out [Building documentation](doc/Building.md) for compilation and running. **IMPORTANT** It is generally recommended to use the [latest stable release](https://github.com/ntop/n2n/releases). Please note that the current _dev_ branch usually is not guaranteed to be backward compatible neither with the latest stable release nor with previous _dev_ states. On the other hand, if you dare to try bleeding edge features, you are encouraged to compile from _dev_ – just keep track of sometimes rapidly occuring changes. Feedback in the _Issues_ section is appreciated. diff --git a/doc/BuildConfig.md b/doc/BuildConfig.md index e0488c2..13fe600 100644 --- a/doc/BuildConfig.md +++ b/doc/BuildConfig.md @@ -12,8 +12,7 @@ configuration settings are being removed. ## Options After changing any configuration, please do no forget to `make clean` after -the (re-)configuration and before building (again) using `make`. (Or the -equivalent with `cmake`) +the (re-)configuration and before building (again) using `make`. ### `--with-zstd` @@ -50,19 +49,7 @@ the hardware support and compiler optimizations such as. `./configure --with-openssl CFLAGS="-O3 -march=native"` -#### Makefile - -Add `--with-openssl` to the `configure` command - -#### Cmake - -Add `-DN2N_OPTION_USE_OPENSSL=ON` to the cmake configure step. - -Additionally, it is possible to statically link the OpenSSL library. -Add `-DOPENSSL_USE_STATIC_LIBS=true` to the cmake configure step. - -Building statically with openssl in this way has been known to have -issues recently on Windows (See #944) +To activate, add `--with-openssl` to the `configure` command ### `--with-edgex` @@ -127,18 +114,6 @@ the correctness of configuration and compilation, `--enable-X` style options are preferred. As part of this, the older `--with-X` options will eventually be migrated to use `--enable-X` -## CMake configuration - -There are a number of OPTION statements in the CMakeLists.txt file that can -have their settings changed. This is done by adding a commandline option -to the cmake configure stage. - -e.g: -`cmake -DN2N_OPTION_USE_ZSTD=ON ..` - -Note that the names of the configure option variables used in the cmake -process will probably change to make the source code consistent. - # Optimisation options ## Compiler Optimizations diff --git a/doc/Building.md b/doc/Building.md index cca09c7..5e162ef 100644 --- a/doc/Building.md +++ b/doc/Building.md @@ -47,52 +47,10 @@ these difficulties are being discussed for future n2n versions. # Build on Windows -The following document some possible windows compile recipes. Of them, the -MinGW build process is more tested as it is more friendly to open source +The following document one possible windows compile recipe. The reason +a MinGW build process is used is it is more friendly to open source development. -## Visual Studio - -### Requirements -In order to build with Vidual Studio on Windows the following tools should be installed: - -- Visual Studio. For a minimal install, the command line only build tools can be - downloaded and installed from https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2017. - -- CMake (From https://cmake.org/download/) - - NOTE: You should always use the official cmake stable release as otherwise - you may have issues finding libraries (e.g: the installed OpenSSL library). - If you still have problems, you can try invoking it with `C:\Program Files\CMake\bin\cmake`. - -- (optional) The OpenSSL library. This optional library can be enabled as - per the steps in the [Build time Configuration](BuildConfig.md) - - Pre-built OpenSSL binaries can be downloaded from - https://slproweb.com/products/Win32OpenSSL.html. - The full version is required, i.e. not the "Light" version. The Win32 - version of it is usually required for a standard build. - -### CLI steps - -In order to build from the command line, open a terminal window change to -the directory where the git checkout of this repository is and run the -following commands: - -Building using `cmake` works as follows: - -```batch -cmake -E make_directory build -cd build - -rem Append any options to the next line -cmake .. - -cmake --build . --config Release -``` - -The compiled `.exe` files should now be available in the `build\Release` directory. - ## MinGW These steps were tested on a fresh install of Windows 10 Pro with all patches diff --git a/doc/Tools.md b/doc/Tools.md index 17f2b64..f350af8 100644 --- a/doc/Tools.md +++ b/doc/Tools.md @@ -47,13 +47,6 @@ Note that n2n needs to be compiled with the corresponding options enabled, e.g. ./configure --enable-miniupnp --enable-natpmp ``` -or - -``` -`cmake -DN2N_OPTION_USE_PORTMAPPING=ON` - -``` - Also see [build configuration](BuildConfig.md). Example: diff --git a/include/n2n.h b/include/n2n.h index 1ec4a2e..ec53772 100644 --- a/include/n2n.h +++ b/include/n2n.h @@ -38,21 +38,14 @@ /* #define N2N_CAN_NAME_IFACE */ +#include "config.h" /* Visual C++ */ + /* Moved here to define _CRT_SECURE_NO_WARNINGS before all the including takes place */ #ifdef WIN32 -#ifndef CMAKE_BUILD -#include "config.h" /* Visual C++ */ -#else -#include "winconfig.h" -#endif #define N2N_CAN_NAME_IFACE 1 #undef N2N_HAVE_DAEMON #undef N2N_HAVE_TCP /* as explained on https://github.com/ntop/n2n/pull/627#issuecomment-782093706 */ #undef N2N_HAVE_SETUID -#else -#ifndef CMAKE_BUILD -#include "config.h" -#endif #endif diff --git a/include/n2n_port_mapping.h b/include/n2n_port_mapping.h index e0c9006..2ecf65e 100644 --- a/include/n2n_port_mapping.h +++ b/include/n2n_port_mapping.h @@ -24,17 +24,9 @@ #include #ifdef HAVE_MINIUPNP -#ifdef CMAKE_BUILD -// CMAKE uses statically linked lib as submodule which requires different includes than -// the dynamically linked, intalled library in case of plain make -#include -#include -#include -#else #include #include #include -#endif // CMAKE_BUILD #endif // HAVE_MINIUPNP diff --git a/scripts/cmake_all.sh b/scripts/cmake_all.sh deleted file mode 100755 index 74c605b..0000000 --- a/scripts/cmake_all.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# -# Well, cmake might be approximately the same as ./configure && make, but it -# never rolls off the fingers as easily -# - -if [ ! -f CMakeLists.txt ]; then - echo ERROR: run this script from the TOPDIR - exit 1 -fi - -OPTS="" -#OPTS+=" -DN2N_OPTION_USE_PTHREAD=ON" -#OPTS+=" -DN2N_OPTION_USE_OPENSSL=ON" -#OPTS+=" -DN2N_OPTION_USE_CAPLIB=ON" -#OPTS+=" -DN2N_OPTION_USE_PCAPLIB=ON" -#OPTS+=" -DN2N_OPTION_USE_ZSTD=ON" -#OPTS+=" -DN2N_OPTION_USE_PORTMAPPING=ON" - -#OPTS+=" -DOPENSSL_USE_STATIC_LIBS=true" - -set -e - -rm -rf build - -cmake -E make_directory build -cd build - -# Shell check wants me to use an array in this scenario. Bourne shell -# arrays are my line in the sand showing that a script should not be -# written in such a horrible language. Since it would be silly to rewrite -# a one-page wrapper script in python, we submit that this check is wrong. -# shellcheck disable=SC2086 -cmake .. $OPTS - -cmake --build . --config Release - -ctest