|
@ -1,31 +1,60 @@ |
|
|
project(n2n) |
|
|
project(n2n) |
|
|
cmake_minimum_required(VERSION 2.6) |
|
|
cmake_minimum_required(VERSION 2.6) |
|
|
include(CheckFunctionExists) |
|
|
include(CheckFunctionExists) |
|
|
|
|
|
SET(CMAKE_VERBOSE_MAKEFILE ON) |
|
|
|
|
|
|
|
|
# N2n information |
|
|
# N2n release information |
|
|
set(N2N_VERSION 2.5.1) |
|
|
set(N2N_VERSION "2.7.0") |
|
|
set(N2N_OSNAME ${CMAKE_SYSTEM}) |
|
|
set(N2N_OSNAME ${CMAKE_SYSTEM}) |
|
|
|
|
|
execute_process( |
|
|
|
|
|
COMMAND git --version |
|
|
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} |
|
|
|
|
|
OUTPUT_VARIABLE GIT_EXIST |
|
|
|
|
|
) |
|
|
|
|
|
if (GIT_EXIST) |
|
|
|
|
|
execute_process( |
|
|
|
|
|
COMMAND git rev-list --count HEAD |
|
|
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} |
|
|
|
|
|
OUTPUT_VARIABLE GIT_REV |
|
|
|
|
|
) |
|
|
|
|
|
execute_process( |
|
|
|
|
|
COMMAND git rev-parse --short HEAD |
|
|
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} |
|
|
|
|
|
OUTPUT_VARIABLE GIT_ID |
|
|
|
|
|
) |
|
|
|
|
|
string(REGEX REPLACE "\n$" "" GIT_REV "${GIT_REV}") |
|
|
|
|
|
string(REGEX REPLACE "\n$" "" GIT_ID "${GIT_ID}") |
|
|
|
|
|
set(N2N_VERSION "${N2N_VERSION}.r${GIT_REV}.${GIT_ID}") |
|
|
|
|
|
MESSAGE(STATUS "Build from git rev: ${N2N_VERSION}") |
|
|
|
|
|
endif (GIT_EXIST) |
|
|
|
|
|
|
|
|
|
|
|
add_definitions(-DCMAKE_BUILD) |
|
|
|
|
|
add_definitions(-DGIT_RELEASE="" -DPACKAGE_VERSION="${N2N_VERSION}" -DPACKAGE_OSNAME="${N2N_OSNAME}") |
|
|
|
|
|
add_definitions(-DN2N_VERSION="${N2N_VERSION}" -DN2N_OSNAME="${N2N_OSNAME}") |
|
|
|
|
|
|
|
|
# N2n specific params |
|
|
|
|
|
OPTION(N2N_OPTION_AES "USE AES" ON) |
|
|
|
|
|
|
|
|
|
|
|
# Build information |
|
|
# Build information |
|
|
OPTION(BUILD_SHARED_LIBS "BUILD Shared Library" OFF) |
|
|
OPTION(BUILD_SHARED_LIBS "BUILD Shared Library" OFF) |
|
|
|
|
|
|
|
|
|
|
|
# N2n specific params |
|
|
|
|
|
OPTION(N2N_OPTION_AES "USE AES" ON) |
|
|
|
|
|
|
|
|
if(NOT DEFINED N2N_OPTION_AES) |
|
|
if(NOT DEFINED N2N_OPTION_AES) |
|
|
set(N2N_OPTION_AES ON) |
|
|
set(N2N_OPTION_AES ON) |
|
|
endif(NOT DEFINED N2N_OPTION_AES) |
|
|
endif(NOT DEFINED N2N_OPTION_AES) |
|
|
|
|
|
|
|
|
add_definitions(-DCMAKE_BUILD) |
|
|
|
|
|
add_definitions(-DGIT_RELEASE="" -DPACKAGE_VERSION="${N2N_VERSION}" -DPACKAGE_OSNAME="${CMAKE_SYSTEM}") |
|
|
|
|
|
add_definitions(-DN2N_VERSION="${N2N_VERSION}" -DN2N_OSNAME="${N2N_OSNAME}") |
|
|
|
|
|
|
|
|
|
|
|
if(N2N_OPTION_AES) |
|
|
if(N2N_OPTION_AES) |
|
|
find_package(OpenSSL REQUIRED) |
|
|
find_package(OpenSSL QUIET) |
|
|
add_definitions(-DN2N_HAVE_AES) |
|
|
if(NOT OPENSSL_FOUND) |
|
|
|
|
|
MESSAGE(WARNING "OpenSSL not found, AES disabled.") |
|
|
|
|
|
set(N2N_OPTION_AES OFF) |
|
|
|
|
|
else() |
|
|
|
|
|
include_directories(${OPENSSL_INCLUDE_DIR}) |
|
|
|
|
|
add_definitions(-DN2N_HAVE_AES) |
|
|
|
|
|
endif(NOT OPENSSL_FOUND) |
|
|
endif(N2N_OPTION_AES) |
|
|
endif(N2N_OPTION_AES) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(NOT DEFINED CMAKE_BUILD_TYPE) |
|
|
if(NOT DEFINED CMAKE_BUILD_TYPE) |
|
|
set(CMAKE_BUILD_TYPE None) |
|
|
set(CMAKE_BUILD_TYPE None) |
|
|
endif(NOT DEFINED CMAKE_BUILD_TYPE) |
|
|
endif(NOT DEFINED CMAKE_BUILD_TYPE) |
|
@ -42,60 +71,69 @@ set(CMAKE_CXX_FLAGS_DEBUG "-g") |
|
|
# Release |
|
|
# Release |
|
|
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") |
|
|
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") |
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") |
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") |
|
|
endif() |
|
|
endif(DEFINED UNIX) |
|
|
|
|
|
|
|
|
## DEBUG FOR CMAKE |
|
|
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static") |
|
|
#message(${N2N_VERSION}) |
|
|
|
|
|
#message(${N2N_OSNAME}) |
|
|
|
|
|
##message(${CMAKE_BUILD_TYPE}) |
|
|
INCLUDE_DIRECTORIES(.) |
|
|
#message(${N2N_OPTION_AES}) |
|
|
INCLUDE_DIRECTORIES(include) |
|
|
## DEBUG FOR CMAKE |
|
|
if(DEFINED WIN32) |
|
|
|
|
|
INCLUDE_DIRECTORIES(win32) |
|
|
# Add SHARED to build DLL |
|
|
# INCLUDE_DIRECTORIES("D:/Program Files/MinGW/opt/include/" "D:/Program Files/MinGW/x86_64-w64-mingw32/include/") |
|
|
add_library(n2n n2n.c |
|
|
# LINK_DIRECTORIES("D:/Program Files/MinGW/opt/lib/" "D:/Program Files/MinGW/x86_64-w64-mingw32/lib/") |
|
|
edge_utils.c |
|
|
endif(DEFINED WIN32) |
|
|
sn_utils.c |
|
|
|
|
|
wire.c |
|
|
|
|
|
minilzo.c |
|
|
#aux_source_directory(./src N2N_DIR_SRCS) |
|
|
twofish.c |
|
|
#add_library(n2n STATIC ${N2N_DIR_SRCS}) |
|
|
transform_null.c |
|
|
add_library(n2n STATIC |
|
|
transform_tf.c |
|
|
src/n2n.c |
|
|
transform_aes.c |
|
|
src/edge_utils.c |
|
|
transform_cc20.c |
|
|
src/sn_utils.c |
|
|
transform_speck.c |
|
|
src/wire.c |
|
|
speck.c |
|
|
src/minilzo.c |
|
|
random_numbers.c |
|
|
src/twofish.c |
|
|
pearson.c |
|
|
src/transform_null.c |
|
|
header_encryption.c |
|
|
src/transform_tf.c |
|
|
tuntap_freebsd.c |
|
|
src/transform_aes.c |
|
|
tuntap_netbsd.c |
|
|
src/transform_cc20.c |
|
|
tuntap_linux.c |
|
|
src/transform_speck.c |
|
|
tuntap_osx.c |
|
|
src/speck.c |
|
|
|
|
|
src/random_numbers.c |
|
|
|
|
|
src/pearson.c |
|
|
|
|
|
src/header_encryption.c |
|
|
|
|
|
src/tuntap_freebsd.c |
|
|
|
|
|
src/tuntap_netbsd.c |
|
|
|
|
|
src/tuntap_linux.c |
|
|
|
|
|
src/tuntap_osx.c |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
if(DEFINED WIN32) |
|
|
if(DEFINED WIN32) |
|
|
add_subdirectory(win32) |
|
|
add_library(edge_utils_win32 src/edge_utils_win32.c) |
|
|
target_link_libraries(n2n n2n_win32) |
|
|
add_subdirectory(win32) |
|
|
|
|
|
target_link_libraries(n2n edge_utils_win32 n2n_win32 ) |
|
|
endif(DEFINED WIN32) |
|
|
endif(DEFINED WIN32) |
|
|
|
|
|
|
|
|
if(N2N_OPTION_AES) |
|
|
if(N2N_OPTION_AES) |
|
|
target_link_libraries(n2n ${OPENSSL_LIBRARIES}) |
|
|
# target_link_libraries(n2n crypto) |
|
|
include_directories(${OPENSSL_INCLUDE_DIR}) |
|
|
target_link_libraries(n2n ${OPENSSL_LIBRARIES}) |
|
|
endif(N2N_OPTION_AES) |
|
|
endif(N2N_OPTION_AES) |
|
|
|
|
|
|
|
|
add_executable(edge edge.c) |
|
|
|
|
|
|
|
|
add_executable(edge src/edge.c) |
|
|
target_link_libraries(edge n2n) |
|
|
target_link_libraries(edge n2n) |
|
|
|
|
|
|
|
|
add_executable(supernode sn.c) |
|
|
add_executable(supernode src/sn.c) |
|
|
target_link_libraries(supernode n2n) |
|
|
target_link_libraries(supernode n2n) |
|
|
|
|
|
|
|
|
add_executable(example_edge_embed_quick_edge_init example_edge_embed_quick_edge_init.c) |
|
|
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) |
|
|
target_link_libraries(example_edge_embed_quick_edge_init n2n) |
|
|
|
|
|
|
|
|
add_executable(example_edge_embed example_edge_embed.c) |
|
|
add_executable(example_edge_embed src/example_edge_embed.c) |
|
|
target_link_libraries(example_edge_embed n2n) |
|
|
target_link_libraries(example_edge_embed n2n) |
|
|
|
|
|
|
|
|
add_executable(example_sn_embed example_sn_embed.c) |
|
|
add_executable(example_sn_embed src/example_sn_embed.c) |
|
|
target_link_libraries(example_sn_embed n2n) |
|
|
target_link_libraries(example_sn_embed n2n) |
|
|
|
|
|
|
|
|
if(NOT DEFINED WIN32) |
|
|
if(NOT DEFINED WIN32) |
|
@ -114,9 +152,8 @@ install(TARGETS edge supernode |
|
|
ARCHIVE DESTINATION lib |
|
|
ARCHIVE DESTINATION lib |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
# Tools |
|
|
|
|
|
include_directories(.) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Tools |
|
|
add_executable(n2n-benchmark tools/benchmark.c) |
|
|
add_executable(n2n-benchmark tools/benchmark.c) |
|
|
target_link_libraries(n2n-benchmark n2n ${OPENSSL_LIBRARIES}) |
|
|
target_link_libraries(n2n-benchmark n2n ${OPENSSL_LIBRARIES}) |
|
|
|
|
|
|
|
@ -130,8 +167,8 @@ if(PCAP_LIB) |
|
|
check_function_exists(pcap_set_immediate_mode HAVE_PCAP_IMMEDIATE_MODE) |
|
|
check_function_exists(pcap_set_immediate_mode HAVE_PCAP_IMMEDIATE_MODE) |
|
|
IF(HAVE_PCAP_IMMEDIATE_MODE) |
|
|
IF(HAVE_PCAP_IMMEDIATE_MODE) |
|
|
ADD_DEFINITIONS("-DHAVE_PCAP_IMMEDIATE_MODE") |
|
|
ADD_DEFINITIONS("-DHAVE_PCAP_IMMEDIATE_MODE") |
|
|
ENDIF() |
|
|
ENDIF(HAVE_PCAP_IMMEDIATE_MODE) |
|
|
endif() |
|
|
endif(PCAP_LIB) |
|
|
|
|
|
|
|
|
install(TARGETS n2n-benchmark RUNTIME DESTINATION bin) |
|
|
install(TARGETS n2n-benchmark RUNTIME DESTINATION bin) |
|
|
|
|
|
|
|
|