mirror of https://github.com/PurpleI2P/i2pd.git
orignal
10 years ago
2 changed files with 149 additions and 110 deletions
@ -0,0 +1,51 @@ |
|||||||
|
Build notes |
||||||
|
=========== |
||||||
|
|
||||||
|
Common build/install process: |
||||||
|
|
||||||
|
git clone https://github.com/PrivacySolutions/i2pd.git |
||||||
|
cd i2pd/build |
||||||
|
cmake -DCMAKE_BUILD_TYPE=Release <more options> . |
||||||
|
make |
||||||
|
make install |
||||||
|
|
||||||
|
Available cmake options: |
||||||
|
|
||||||
|
* CMAKE_BUILD_TYPE -- build profile (Debug/Release) |
||||||
|
* WITH_AESNI -- AES-NI support (ON/OFF) |
||||||
|
* WITH_HARDENING -- enable hardening features (ON/OFF) (gcc only) |
||||||
|
|
||||||
|
Debian |
||||||
|
------ |
||||||
|
|
||||||
|
Required "-dev" packages: |
||||||
|
|
||||||
|
* cmake |
||||||
|
* libboost-filesystem-dev |
||||||
|
* libboost-program-options-dev |
||||||
|
* libboost-regex-dev |
||||||
|
* libboost-system-dev |
||||||
|
* libcrypto++-dev |
||||||
|
|
||||||
|
FreeBSD |
||||||
|
------- |
||||||
|
|
||||||
|
Branch 9.X has gcc v4.2, that knows nothing about required c++11 standart. |
||||||
|
|
||||||
|
Required ports: |
||||||
|
|
||||||
|
* devel/cmake |
||||||
|
* devel/boost-libs |
||||||
|
* lang/gcc47 # or later version |
||||||
|
* security/cryptopp |
||||||
|
|
||||||
|
To use newer compiler you should set these variables: |
||||||
|
|
||||||
|
export CC=/usr/local/bin/gcc47 |
||||||
|
export CXX=/usr/local/bin/g++47 |
||||||
|
|
||||||
|
Replace "47" with your actual gcc version |
||||||
|
|
||||||
|
Branch 10.X has more reliable clang version, that can finally build i2pd, |
||||||
|
but i still recommend to use gcc, otherwise you will fight it's bugs by |
||||||
|
your own. |
@ -1,135 +1,123 @@ |
|||||||
cmake_minimum_required ( VERSION 2.8 ) |
cmake_minimum_required ( VERSION 2.8 ) |
||||||
project ( i2pd ) |
project ( "i2pd" ) |
||||||
|
|
||||||
# Default build is Debug |
# configurale options |
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall") |
option(WITH_AESNI "Use AES-NI instructions set" OFF) |
||||||
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall") |
option(WITH_HARDENING "Use hardening compiler flags" OFF) |
||||||
|
|
||||||
set ( SRC_DIR ".." ) |
|
||||||
set ( INC_DIR ".." ) |
|
||||||
|
|
||||||
|
|
||||||
add_definitions ( "-std=c++0x -Wall" ) |
|
||||||
|
|
||||||
set ( SOURCES |
|
||||||
CryptoConst.cpp |
|
||||||
AddressBook.cpp |
|
||||||
Garlic.cpp |
|
||||||
HTTPServer.cpp |
|
||||||
i2p.cpp |
|
||||||
Identity.cpp |
|
||||||
Log.cpp |
|
||||||
NTCPSession.cpp |
|
||||||
RouterContext.cpp |
|
||||||
SSU.cpp |
|
||||||
SSUData.cpp |
|
||||||
TransitTunnel.cpp |
|
||||||
Tunnel.cpp |
|
||||||
TunnelGateway.cpp |
|
||||||
UPnP.cpp |
|
||||||
base64.cpp |
|
||||||
HTTPProxy.cpp |
|
||||||
I2NPProtocol.cpp |
|
||||||
LeaseSet.cpp |
|
||||||
NetDb.cpp |
|
||||||
Reseed.cpp |
|
||||||
RouterInfo.cpp |
|
||||||
Streaming.cpp |
|
||||||
Transports.cpp |
|
||||||
TunnelEndpoint.cpp |
|
||||||
TunnelPool.cpp |
|
||||||
util.cpp |
|
||||||
aes.cpp |
|
||||||
Daemon.cpp |
|
||||||
SOCKS.cpp |
|
||||||
I2PTunnel.cpp |
|
||||||
) |
|
||||||
|
|
||||||
set ( HEADERS |
# paths |
||||||
CryptoConst.h |
set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" ) |
||||||
AddressBook.h |
set ( CMAKE_SOURCE_DIR ".." ) |
||||||
Garlic.h |
|
||||||
HTTPServer.h |
set (SOURCES |
||||||
Identity.h |
"${CMAKE_SOURCE_DIR}/AddressBook.cpp" |
||||||
Log.h |
"${CMAKE_SOURCE_DIR}/CryptoConst.cpp" |
||||||
NTCPSession.h |
"${CMAKE_SOURCE_DIR}/Daemon.cpp" |
||||||
RouterContext.h |
"${CMAKE_SOURCE_DIR}/Garlic.cpp" |
||||||
SSU.h |
"${CMAKE_SOURCE_DIR}/HTTPProxy.cpp" |
||||||
SSUData.h |
"${CMAKE_SOURCE_DIR}/HTTPServer.cpp" |
||||||
TransitTunnel.h |
"${CMAKE_SOURCE_DIR}/I2NPProtocol.cpp" |
||||||
Tunnel.h |
"${CMAKE_SOURCE_DIR}/I2PTunnel.cpp" |
||||||
TunnelGateway.h |
"${CMAKE_SOURCE_DIR}/Identity.cpp" |
||||||
UPnP.h |
"${CMAKE_SOURCE_DIR}/LeaseSet.cpp" |
||||||
base64.h |
"${CMAKE_SOURCE_DIR}/Log.cpp" |
||||||
HTTPProxy.h |
"${CMAKE_SOURCE_DIR}/NTCPSession.cpp" |
||||||
I2NPProtocol.h |
"${CMAKE_SOURCE_DIR}/NetDb.cpp" |
||||||
LeaseSet.h |
"${CMAKE_SOURCE_DIR}/Reseed.cpp" |
||||||
NetDb.h |
"${CMAKE_SOURCE_DIR}/RouterContext.cpp" |
||||||
Reseed.h |
"${CMAKE_SOURCE_DIR}/RouterInfo.cpp" |
||||||
RouterInfo.h |
"${CMAKE_SOURCE_DIR}/SOCKS.cpp" |
||||||
Streaming.h |
"${CMAKE_SOURCE_DIR}/SSU.cpp" |
||||||
Transports.h |
"${CMAKE_SOURCE_DIR}/SSUData.cpp" |
||||||
TunnelEndpoint.h |
"${CMAKE_SOURCE_DIR}/Streaming.cpp" |
||||||
TunnelPool.h |
"${CMAKE_SOURCE_DIR}/TransitTunnel.cpp" |
||||||
util.h |
"${CMAKE_SOURCE_DIR}/Tunnel.cpp" |
||||||
aes.h |
"${CMAKE_SOURCE_DIR}/TunnelGateway.cpp" |
||||||
Daemon.h |
"${CMAKE_SOURCE_DIR}/Transports.cpp" |
||||||
SOCKS.h |
"${CMAKE_SOURCE_DIR}/TunnelEndpoint.cpp" |
||||||
I2PTunnel.h |
"${CMAKE_SOURCE_DIR}/TunnelPool.cpp" |
||||||
version.h |
"${CMAKE_SOURCE_DIR}/UPnP.cpp" |
||||||
Signature.h |
"${CMAKE_SOURCE_DIR}/aes.cpp" |
||||||
|
"${CMAKE_SOURCE_DIR}/base64.cpp" |
||||||
|
"${CMAKE_SOURCE_DIR}/i2p.cpp" |
||||||
|
"${CMAKE_SOURCE_DIR}/util.cpp" |
||||||
) |
) |
||||||
|
|
||||||
if (WIN32) |
file (GLOB HEADERS "${CMAKE_SOURCE_DIR}/*.h") |
||||||
list (APPEND SOURCES DeamonWin32.cpp) |
|
||||||
|
# MSVS grouping |
||||||
|
source_group ("Header Files" FILES ${HEADERS}) |
||||||
|
source_group ("Source Files" FILES ${SOURCES}) |
||||||
|
|
||||||
|
# Default build is Debug |
||||||
|
if (CMAKE_BUILD_TYPE STREQUAL "Release") |
||||||
|
add_definitions( "-pedantic" ) |
||||||
else () |
else () |
||||||
list (APPEND SOURCES DaemonLinux.cpp) |
set(CMAKE_BUILD_TYPE Debug) |
||||||
endif () |
endif () |
||||||
|
|
||||||
|
# compiler flags customization (by vendor) |
||||||
|
add_definitions ( "-Wall -Wextra" ) |
||||||
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
||||||
|
add_definitions( "-std=c++11" ) |
||||||
|
if (WITH_HARDENING) |
||||||
|
add_definitions( "-D_FORTIFY_SOURCE=2" ) |
||||||
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat -Wformat-security -Werror=format-security" ) |
||||||
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector --param ssp-buffer-size=4" ) |
||||||
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -pie" ) |
||||||
|
endif () |
||||||
|
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
||||||
|
add_definitions( "-std=c++11" ) |
||||||
|
endif () |
||||||
|
|
||||||
|
# compiler flags customization (by system) |
||||||
|
if (CMAKE_SYSTEM_NAME STREQUAL "Linux") |
||||||
|
list (APPEND SOURCES "../DaemonLinux.cpp") |
||||||
|
elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") |
||||||
|
list (APPEND SOURCES "../DaemonLinux.cpp") |
||||||
|
# "'sleep_for' is not a member of 'std::this_thread'" in gcc 4.7/4.8 |
||||||
|
add_definitions( "-D_GLIBCXX_USE_NANOSLEEP=1" ) |
||||||
|
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows") |
||||||
|
list (APPEND SOURCES "../DaemonWin32.cpp") |
||||||
|
endif () |
||||||
|
|
||||||
source_group ("Header Files" FILES ${HEADERS}) |
if (WITH_AESNI) |
||||||
source_group ("Source Files" FILES ${SOURCES}) |
add_definitions ( "-maes -DAESNI" ) |
||||||
|
endif() |
||||||
set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" ) |
|
||||||
|
|
||||||
|
# libraries |
||||||
find_package ( Threads REQUIRED ) |
find_package ( Threads REQUIRED ) |
||||||
|
|
||||||
find_package ( Boost COMPONENTS system filesystem regex program_options REQUIRED ) |
find_package ( Boost COMPONENTS system filesystem regex program_options REQUIRED ) |
||||||
|
|
||||||
find_package ( CryptoPP REQUIRED ) |
|
||||||
|
|
||||||
# Check for libraries |
|
||||||
if(NOT DEFINED Boost_INCLUDE_DIRS) |
if(NOT DEFINED Boost_INCLUDE_DIRS) |
||||||
message(FATAL_ERROR "Boost is not found, or your boost version was bellow 1.46. Please download Boost!") |
message(SEND_ERROR "Boost is not found, or your boost version was bellow 1.46. Please download Boost!") |
||||||
return() |
|
||||||
endif() |
endif() |
||||||
|
|
||||||
|
find_package ( CryptoPP REQUIRED ) |
||||||
if(NOT DEFINED CRYPTO++_INCLUDE_DIR) |
if(NOT DEFINED CRYPTO++_INCLUDE_DIR) |
||||||
message(FATAL_ERROR "Could not find Crypto++. Please download and install it first!") |
message(SEND_ERROR "Could not find Crypto++. Please download and install it first!") |
||||||
return() |
|
||||||
endif() |
endif() |
||||||
|
|
||||||
|
# load includes |
||||||
|
include_directories( ${Boost_INCLUDE_DIRS} ${CRYPTO++_INCLUDE_DIR}) |
||||||
|
|
||||||
# End checks |
# show summary |
||||||
|
message(STATUS "---------------------------------------") |
||||||
|
message(STATUS "Build type : ${CMAKE_BUILD_TYPE}") |
||||||
|
message(STATUS "Compiler vendor : ${CMAKE_CXX_COMPILER_ID}") |
||||||
|
message(STATUS "Compiler path : ${CMAKE_CXX_COMPILER}") |
||||||
|
message(STATUS "Install prefix: : ${CMAKE_INSTALL_PREFIX}") |
||||||
|
message(STATUS "Options:") |
||||||
|
message(STATUS " AESNI : ${WITH_AESNI}") |
||||||
|
message(STATUS " HARDENING : ${WITH_HARDENING}") |
||||||
|
message(STATUS "---------------------------------------") |
||||||
|
|
||||||
include_directories ( ${Boost_INCLUDE_DIRS} ${CRYPTO++_INCLUDE_DIR}) |
add_executable ( ${PROJECT_NAME} ${SOURCES} ) |
||||||
|
|
||||||
|
if (WITH_HARDENING AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
||||||
unset ( TMP ) |
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-z relro -z now" ) |
||||||
foreach ( src ${SOURCES} ) |
endif () |
||||||
list ( APPEND TMP "${SRC_DIR}/${src}" ) |
|
||||||
endforeach () |
|
||||||
set ( SOURCES ${TMP} ) |
|
||||||
|
|
||||||
unset ( TMP ) |
|
||||||
foreach ( hdr ${HEADERS} ) |
|
||||||
list ( APPEND TMP "${INC_DIR}/${hdr}" ) |
|
||||||
endforeach () |
|
||||||
set ( HEADERS ${TMP} ) |
|
||||||
|
|
||||||
|
|
||||||
add_executable ( ${PROJECT_NAME} WIN32 ${HEADERS} ${SOURCES} ) |
|
||||||
|
|
||||||
target_link_libraries( ${PROJECT_NAME} ${Boost_LIBRARIES} ${CRYPTO++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) |
target_link_libraries( ${PROJECT_NAME} ${Boost_LIBRARIES} ${CRYPTO++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) |
||||||
|
|
||||||
|
install(TARGETS i2pd RUNTIME DESTINATION "bin") |
||||||
|
Loading…
Reference in new issue