From 1dee71a6079d3e564fd7e3d1e6e69e7f4abf8350 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 10:15:22 +0200 Subject: [PATCH 01/29] added static build dependency instructions to README --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ee6ef0545..8ec56a53b 100644 --- a/README.md +++ b/README.md @@ -51,11 +51,12 @@ Parts of the project are originally copyright (c) 2012-2013 The Cryptonote devel ### On Unix and Linux: Dependencies: GCC 4.7.3 or later, CMake 2.8.6 or later, libunbound 1.4.16 or later (note: Unbound is not a dependency, libunbound is), and Boost 1.53 or later (except 1.54, [more details here](http://goo.gl/RrCFmA)). +Static Build Additional Dependencies: ldns 1.6.17 or later, expat 1.1 or later **Basic Process:** * To build, change to the root of the source code directory, and run `make`. -* The resulting executables can be found in build/release/src. +* The resulting executables can be found in `build/release/src` or `build/debug/src`, depending on what you're building. **Advanced options:** @@ -78,6 +79,7 @@ Alternatively, it can be built in an easier and more automated fashion using Hom ### On Windows: Dependencies: mingw-w64, msys2, CMake 2.8.6 or later, libunbound 1.4.16 or later (note: Unbound is not a dependency, libunbound is), and Boost 1.53 or 1.55 (except 1.54, [more details here](http://goo.gl/RrCFmA)). +Static Build Additional Dependencies: ldns 1.6.17 or later, expat 1.1 or later **Preparing the Build Environment** @@ -91,6 +93,7 @@ pacman -Su ``` * For those of you already familiar with pacman, you can run the normal `pacman -Syu` to update, but you may get errors and need to restart MSYS2 if pacman's dependencies are updated. * Install dependencies: `pacman -S mingw-w64-x86_64-gcc make mingw-w64-x86_64-cmake mingw-w64-x86_64-unbound mingw-w64-x86_64-boost` +* If you are planning to build statically you will also need to install: `pacman -S mingw-w64-x86_64-ldns mingw-w64-x86_64-expat` (note that these are likely already installed by the unbound dependency installation above) **Building** @@ -108,9 +111,17 @@ cmake -G "MSYS Makefiles" -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=.. cmake -G "MSYS Makefiles" -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=../cmake/32-bit-toolchain.cmake -D MSYS2_FOLDER=c:/msys32 .. ``` * You can now run `make` to have it build +* The resulting executables can be found in `build/release/src` or `build/debug/src`, depending on what you're building. If you installed MSYS2 in a folder other than c:/msys64, make the appropriate substitution above. +**Advanced options:** + +* Parallel build: run `make -j` instead of `make`. +* Statically linked release build: run `make release-static`. +* Debug build: run `make build-debug`. +* Test suite: run `make test-release` to run tests in addition to building. Running `make test-debug` will do the same to the debug version. + ### On FreeBSD: The project can be built from scratch by following instructions for Unix and Linux above. From ff3a7660389ca53354dc3d4e1a0da9bf9db7f4d8 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 10:15:22 +0200 Subject: [PATCH 02/29] added static build dependency instructions to README --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ee6ef0545..8ec56a53b 100644 --- a/README.md +++ b/README.md @@ -51,11 +51,12 @@ Parts of the project are originally copyright (c) 2012-2013 The Cryptonote devel ### On Unix and Linux: Dependencies: GCC 4.7.3 or later, CMake 2.8.6 or later, libunbound 1.4.16 or later (note: Unbound is not a dependency, libunbound is), and Boost 1.53 or later (except 1.54, [more details here](http://goo.gl/RrCFmA)). +Static Build Additional Dependencies: ldns 1.6.17 or later, expat 1.1 or later **Basic Process:** * To build, change to the root of the source code directory, and run `make`. -* The resulting executables can be found in build/release/src. +* The resulting executables can be found in `build/release/src` or `build/debug/src`, depending on what you're building. **Advanced options:** @@ -78,6 +79,7 @@ Alternatively, it can be built in an easier and more automated fashion using Hom ### On Windows: Dependencies: mingw-w64, msys2, CMake 2.8.6 or later, libunbound 1.4.16 or later (note: Unbound is not a dependency, libunbound is), and Boost 1.53 or 1.55 (except 1.54, [more details here](http://goo.gl/RrCFmA)). +Static Build Additional Dependencies: ldns 1.6.17 or later, expat 1.1 or later **Preparing the Build Environment** @@ -91,6 +93,7 @@ pacman -Su ``` * For those of you already familiar with pacman, you can run the normal `pacman -Syu` to update, but you may get errors and need to restart MSYS2 if pacman's dependencies are updated. * Install dependencies: `pacman -S mingw-w64-x86_64-gcc make mingw-w64-x86_64-cmake mingw-w64-x86_64-unbound mingw-w64-x86_64-boost` +* If you are planning to build statically you will also need to install: `pacman -S mingw-w64-x86_64-ldns mingw-w64-x86_64-expat` (note that these are likely already installed by the unbound dependency installation above) **Building** @@ -108,9 +111,17 @@ cmake -G "MSYS Makefiles" -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=.. cmake -G "MSYS Makefiles" -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=../cmake/32-bit-toolchain.cmake -D MSYS2_FOLDER=c:/msys32 .. ``` * You can now run `make` to have it build +* The resulting executables can be found in `build/release/src` or `build/debug/src`, depending on what you're building. If you installed MSYS2 in a folder other than c:/msys64, make the appropriate substitution above. +**Advanced options:** + +* Parallel build: run `make -j` instead of `make`. +* Statically linked release build: run `make release-static`. +* Debug build: run `make build-debug`. +* Test suite: run `make test-release` to run tests in addition to building. Running `make test-debug` will do the same to the debug version. + ### On FreeBSD: The project can be built from scratch by following instructions for Unix and Linux above. From 59172ee125ec916bbd43e97acc18b6aa7354c97a Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 15:00:06 +0200 Subject: [PATCH 03/29] build libunbound from external if no local libunbound or for static builds --- CMakeLists.txt | 23 ++-- cmake/FindMiniupnpc.cmake | 185 ++++++++++++++++++++++++++ cmake/FindUnbound.cmake | 23 +--- external/CMakeLists.txt | 268 ++++++++++---------------------------- src/common/dns_utils.cpp | 3 +- 5 files changed, 270 insertions(+), 232 deletions(-) create mode 100644 cmake/FindMiniupnpc.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index e908e0dfe..b9bcc411c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,8 +92,17 @@ if (UNIX AND NOT APPLE) find_package(Threads) endif() -# Find unbound - don't move this to the end, cmake is weird about this -find_package(Unbound REQUIRED) +add_subdirectory(external) + +# Final setup for miniupnpc +if(UPNP_STATIC) + add_definitions("-DUPNP_STATIC") +else() + add_definitions("-DUPNP_DYNAMIC") + include_directories(${UPNP_INCLUDE}) +endif() + +# Final setup for libunbound include_directories(${UNBOUND_INCLUDE}) if(MSVC) @@ -215,15 +224,5 @@ else() add_custom_target(version ALL) endif() -add_subdirectory(external) - -# Final setup for miniupnpc -if(UPNP_STATIC) - add_definitions("-DUPNP_STATIC") -else() - add_definitions("-DUPNP_DYNAMIC") - include_directories(${UPNP_INCLUDE}) -endif() - add_subdirectory(src) add_subdirectory(tests) diff --git a/cmake/FindMiniupnpc.cmake b/cmake/FindMiniupnpc.cmake new file mode 100644 index 000000000..0bf331da2 --- /dev/null +++ b/cmake/FindMiniupnpc.cmake @@ -0,0 +1,185 @@ +# --------------------------------- FindMiniupnpc Start --------------------------------- +# Locate miniupnp library +# This module defines +# MINIUPNP_FOUND, if false, do not try to link to miniupnp +# MINIUPNP_LIBRARY, the miniupnp variant +# MINIUPNP_INCLUDE_DIR, where to find miniupnpc.h and family) +# MINIUPNPC_VERSION_PRE1_6 --> set if we detect the version of miniupnpc is +# pre 1.6 +# MINIUPNPC_VERSION_PRE1_5 --> set if we detect the version of miniupnpc is +# pre 1.5 +# +# Note that the expected include convention is +# #include "miniupnpc.h" +# and not +# #include +# This is because, the miniupnpc location is not standardized and may exist +# in locations other than miniupnpc/ + +#============================================================================= +# Copyright 2011 Mark Vejvoda +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distributed this file outside of CMake, substitute the full +# License text for the above reference.) + +if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY) + # Already in cache, be silent + set(MINIUPNP_FIND_QUIETLY TRUE) +endif (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY) + +find_path(MINIUPNP_INCLUDE_DIR miniupnpc.h + PATH_SUFFIXES miniupnpc) +find_library(MINIUPNP_LIBRARY miniupnpc) + +if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY) + set (MINIUPNP_FOUND TRUE) +endif () + +if (MINIUPNP_FOUND) + include(CheckCXXSourceRuns) + if (NOT MINIUPNP_FIND_QUIETLY) + message (STATUS "Found the miniupnpc libraries at ${MINIUPNP_LIBRARY}") + message (STATUS "Found the miniupnpc headers at ${MINIUPNP_INCLUDE_DIR}") + endif (NOT MINIUPNP_FIND_QUIETLY) + + message(STATUS "Detecting version of miniupnpc in path: ${MINIUPNP_INCLUDE_DIR}") + + set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) + check_cxx_source_runs(" + #include + #include + #include + #include + int main() + { + static struct UPNPUrls urls; + static struct IGDdatas data; + + GetUPNPUrls (&urls, &data, \"myurl\",0); + + return 0; + }" + MINIUPNPC_VERSION_1_7_OR_HIGHER) + +IF (NOT MINIUPNPC_VERSION_1_7_OR_HIGHER) + set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) + check_cxx_source_runs(" + #include + #include + #include + #include + int main() + { + struct UPNPDev *devlist = NULL; + int upnp_delay = 5000; + const char *upnp_multicastif = NULL; + const char *upnp_minissdpdsock = NULL; + int upnp_sameport = 0; + int upnp_ipv6 = 0; + int upnp_error = 0; + devlist = upnpDiscover(upnp_delay, upnp_multicastif, upnp_minissdpdsock, upnp_sameport, upnp_ipv6, &upnp_error); + + return 0; + }" + MINIUPNPC_VERSION_PRE1_7) + ENDIF() + + IF (NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER) + set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) + check_cxx_source_runs(" + #include + #include + #include + #include + int main() + { + struct UPNPDev *devlist = NULL; + int upnp_delay = 5000; + const char *upnp_multicastif = NULL; + const char *upnp_minissdpdsock = NULL; + int upnp_sameport = 0; + int upnp_ipv6 = 0; + int upnp_error = 0; + devlist = upnpDiscover(upnp_delay, upnp_multicastif, upnp_minissdpdsock, upnp_sameport); + + return 0; + }" + MINIUPNPC_VERSION_PRE1_6) + + ENDIF() + + IF (NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER) + set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) + check_cxx_source_runs(" + #include + #include + #include + #include + static struct UPNPUrls urls; + static struct IGDdatas data; + int main() + { + char externalIP[16] = \"\"; + UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIP); + + return 0; + }" + MINIUPNPC_VERSION_1_5_OR_HIGHER) + ENDIF() + + IF (NOT MINIUPNPC_VERSION_1_5_OR_HIGHER AND NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER) + set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) + check_cxx_source_runs(" + #include + #include + #include + #include + static struct UPNPUrls urls; + static struct IGDdatas data; + int main() + { + char externalIP[16] = \"\"; + UPNP_GetExternalIPAddress(urls.controlURL, data.servicetype, externalIP); + + return 0; + }" + MINIUPNPC_VERSION_PRE1_5) + +ENDIF() + +IF(MINIUPNPC_VERSION_PRE1_5) + message(STATUS "Found miniupnpc version is pre v1.5") +ENDIF() +IF(MINIUPNPC_VERSION_PRE1_6) + message(STATUS "Found miniupnpc version is pre v1.6") +ENDIF() +IF(MINIUPNPC_VERSION_PRE1_7) + message(STATUS "Found miniupnpc version is pre v1.7") +ENDIF() + +IF(NOT MINIUPNPC_VERSION_PRE1_5 AND NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7) + IF(MINIUPNPC_VERSION_1_5_OR_HIGHER) + message(STATUS "Found miniupnpc version is v1.5 or higher") + ELSE() + message(STATUS "Found miniupnpc version is v1.7 or higher") + ENDIF() +ENDIF() + +else () + message (STATUS "Could not find miniupnp") +endif () + +MARK_AS_ADVANCED(MINIUPNP_INCLUDE_DIR MINIUPNP_LIBRARY) +# --------------------------------- FindMiniupnpc End --------------------------------- \ No newline at end of file diff --git a/cmake/FindUnbound.cmake b/cmake/FindUnbound.cmake index 032bcf45e..9728cd2f0 100644 --- a/cmake/FindUnbound.cmake +++ b/cmake/FindUnbound.cmake @@ -37,25 +37,4 @@ FIND_PATH(UNBOUND_INCLUDE_DIR /usr/ ) -if(STATIC) - if(MINGW) - find_library(UNBOUND_LIBRARIES libunbound.dll.a) - else() - find_library(UNBOUND_LIBRARIES libunbound.a) - endif() -else() - find_library(UNBOUND_LIBRARIES unbound) -endif() - -IF(UNBOUND_INCLUDE_DIR) - MESSAGE(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}") - IF(UNBOUND_LIBRARIES) - MESSAGE(STATUS "Found libunbound library") - set(UNBOUND_INCLUDE ${UNBOUND_INCLUDE_DIR}) - set(UNBOUND_LIBRARY ${UNBOUND_LIBRARIES}) - ELSE() - MESSAGE(FATAL_ERROR "${BoldRed}Could not find libunbound library, please make sure you have installed libunbound or libunbound-dev or the equivalent${ColourReset}") - ENDIF() -ELSE() - MESSAGE(FATAL_ERROR "${BoldRed}Could not find libunbound library, please make sure you have installed libunbound or libunbound-dev or the equivalent${ColourReset}") -ENDIF() +find_library(UNBOUND_LIBRARIES unbound) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index f121162df..2b5d81f28 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -28,216 +28,36 @@ # # Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers -# --------------------------------- FindMiniupnpc Start --------------------------------- -# Locate miniupnp library -# This module defines -# MINIUPNP_FOUND, if false, do not try to link to miniupnp -# MINIUPNP_LIBRARY, the miniupnp variant -# MINIUPNP_INCLUDE_DIR, where to find miniupnpc.h and family) -# MINIUPNPC_VERSION_PRE1_6 --> set if we detect the version of miniupnpc is -# pre 1.6 -# MINIUPNPC_VERSION_PRE1_5 --> set if we detect the version of miniupnpc is -# pre 1.5 -# -# Note that the expected include convention is -# #include "miniupnpc.h" -# and not -# #include -# This is because, the miniupnpc location is not standardized and may exist -# in locations other than miniupnpc/ -#============================================================================= -# Copyright 2011 Mark Vejvoda -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distributed this file outside of CMake, substitute the full -# License text for the above reference.) +# This is broken up into two parts: first we check for miniupnp, compile it if we can't +# find it, and thereafter we check for libunbound, and compile it if we can't find it. +# We always compile if we are building statically to reduce static dependency issues... +# ...except for FreeBSD, because FreeBSD is a special case that doesn't play well with +# others. -if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY) - # Already in cache, be silent - set(MINIUPNP_FIND_QUIETLY TRUE) -endif (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY) +find_package(MiniUpnpc REQUIRED) -find_path(MINIUPNP_INCLUDE_DIR miniupnpc.h - PATH_SUFFIXES miniupnpc) -find_library(MINIUPNP_LIBRARY miniupnpc) - -if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY) - set (MINIUPNP_FOUND TRUE) -endif () - -if (MINIUPNP_FOUND) - include(CheckCXXSourceRuns) - if (NOT MINIUPNP_FIND_QUIETLY) - message (STATUS "Found the miniupnpc libraries at ${MINIUPNP_LIBRARY}") - message (STATUS "Found the miniupnpc headers at ${MINIUPNP_INCLUDE_DIR}") - endif (NOT MINIUPNP_FIND_QUIETLY) - - message(STATUS "Detecting version of miniupnpc in path: ${MINIUPNP_INCLUDE_DIR}") - - set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) - set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) - check_cxx_source_runs(" - #include - #include - #include - #include - int main() - { - static struct UPNPUrls urls; - static struct IGDdatas data; - - GetUPNPUrls (&urls, &data, \"myurl\",0); - - return 0; - }" - MINIUPNPC_VERSION_1_7_OR_HIGHER) - -IF (NOT MINIUPNPC_VERSION_1_7_OR_HIGHER) - set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) - set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) - check_cxx_source_runs(" - #include - #include - #include - #include - int main() - { - struct UPNPDev *devlist = NULL; - int upnp_delay = 5000; - const char *upnp_multicastif = NULL; - const char *upnp_minissdpdsock = NULL; - int upnp_sameport = 0; - int upnp_ipv6 = 0; - int upnp_error = 0; - devlist = upnpDiscover(upnp_delay, upnp_multicastif, upnp_minissdpdsock, upnp_sameport, upnp_ipv6, &upnp_error); - - return 0; - }" - MINIUPNPC_VERSION_PRE1_7) - ENDIF() - - IF (NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER) - set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) - set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) - check_cxx_source_runs(" - #include - #include - #include - #include - int main() - { - struct UPNPDev *devlist = NULL; - int upnp_delay = 5000; - const char *upnp_multicastif = NULL; - const char *upnp_minissdpdsock = NULL; - int upnp_sameport = 0; - int upnp_ipv6 = 0; - int upnp_error = 0; - devlist = upnpDiscover(upnp_delay, upnp_multicastif, upnp_minissdpdsock, upnp_sameport); - - return 0; - }" - MINIUPNPC_VERSION_PRE1_6) - - ENDIF() - - IF (NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER) - set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) - set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) - check_cxx_source_runs(" - #include - #include - #include - #include - static struct UPNPUrls urls; - static struct IGDdatas data; - int main() - { - char externalIP[16] = \"\"; - UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIP); - - return 0; - }" - MINIUPNPC_VERSION_1_5_OR_HIGHER) - ENDIF() - - IF (NOT MINIUPNPC_VERSION_1_5_OR_HIGHER AND NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER) - set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) - set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) - check_cxx_source_runs(" - #include - #include - #include - #include - static struct UPNPUrls urls; - static struct IGDdatas data; - int main() - { - char externalIP[16] = \"\"; - UPNP_GetExternalIPAddress(urls.controlURL, data.servicetype, externalIP); - - return 0; - }" - MINIUPNPC_VERSION_PRE1_5) - -ENDIF() - -IF(MINIUPNPC_VERSION_PRE1_5) - message(STATUS "Found miniupnpc version is pre v1.5") -ENDIF() -IF(MINIUPNPC_VERSION_PRE1_6) - message(STATUS "Found miniupnpc version is pre v1.6") -ENDIF() -IF(MINIUPNPC_VERSION_PRE1_7) - message(STATUS "Found miniupnpc version is pre v1.7") -ENDIF() - -IF(NOT MINIUPNPC_VERSION_PRE1_5 AND NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7) - IF(MINIUPNPC_VERSION_1_5_OR_HIGHER) - message(STATUS "Found miniupnpc version is v1.5 or higher") - ELSE() - message(STATUS "Found miniupnpc version is v1.7 or higher") - ENDIF() -ENDIF() - -else () - message (STATUS "Could not find miniupnp") -endif () - -MARK_AS_ADVANCED(MINIUPNP_INCLUDE_DIR MINIUPNP_LIBRARY) -# --------------------------------- FindMiniupnpc End --------------------------------- - -# And now on to the Monero part of things - -# FreeBSD doesn't play well with the local copy -SET(USE_SHARED false) +# FreeBSD doesn't play well with the local copy, so default to using shared +SET(USE_SHARED_MINIUPNPC true) # If we have the correct shared version and we're not building static, use it -IF(MINIUPNP_FOUND AND MINIUPNPC_VERSION_1_7_OR_HIGHER AND !STATIC) - SET(USE_SHARED true) +IF(!MINIUPNP_FOUND OR !MINIUPNPC_VERSION_1_7_OR_HIGHER OR STATIC) + SET(USE_SHARED_MINIUPNPC false) ENDIF() -# If we're on FreeBSD -IF(FREEBSD) - SET(USE_SHARED true) -ENDIF() - -if(USE_SHARED) +if(USE_SHARED_MINIUPNPC) message(STATUS "Using shared miniupnpc found at ${MINIUPNP_INCLUDE_DIR}") set(UPNP_STATIC false PARENT_SCOPE) set(UPNP_INCLUDE ${MINIUPNP_INCLUDE_DIR} PARENT_SCOPE) set(UPNP_LIBRARIES ${MINIUPNP_LIBRARY} PARENT_SCOPE) else() - message(STATUS "Using static miniupnpc from external") - + if(STATIC) + message(STATUS "Using miniupnpc from local source tree for static build") + else() + message(STATUS "Using miniupnpc from local source tree (/external/miniupnpc)") + endif() + set(UPNPC_BUILD_STATIC ON CACHE BOOL "Build static library") set(UPNPC_BUILD_SHARED OFF CACHE BOOL "Build shared library") set(UPNPC_BUILD_TESTS OFF CACHE BOOL "Build test executables") @@ -253,3 +73,57 @@ else() set(UPNP_STATIC true PARENT_SCOPE) set(UPNP_LIBRARIES "upnpc-static" PARENT_SCOPE) endif() + +find_package(Unbound REQUIRED) + +IF(UNBOUND_INCLUDE_DIR) + MESSAGE(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}") + IF(UNBOUND_LIBRARIES) + MESSAGE(STATUS "Found libunbound shared library") + set(UNBOUND_STATIC false PARENT_SCOPE) + set(UNBOUND_INCLUDE ${UNBOUND_INCLUDE_DIR} PARENT_SCOPE) + set(UNBOUND_LIBRARY ${UNBOUND_LIBRARIES} PARENT_SCOPE) + ELSE() + MESSAGE(FATAL_ERROR "${BoldRed}Found libunbound includes, but could not find libunbound library. Please make sure you have installed libunbound or libunbound-dev or the equivalent${ColourReset}") + ENDIF() +ELSE + if(STATIC) + message(STATUS "Using libunbound from local source tree for static build") + else() + message(STATUS "Using libunbound from local source tree (/external/unbound)") + endif() + + INCLUDE(ExternalProject) + + FIND_PACKAGE(OpenSSL REQUIRED) + FIND_PACKAGE(Expat REQUIRED) + + IF(MINGW) + EXTERNALPROJECT_ADD( + libunbound + URL ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound + BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/unbound + CONFIGURE_COMMAND export USE_WINSOCK=1 && ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound/configure --prefix=${CMAKE_FIND_ROOT_PATH} --build=${GCC_PREFIX} --host=${GCC_PREFIX} --disable-shared --enable-static --sysconfdir=${CMAKE_FIND_ROOT_PATH}/etc --localstatedir=${CMAKE_FIND_ROOT_PATH}/var --sbindir=${CMAKE_FIND_ROOT_PATH}/bin --disable-gost --disable-rpath --with-libevent=no --with-libexpat=${CMAKE_FIND_ROOT_PATH} --without-pyunbound --without-pythonmodule --with-ssl=${CMAKE_FIND_ROOT_PATH} --without-pthreads --with-libunbound-only + BUILD_COMMAND make + ) + ELSEIF(APPLE) + EXTERNALPROJECT_ADD( + libunbound + URL ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound + BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/unbound + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound/configure --prefix=$(brew --prefix) --disable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only + BUILD_COMMAND make + ) + ELSE() + EXTERNALPROJECT_ADD( + libunbound + URL ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound + BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/unbound + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound/configure --disable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only + BUILD_COMMAND make + ) + ENDIF() + + set(UNBOUND_STATIC true PARENT_SCOPE) + set(UNBOUND_LIBRARY unbound-static PARENT_SCOPE) +ENDIF() diff --git a/src/common/dns_utils.cpp b/src/common/dns_utils.cpp index 8c4038568..d21b538a6 100644 --- a/src/common/dns_utils.cpp +++ b/src/common/dns_utils.cpp @@ -29,7 +29,8 @@ #include "common/dns_utils.h" #include #include -#include +// check local first (in the event of static or in-source compilation of libunbound) +#include "unbound.h" #include #include "include_base_utils.h" From 75a616fa96b9c5ec444ae5627f90457ca6c5ef97 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 15:01:00 +0200 Subject: [PATCH 04/29] fix missing parentheses --- external/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 2b5d81f28..2e6a2f86d 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -86,7 +86,7 @@ IF(UNBOUND_INCLUDE_DIR) ELSE() MESSAGE(FATAL_ERROR "${BoldRed}Found libunbound includes, but could not find libunbound library. Please make sure you have installed libunbound or libunbound-dev or the equivalent${ColourReset}") ENDIF() -ELSE +ELSE() if(STATIC) message(STATUS "Using libunbound from local source tree for static build") else() From 3a0b00acfd5ae862cc1191a8fdbbf932a2ff82c9 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 15:40:01 +0200 Subject: [PATCH 05/29] build libunbound correctly --- external/CMakeLists.txt | 71 +++++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 2e6a2f86d..0cafec53c 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -76,17 +76,7 @@ endif() find_package(Unbound REQUIRED) -IF(UNBOUND_INCLUDE_DIR) - MESSAGE(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}") - IF(UNBOUND_LIBRARIES) - MESSAGE(STATUS "Found libunbound shared library") - set(UNBOUND_STATIC false PARENT_SCOPE) - set(UNBOUND_INCLUDE ${UNBOUND_INCLUDE_DIR} PARENT_SCOPE) - set(UNBOUND_LIBRARY ${UNBOUND_LIBRARIES} PARENT_SCOPE) - ELSE() - MESSAGE(FATAL_ERROR "${BoldRed}Found libunbound includes, but could not find libunbound library. Please make sure you have installed libunbound or libunbound-dev or the equivalent${ColourReset}") - ENDIF() -ELSE() +IF(!UNBOUND_INCLUDE_DIR OR STATIC) if(STATIC) message(STATUS "Using libunbound from local source tree for static build") else() @@ -101,29 +91,68 @@ ELSE() IF(MINGW) EXTERNALPROJECT_ADD( libunbound - URL ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound - BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/unbound - CONFIGURE_COMMAND export USE_WINSOCK=1 && ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound/configure --prefix=${CMAKE_FIND_ROOT_PATH} --build=${GCC_PREFIX} --host=${GCC_PREFIX} --disable-shared --enable-static --sysconfdir=${CMAKE_FIND_ROOT_PATH}/etc --localstatedir=${CMAKE_FIND_ROOT_PATH}/var --sbindir=${CMAKE_FIND_ROOT_PATH}/bin --disable-gost --disable-rpath --with-libevent=no --with-libexpat=${CMAKE_FIND_ROOT_PATH} --without-pyunbound --without-pythonmodule --with-ssl=${CMAKE_FIND_ROOT_PATH} --without-pthreads --with-libunbound-only + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/unbound + URL ${CMAKE_CURRENT_SOURCE_DIR}/unbound/ + CONFIGURE_COMMAND export USE_WINSOCK=1 && ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure --prefix=${CMAKE_FIND_ROOT_PATH} --build=${GCC_PREFIX} --host=${GCC_PREFIX} --disable-shared --enable-static --sysconfdir=${CMAKE_FIND_ROOT_PATH}/etc --localstatedir=${CMAKE_FIND_ROOT_PATH}/var --sbindir=${CMAKE_FIND_ROOT_PATH}/bin --disable-gost --disable-rpath --with-libevent=no --with-libexpat=${CMAKE_FIND_ROOT_PATH} --without-pyunbound --without-pythonmodule --with-ssl=${CMAKE_FIND_ROOT_PATH} --without-pthreads --with-libunbound-only BUILD_COMMAND make + UPDATE_COMMAND "" + PATCH_COMMAND "" + INSTALL_COMMAND "" + LOG_DOWNLOAD 1 + LOG_UPDATE 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_TEST 1 + LOG_INSTALL 1 ) ELSEIF(APPLE) + execute_process(COMMAND brew --prefix OUTPUT_VARIABLE BREW_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) EXTERNALPROJECT_ADD( libunbound - URL ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound - BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/unbound - CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound/configure --prefix=$(brew --prefix) --disable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/unbound + URL ${CMAKE_CURRENT_SOURCE_DIR}/unbound/ + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure --prefix=${BREW_PREFIX} --disable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only BUILD_COMMAND make + UPDATE_COMMAND "" + PATCH_COMMAND "" + INSTALL_COMMAND "" + LOG_DOWNLOAD 1 + LOG_UPDATE 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_TEST 1 + LOG_INSTALL 1 ) ELSE() EXTERNALPROJECT_ADD( libunbound - URL ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound - BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/unbound - CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound/configure --disable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/unbound + URL ${CMAKE_CURRENT_SOURCE_DIR}/unbound/ + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure --disable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only BUILD_COMMAND make + UPDATE_COMMAND "" + PATCH_COMMAND "" + INSTALL_COMMAND "" + LOG_DOWNLOAD 1 + LOG_UPDATE 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_TEST 1 + LOG_INSTALL 1 ) ENDIF() set(UNBOUND_STATIC true PARENT_SCOPE) - set(UNBOUND_LIBRARY unbound-static PARENT_SCOPE) + set(UNBOUND_INCLUDE "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build" PARENT_SCOPE) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build" PARENT_SCOPE) +ELSE() + MESSAGE(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}") + IF(UNBOUND_LIBRARIES) + MESSAGE(STATUS "Found libunbound shared library") + set(UNBOUND_STATIC false PARENT_SCOPE) + set(UNBOUND_INCLUDE ${UNBOUND_INCLUDE_DIR} PARENT_SCOPE) + set(UNBOUND_LIBRARY ${UNBOUND_LIBRARIES} PARENT_SCOPE) + ELSE() + MESSAGE(FATAL_ERROR "${BoldRed}Found libunbound includes, but could not find libunbound library. Please make sure you have installed libunbound or libunbound-dev or the equivalent${ColourReset}") + ENDIF() ENDIF() From 409e9ba5879c436c90f49ec21fb39515a14bdfbb Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 16:05:24 +0200 Subject: [PATCH 06/29] use the correct CMake variable for static builds --- external/CMakeLists.txt | 2 +- src/CMakeLists.txt | 8 ++++---- tests/CMakeLists.txt | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 0cafec53c..24aca9be0 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -144,7 +144,7 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) set(UNBOUND_STATIC true PARENT_SCOPE) set(UNBOUND_INCLUDE "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build" PARENT_SCOPE) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build" PARENT_SCOPE) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.la" PARENT_SCOPE) ELSE() MESSAGE(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}") IF(UNBOUND_LIBRARIES) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2393213cb..e000b635d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -63,14 +63,14 @@ add_library(mnemonics ${MNEMONICS}) add_executable(daemon ${DAEMON} ${P2P} ${CRYPTONOTE_PROTOCOL}) add_executable(connectivity_tool ${CONN_TOOL}) add_executable(simpleminer ${MINER}) -target_link_libraries(daemon rpc cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) -target_link_libraries(connectivity_tool cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) -target_link_libraries(simpleminer cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(daemon rpc cryptonote_core crypto common ${UNBOUND_LIBRARY} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(connectivity_tool cryptonote_core crypto common ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(simpleminer cryptonote_core crypto common ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) add_library(rpc ${RPC}) add_library(wallet ${WALLET}) target_link_libraries(wallet mnemonics) add_executable(simplewallet ${SIMPLEWALLET} ) -target_link_libraries(simplewallet wallet rpc cryptonote_core crypto common mnemonics ${UNBOUND_LIBRARIES} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(simplewallet wallet rpc cryptonote_core crypto common mnemonics ${UNBOUND_LIBRARY} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) add_dependencies(daemon version) add_dependencies(rpc version) add_dependencies(simplewallet version) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 14695ddd8..a95c34f0f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -61,16 +61,16 @@ add_executable(unit_tests ${UNIT_TESTS}) add_executable(net_load_tests_clt net_load_tests/clt.cpp) add_executable(net_load_tests_srv net_load_tests/srv.cpp) -target_link_libraries(core_proxy cryptonote_core common crypto ${UNBOUND_LIBRARIES} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) -target_link_libraries(coretests cryptonote_core common crypto ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(core_proxy cryptonote_core common crypto ${UNBOUND_LIBRARY} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(coretests cryptonote_core common crypto ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) target_link_libraries(difficulty-tests cryptonote_core) -target_link_libraries(functional_tests cryptonote_core wallet common crypto ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(functional_tests cryptonote_core wallet common crypto ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) target_link_libraries(hash-tests crypto) target_link_libraries(hash-target-tests crypto cryptonote_core) -target_link_libraries(performance_tests cryptonote_core common crypto ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) -target_link_libraries(unit_tests gtest_main cryptonote_core wallet crypto common ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) -target_link_libraries(net_load_tests_clt cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) -target_link_libraries(net_load_tests_srv cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(performance_tests cryptonote_core common crypto ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(unit_tests gtest_main cryptonote_core wallet crypto common ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(net_load_tests_clt cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(net_load_tests_srv cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) if(NOT MSVC) set_property(TARGET gtest gtest_main unit_tests net_load_tests_clt net_load_tests_srv APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-sign-compare") From 23cc93c935ce0523f71b526d66ed9fa1e1861b51 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 17:19:51 +0200 Subject: [PATCH 07/29] added libtool's install command --- external/CMakeLists.txt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 24aca9be0..cbd70800a 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -94,10 +94,10 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) PREFIX ${CMAKE_CURRENT_BINARY_DIR}/unbound URL ${CMAKE_CURRENT_SOURCE_DIR}/unbound/ CONFIGURE_COMMAND export USE_WINSOCK=1 && ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure --prefix=${CMAKE_FIND_ROOT_PATH} --build=${GCC_PREFIX} --host=${GCC_PREFIX} --disable-shared --enable-static --sysconfdir=${CMAKE_FIND_ROOT_PATH}/etc --localstatedir=${CMAKE_FIND_ROOT_PATH}/var --sbindir=${CMAKE_FIND_ROOT_PATH}/bin --disable-gost --disable-rpath --with-libevent=no --with-libexpat=${CMAKE_FIND_ROOT_PATH} --without-pyunbound --without-pythonmodule --with-ssl=${CMAKE_FIND_ROOT_PATH} --without-pthreads --with-libunbound-only - BUILD_COMMAND make + BUILD_COMMAND $(MAKE) UPDATE_COMMAND "" PATCH_COMMAND "" - INSTALL_COMMAND "" + INSTALL_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libtool --mode=install cp ${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.la ${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build LOG_DOWNLOAD 1 LOG_UPDATE 1 LOG_CONFIGURE 1 @@ -105,17 +105,18 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.dll.la" PARENT_SCOPE) ELSEIF(APPLE) execute_process(COMMAND brew --prefix OUTPUT_VARIABLE BREW_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) EXTERNALPROJECT_ADD( libunbound PREFIX ${CMAKE_CURRENT_BINARY_DIR}/unbound URL ${CMAKE_CURRENT_SOURCE_DIR}/unbound/ - CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure --prefix=${BREW_PREFIX} --disable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only - BUILD_COMMAND make + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure --prefix=${BREW_PREFIX} --enable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only + BUILD_COMMAND $(MAKE) UPDATE_COMMAND "" PATCH_COMMAND "" - INSTALL_COMMAND "" + INSTALL_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libtool --mode=install cp ${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.la ${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build LOG_DOWNLOAD 1 LOG_UPDATE 1 LOG_CONFIGURE 1 @@ -123,16 +124,17 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.la" PARENT_SCOPE) ELSE() EXTERNALPROJECT_ADD( libunbound PREFIX ${CMAKE_CURRENT_BINARY_DIR}/unbound URL ${CMAKE_CURRENT_SOURCE_DIR}/unbound/ CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure --disable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only - BUILD_COMMAND make + BUILD_COMMAND $(MAKE) UPDATE_COMMAND "" PATCH_COMMAND "" - INSTALL_COMMAND "" + INSTALL_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libtool --mode=install cp ${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.la ${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build LOG_DOWNLOAD 1 LOG_UPDATE 1 LOG_CONFIGURE 1 @@ -140,6 +142,7 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.la" PARENT_SCOPE) ENDIF() set(UNBOUND_STATIC true PARENT_SCOPE) From 6ef8ae8bd861c0921f29e87617f8dc8da1041628 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 17:28:59 +0200 Subject: [PATCH 08/29] reference the correct unbound static lib --- external/CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index cbd70800a..58f81fd34 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -105,7 +105,7 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.dll.la" PARENT_SCOPE) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.dll.a" PARENT_SCOPE) ELSEIF(APPLE) execute_process(COMMAND brew --prefix OUTPUT_VARIABLE BREW_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) EXTERNALPROJECT_ADD( @@ -124,7 +124,7 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.la" PARENT_SCOPE) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.a" PARENT_SCOPE) ELSE() EXTERNALPROJECT_ADD( libunbound @@ -142,12 +142,11 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.la" PARENT_SCOPE) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.a" PARENT_SCOPE) ENDIF() set(UNBOUND_STATIC true PARENT_SCOPE) set(UNBOUND_INCLUDE "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build" PARENT_SCOPE) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.la" PARENT_SCOPE) ELSE() MESSAGE(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}") IF(UNBOUND_LIBRARIES) From 1d5991ed3380f725012716c4487cb9440057d29a Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 18:06:25 +0200 Subject: [PATCH 09/29] include openssl in linbunbound static linking, added errors for openssl and expat --- external/CMakeLists.txt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 58f81fd34..77de69c17 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -86,7 +86,18 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) INCLUDE(ExternalProject) FIND_PACKAGE(OpenSSL REQUIRED) + IF(!OPENSSL_LIBRARIES) + MESSAGE(FATAL_ERROR "${BoldRed}Could not find the openssl library. Please make sure you have installed openssl or libssl-dev or the equivalent${ColourReset}") + ELSE() + MESSAGE(STATUS "Found openssl libraries") + ENDIF() + FIND_PACKAGE(Expat REQUIRED) + IF(!EXPAT_LIBRARIES) + MESSAGE(FATAL_ERROR "${BoldRed}Could not find the expat library. Please make sure you have installed libexpat or libexpat-dev or the equivalent${ColourReset}") + ELSE() + MESSAGE(STATUS "Found expat libraries") + ENDIF() IF(MINGW) EXTERNALPROJECT_ADD( @@ -105,7 +116,7 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.dll.a" PARENT_SCOPE) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.dll.a;${OPENSSL_LIBRARIES}" PARENT_SCOPE) ELSEIF(APPLE) execute_process(COMMAND brew --prefix OUTPUT_VARIABLE BREW_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) EXTERNALPROJECT_ADD( @@ -124,7 +135,7 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.a" PARENT_SCOPE) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.a;${OPENSSL_LIBRARIES}" PARENT_SCOPE) ELSE() EXTERNALPROJECT_ADD( libunbound @@ -142,7 +153,7 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.a" PARENT_SCOPE) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.a;${OPENSSL_LIBRARIES}" PARENT_SCOPE) ENDIF() set(UNBOUND_STATIC true PARENT_SCOPE) From add1a608dd5a01fa9c681379e42844527a05814c Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 10:15:22 +0200 Subject: [PATCH 10/29] added static build dependency instructions to README --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ee6ef0545..8ec56a53b 100644 --- a/README.md +++ b/README.md @@ -51,11 +51,12 @@ Parts of the project are originally copyright (c) 2012-2013 The Cryptonote devel ### On Unix and Linux: Dependencies: GCC 4.7.3 or later, CMake 2.8.6 or later, libunbound 1.4.16 or later (note: Unbound is not a dependency, libunbound is), and Boost 1.53 or later (except 1.54, [more details here](http://goo.gl/RrCFmA)). +Static Build Additional Dependencies: ldns 1.6.17 or later, expat 1.1 or later **Basic Process:** * To build, change to the root of the source code directory, and run `make`. -* The resulting executables can be found in build/release/src. +* The resulting executables can be found in `build/release/src` or `build/debug/src`, depending on what you're building. **Advanced options:** @@ -78,6 +79,7 @@ Alternatively, it can be built in an easier and more automated fashion using Hom ### On Windows: Dependencies: mingw-w64, msys2, CMake 2.8.6 or later, libunbound 1.4.16 or later (note: Unbound is not a dependency, libunbound is), and Boost 1.53 or 1.55 (except 1.54, [more details here](http://goo.gl/RrCFmA)). +Static Build Additional Dependencies: ldns 1.6.17 or later, expat 1.1 or later **Preparing the Build Environment** @@ -91,6 +93,7 @@ pacman -Su ``` * For those of you already familiar with pacman, you can run the normal `pacman -Syu` to update, but you may get errors and need to restart MSYS2 if pacman's dependencies are updated. * Install dependencies: `pacman -S mingw-w64-x86_64-gcc make mingw-w64-x86_64-cmake mingw-w64-x86_64-unbound mingw-w64-x86_64-boost` +* If you are planning to build statically you will also need to install: `pacman -S mingw-w64-x86_64-ldns mingw-w64-x86_64-expat` (note that these are likely already installed by the unbound dependency installation above) **Building** @@ -108,9 +111,17 @@ cmake -G "MSYS Makefiles" -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=.. cmake -G "MSYS Makefiles" -D CMAKE_BUILD_TYPE=Release -D CMAKE_TOOLCHAIN_FILE=../cmake/32-bit-toolchain.cmake -D MSYS2_FOLDER=c:/msys32 .. ``` * You can now run `make` to have it build +* The resulting executables can be found in `build/release/src` or `build/debug/src`, depending on what you're building. If you installed MSYS2 in a folder other than c:/msys64, make the appropriate substitution above. +**Advanced options:** + +* Parallel build: run `make -j` instead of `make`. +* Statically linked release build: run `make release-static`. +* Debug build: run `make build-debug`. +* Test suite: run `make test-release` to run tests in addition to building. Running `make test-debug` will do the same to the debug version. + ### On FreeBSD: The project can be built from scratch by following instructions for Unix and Linux above. From cee87473adb609aff52c12cff174fd2ad58f5d1d Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 15:00:06 +0200 Subject: [PATCH 11/29] build libunbound from external if no local libunbound or for static builds --- CMakeLists.txt | 23 ++-- cmake/FindMiniupnpc.cmake | 185 ++++++++++++++++++++++++++ cmake/FindUnbound.cmake | 23 +--- external/CMakeLists.txt | 268 ++++++++++---------------------------- src/common/dns_utils.cpp | 3 +- 5 files changed, 270 insertions(+), 232 deletions(-) create mode 100644 cmake/FindMiniupnpc.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index e908e0dfe..b9bcc411c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,8 +92,17 @@ if (UNIX AND NOT APPLE) find_package(Threads) endif() -# Find unbound - don't move this to the end, cmake is weird about this -find_package(Unbound REQUIRED) +add_subdirectory(external) + +# Final setup for miniupnpc +if(UPNP_STATIC) + add_definitions("-DUPNP_STATIC") +else() + add_definitions("-DUPNP_DYNAMIC") + include_directories(${UPNP_INCLUDE}) +endif() + +# Final setup for libunbound include_directories(${UNBOUND_INCLUDE}) if(MSVC) @@ -215,15 +224,5 @@ else() add_custom_target(version ALL) endif() -add_subdirectory(external) - -# Final setup for miniupnpc -if(UPNP_STATIC) - add_definitions("-DUPNP_STATIC") -else() - add_definitions("-DUPNP_DYNAMIC") - include_directories(${UPNP_INCLUDE}) -endif() - add_subdirectory(src) add_subdirectory(tests) diff --git a/cmake/FindMiniupnpc.cmake b/cmake/FindMiniupnpc.cmake new file mode 100644 index 000000000..0bf331da2 --- /dev/null +++ b/cmake/FindMiniupnpc.cmake @@ -0,0 +1,185 @@ +# --------------------------------- FindMiniupnpc Start --------------------------------- +# Locate miniupnp library +# This module defines +# MINIUPNP_FOUND, if false, do not try to link to miniupnp +# MINIUPNP_LIBRARY, the miniupnp variant +# MINIUPNP_INCLUDE_DIR, where to find miniupnpc.h and family) +# MINIUPNPC_VERSION_PRE1_6 --> set if we detect the version of miniupnpc is +# pre 1.6 +# MINIUPNPC_VERSION_PRE1_5 --> set if we detect the version of miniupnpc is +# pre 1.5 +# +# Note that the expected include convention is +# #include "miniupnpc.h" +# and not +# #include +# This is because, the miniupnpc location is not standardized and may exist +# in locations other than miniupnpc/ + +#============================================================================= +# Copyright 2011 Mark Vejvoda +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distributed this file outside of CMake, substitute the full +# License text for the above reference.) + +if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY) + # Already in cache, be silent + set(MINIUPNP_FIND_QUIETLY TRUE) +endif (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY) + +find_path(MINIUPNP_INCLUDE_DIR miniupnpc.h + PATH_SUFFIXES miniupnpc) +find_library(MINIUPNP_LIBRARY miniupnpc) + +if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY) + set (MINIUPNP_FOUND TRUE) +endif () + +if (MINIUPNP_FOUND) + include(CheckCXXSourceRuns) + if (NOT MINIUPNP_FIND_QUIETLY) + message (STATUS "Found the miniupnpc libraries at ${MINIUPNP_LIBRARY}") + message (STATUS "Found the miniupnpc headers at ${MINIUPNP_INCLUDE_DIR}") + endif (NOT MINIUPNP_FIND_QUIETLY) + + message(STATUS "Detecting version of miniupnpc in path: ${MINIUPNP_INCLUDE_DIR}") + + set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) + check_cxx_source_runs(" + #include + #include + #include + #include + int main() + { + static struct UPNPUrls urls; + static struct IGDdatas data; + + GetUPNPUrls (&urls, &data, \"myurl\",0); + + return 0; + }" + MINIUPNPC_VERSION_1_7_OR_HIGHER) + +IF (NOT MINIUPNPC_VERSION_1_7_OR_HIGHER) + set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) + check_cxx_source_runs(" + #include + #include + #include + #include + int main() + { + struct UPNPDev *devlist = NULL; + int upnp_delay = 5000; + const char *upnp_multicastif = NULL; + const char *upnp_minissdpdsock = NULL; + int upnp_sameport = 0; + int upnp_ipv6 = 0; + int upnp_error = 0; + devlist = upnpDiscover(upnp_delay, upnp_multicastif, upnp_minissdpdsock, upnp_sameport, upnp_ipv6, &upnp_error); + + return 0; + }" + MINIUPNPC_VERSION_PRE1_7) + ENDIF() + + IF (NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER) + set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) + check_cxx_source_runs(" + #include + #include + #include + #include + int main() + { + struct UPNPDev *devlist = NULL; + int upnp_delay = 5000; + const char *upnp_multicastif = NULL; + const char *upnp_minissdpdsock = NULL; + int upnp_sameport = 0; + int upnp_ipv6 = 0; + int upnp_error = 0; + devlist = upnpDiscover(upnp_delay, upnp_multicastif, upnp_minissdpdsock, upnp_sameport); + + return 0; + }" + MINIUPNPC_VERSION_PRE1_6) + + ENDIF() + + IF (NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER) + set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) + check_cxx_source_runs(" + #include + #include + #include + #include + static struct UPNPUrls urls; + static struct IGDdatas data; + int main() + { + char externalIP[16] = \"\"; + UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIP); + + return 0; + }" + MINIUPNPC_VERSION_1_5_OR_HIGHER) + ENDIF() + + IF (NOT MINIUPNPC_VERSION_1_5_OR_HIGHER AND NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER) + set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) + check_cxx_source_runs(" + #include + #include + #include + #include + static struct UPNPUrls urls; + static struct IGDdatas data; + int main() + { + char externalIP[16] = \"\"; + UPNP_GetExternalIPAddress(urls.controlURL, data.servicetype, externalIP); + + return 0; + }" + MINIUPNPC_VERSION_PRE1_5) + +ENDIF() + +IF(MINIUPNPC_VERSION_PRE1_5) + message(STATUS "Found miniupnpc version is pre v1.5") +ENDIF() +IF(MINIUPNPC_VERSION_PRE1_6) + message(STATUS "Found miniupnpc version is pre v1.6") +ENDIF() +IF(MINIUPNPC_VERSION_PRE1_7) + message(STATUS "Found miniupnpc version is pre v1.7") +ENDIF() + +IF(NOT MINIUPNPC_VERSION_PRE1_5 AND NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7) + IF(MINIUPNPC_VERSION_1_5_OR_HIGHER) + message(STATUS "Found miniupnpc version is v1.5 or higher") + ELSE() + message(STATUS "Found miniupnpc version is v1.7 or higher") + ENDIF() +ENDIF() + +else () + message (STATUS "Could not find miniupnp") +endif () + +MARK_AS_ADVANCED(MINIUPNP_INCLUDE_DIR MINIUPNP_LIBRARY) +# --------------------------------- FindMiniupnpc End --------------------------------- \ No newline at end of file diff --git a/cmake/FindUnbound.cmake b/cmake/FindUnbound.cmake index 032bcf45e..9728cd2f0 100644 --- a/cmake/FindUnbound.cmake +++ b/cmake/FindUnbound.cmake @@ -37,25 +37,4 @@ FIND_PATH(UNBOUND_INCLUDE_DIR /usr/ ) -if(STATIC) - if(MINGW) - find_library(UNBOUND_LIBRARIES libunbound.dll.a) - else() - find_library(UNBOUND_LIBRARIES libunbound.a) - endif() -else() - find_library(UNBOUND_LIBRARIES unbound) -endif() - -IF(UNBOUND_INCLUDE_DIR) - MESSAGE(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}") - IF(UNBOUND_LIBRARIES) - MESSAGE(STATUS "Found libunbound library") - set(UNBOUND_INCLUDE ${UNBOUND_INCLUDE_DIR}) - set(UNBOUND_LIBRARY ${UNBOUND_LIBRARIES}) - ELSE() - MESSAGE(FATAL_ERROR "${BoldRed}Could not find libunbound library, please make sure you have installed libunbound or libunbound-dev or the equivalent${ColourReset}") - ENDIF() -ELSE() - MESSAGE(FATAL_ERROR "${BoldRed}Could not find libunbound library, please make sure you have installed libunbound or libunbound-dev or the equivalent${ColourReset}") -ENDIF() +find_library(UNBOUND_LIBRARIES unbound) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index f121162df..2b5d81f28 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -28,216 +28,36 @@ # # Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers -# --------------------------------- FindMiniupnpc Start --------------------------------- -# Locate miniupnp library -# This module defines -# MINIUPNP_FOUND, if false, do not try to link to miniupnp -# MINIUPNP_LIBRARY, the miniupnp variant -# MINIUPNP_INCLUDE_DIR, where to find miniupnpc.h and family) -# MINIUPNPC_VERSION_PRE1_6 --> set if we detect the version of miniupnpc is -# pre 1.6 -# MINIUPNPC_VERSION_PRE1_5 --> set if we detect the version of miniupnpc is -# pre 1.5 -# -# Note that the expected include convention is -# #include "miniupnpc.h" -# and not -# #include -# This is because, the miniupnpc location is not standardized and may exist -# in locations other than miniupnpc/ -#============================================================================= -# Copyright 2011 Mark Vejvoda -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distributed this file outside of CMake, substitute the full -# License text for the above reference.) +# This is broken up into two parts: first we check for miniupnp, compile it if we can't +# find it, and thereafter we check for libunbound, and compile it if we can't find it. +# We always compile if we are building statically to reduce static dependency issues... +# ...except for FreeBSD, because FreeBSD is a special case that doesn't play well with +# others. -if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY) - # Already in cache, be silent - set(MINIUPNP_FIND_QUIETLY TRUE) -endif (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY) +find_package(MiniUpnpc REQUIRED) -find_path(MINIUPNP_INCLUDE_DIR miniupnpc.h - PATH_SUFFIXES miniupnpc) -find_library(MINIUPNP_LIBRARY miniupnpc) - -if (MINIUPNP_INCLUDE_DIR AND MINIUPNP_LIBRARY) - set (MINIUPNP_FOUND TRUE) -endif () - -if (MINIUPNP_FOUND) - include(CheckCXXSourceRuns) - if (NOT MINIUPNP_FIND_QUIETLY) - message (STATUS "Found the miniupnpc libraries at ${MINIUPNP_LIBRARY}") - message (STATUS "Found the miniupnpc headers at ${MINIUPNP_INCLUDE_DIR}") - endif (NOT MINIUPNP_FIND_QUIETLY) - - message(STATUS "Detecting version of miniupnpc in path: ${MINIUPNP_INCLUDE_DIR}") - - set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) - set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) - check_cxx_source_runs(" - #include - #include - #include - #include - int main() - { - static struct UPNPUrls urls; - static struct IGDdatas data; - - GetUPNPUrls (&urls, &data, \"myurl\",0); - - return 0; - }" - MINIUPNPC_VERSION_1_7_OR_HIGHER) - -IF (NOT MINIUPNPC_VERSION_1_7_OR_HIGHER) - set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) - set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) - check_cxx_source_runs(" - #include - #include - #include - #include - int main() - { - struct UPNPDev *devlist = NULL; - int upnp_delay = 5000; - const char *upnp_multicastif = NULL; - const char *upnp_minissdpdsock = NULL; - int upnp_sameport = 0; - int upnp_ipv6 = 0; - int upnp_error = 0; - devlist = upnpDiscover(upnp_delay, upnp_multicastif, upnp_minissdpdsock, upnp_sameport, upnp_ipv6, &upnp_error); - - return 0; - }" - MINIUPNPC_VERSION_PRE1_7) - ENDIF() - - IF (NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER) - set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) - set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) - check_cxx_source_runs(" - #include - #include - #include - #include - int main() - { - struct UPNPDev *devlist = NULL; - int upnp_delay = 5000; - const char *upnp_multicastif = NULL; - const char *upnp_minissdpdsock = NULL; - int upnp_sameport = 0; - int upnp_ipv6 = 0; - int upnp_error = 0; - devlist = upnpDiscover(upnp_delay, upnp_multicastif, upnp_minissdpdsock, upnp_sameport); - - return 0; - }" - MINIUPNPC_VERSION_PRE1_6) - - ENDIF() - - IF (NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER) - set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) - set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) - check_cxx_source_runs(" - #include - #include - #include - #include - static struct UPNPUrls urls; - static struct IGDdatas data; - int main() - { - char externalIP[16] = \"\"; - UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIP); - - return 0; - }" - MINIUPNPC_VERSION_1_5_OR_HIGHER) - ENDIF() - - IF (NOT MINIUPNPC_VERSION_1_5_OR_HIGHER AND NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7 AND NOT MINIUPNPC_VERSION_1_7_OR_HIGHER) - set(CMAKE_REQUIRED_INCLUDES ${MINIUPNP_INCLUDE_DIR}) - set(CMAKE_REQUIRED_LIBRARIES ${MINIUPNP_LIBRARY}) - check_cxx_source_runs(" - #include - #include - #include - #include - static struct UPNPUrls urls; - static struct IGDdatas data; - int main() - { - char externalIP[16] = \"\"; - UPNP_GetExternalIPAddress(urls.controlURL, data.servicetype, externalIP); - - return 0; - }" - MINIUPNPC_VERSION_PRE1_5) - -ENDIF() - -IF(MINIUPNPC_VERSION_PRE1_5) - message(STATUS "Found miniupnpc version is pre v1.5") -ENDIF() -IF(MINIUPNPC_VERSION_PRE1_6) - message(STATUS "Found miniupnpc version is pre v1.6") -ENDIF() -IF(MINIUPNPC_VERSION_PRE1_7) - message(STATUS "Found miniupnpc version is pre v1.7") -ENDIF() - -IF(NOT MINIUPNPC_VERSION_PRE1_5 AND NOT MINIUPNPC_VERSION_PRE1_6 AND NOT MINIUPNPC_VERSION_PRE1_7) - IF(MINIUPNPC_VERSION_1_5_OR_HIGHER) - message(STATUS "Found miniupnpc version is v1.5 or higher") - ELSE() - message(STATUS "Found miniupnpc version is v1.7 or higher") - ENDIF() -ENDIF() - -else () - message (STATUS "Could not find miniupnp") -endif () - -MARK_AS_ADVANCED(MINIUPNP_INCLUDE_DIR MINIUPNP_LIBRARY) -# --------------------------------- FindMiniupnpc End --------------------------------- - -# And now on to the Monero part of things - -# FreeBSD doesn't play well with the local copy -SET(USE_SHARED false) +# FreeBSD doesn't play well with the local copy, so default to using shared +SET(USE_SHARED_MINIUPNPC true) # If we have the correct shared version and we're not building static, use it -IF(MINIUPNP_FOUND AND MINIUPNPC_VERSION_1_7_OR_HIGHER AND !STATIC) - SET(USE_SHARED true) +IF(!MINIUPNP_FOUND OR !MINIUPNPC_VERSION_1_7_OR_HIGHER OR STATIC) + SET(USE_SHARED_MINIUPNPC false) ENDIF() -# If we're on FreeBSD -IF(FREEBSD) - SET(USE_SHARED true) -ENDIF() - -if(USE_SHARED) +if(USE_SHARED_MINIUPNPC) message(STATUS "Using shared miniupnpc found at ${MINIUPNP_INCLUDE_DIR}") set(UPNP_STATIC false PARENT_SCOPE) set(UPNP_INCLUDE ${MINIUPNP_INCLUDE_DIR} PARENT_SCOPE) set(UPNP_LIBRARIES ${MINIUPNP_LIBRARY} PARENT_SCOPE) else() - message(STATUS "Using static miniupnpc from external") - + if(STATIC) + message(STATUS "Using miniupnpc from local source tree for static build") + else() + message(STATUS "Using miniupnpc from local source tree (/external/miniupnpc)") + endif() + set(UPNPC_BUILD_STATIC ON CACHE BOOL "Build static library") set(UPNPC_BUILD_SHARED OFF CACHE BOOL "Build shared library") set(UPNPC_BUILD_TESTS OFF CACHE BOOL "Build test executables") @@ -253,3 +73,57 @@ else() set(UPNP_STATIC true PARENT_SCOPE) set(UPNP_LIBRARIES "upnpc-static" PARENT_SCOPE) endif() + +find_package(Unbound REQUIRED) + +IF(UNBOUND_INCLUDE_DIR) + MESSAGE(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}") + IF(UNBOUND_LIBRARIES) + MESSAGE(STATUS "Found libunbound shared library") + set(UNBOUND_STATIC false PARENT_SCOPE) + set(UNBOUND_INCLUDE ${UNBOUND_INCLUDE_DIR} PARENT_SCOPE) + set(UNBOUND_LIBRARY ${UNBOUND_LIBRARIES} PARENT_SCOPE) + ELSE() + MESSAGE(FATAL_ERROR "${BoldRed}Found libunbound includes, but could not find libunbound library. Please make sure you have installed libunbound or libunbound-dev or the equivalent${ColourReset}") + ENDIF() +ELSE + if(STATIC) + message(STATUS "Using libunbound from local source tree for static build") + else() + message(STATUS "Using libunbound from local source tree (/external/unbound)") + endif() + + INCLUDE(ExternalProject) + + FIND_PACKAGE(OpenSSL REQUIRED) + FIND_PACKAGE(Expat REQUIRED) + + IF(MINGW) + EXTERNALPROJECT_ADD( + libunbound + URL ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound + BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/unbound + CONFIGURE_COMMAND export USE_WINSOCK=1 && ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound/configure --prefix=${CMAKE_FIND_ROOT_PATH} --build=${GCC_PREFIX} --host=${GCC_PREFIX} --disable-shared --enable-static --sysconfdir=${CMAKE_FIND_ROOT_PATH}/etc --localstatedir=${CMAKE_FIND_ROOT_PATH}/var --sbindir=${CMAKE_FIND_ROOT_PATH}/bin --disable-gost --disable-rpath --with-libevent=no --with-libexpat=${CMAKE_FIND_ROOT_PATH} --without-pyunbound --without-pythonmodule --with-ssl=${CMAKE_FIND_ROOT_PATH} --without-pthreads --with-libunbound-only + BUILD_COMMAND make + ) + ELSEIF(APPLE) + EXTERNALPROJECT_ADD( + libunbound + URL ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound + BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/unbound + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound/configure --prefix=$(brew --prefix) --disable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only + BUILD_COMMAND make + ) + ELSE() + EXTERNALPROJECT_ADD( + libunbound + URL ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound + BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/unbound + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound/configure --disable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only + BUILD_COMMAND make + ) + ENDIF() + + set(UNBOUND_STATIC true PARENT_SCOPE) + set(UNBOUND_LIBRARY unbound-static PARENT_SCOPE) +ENDIF() diff --git a/src/common/dns_utils.cpp b/src/common/dns_utils.cpp index 8c4038568..d21b538a6 100644 --- a/src/common/dns_utils.cpp +++ b/src/common/dns_utils.cpp @@ -29,7 +29,8 @@ #include "common/dns_utils.h" #include #include -#include +// check local first (in the event of static or in-source compilation of libunbound) +#include "unbound.h" #include #include "include_base_utils.h" From 8c00098c7508d7985d8724f295597fb8d70db7ff Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 15:01:00 +0200 Subject: [PATCH 12/29] fix missing parentheses --- external/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 2b5d81f28..2e6a2f86d 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -86,7 +86,7 @@ IF(UNBOUND_INCLUDE_DIR) ELSE() MESSAGE(FATAL_ERROR "${BoldRed}Found libunbound includes, but could not find libunbound library. Please make sure you have installed libunbound or libunbound-dev or the equivalent${ColourReset}") ENDIF() -ELSE +ELSE() if(STATIC) message(STATUS "Using libunbound from local source tree for static build") else() From cc0f6a6080bd21a96e16d38850bdbdb7012a4d03 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 15:40:01 +0200 Subject: [PATCH 13/29] build libunbound correctly --- external/CMakeLists.txt | 71 +++++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 2e6a2f86d..0cafec53c 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -76,17 +76,7 @@ endif() find_package(Unbound REQUIRED) -IF(UNBOUND_INCLUDE_DIR) - MESSAGE(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}") - IF(UNBOUND_LIBRARIES) - MESSAGE(STATUS "Found libunbound shared library") - set(UNBOUND_STATIC false PARENT_SCOPE) - set(UNBOUND_INCLUDE ${UNBOUND_INCLUDE_DIR} PARENT_SCOPE) - set(UNBOUND_LIBRARY ${UNBOUND_LIBRARIES} PARENT_SCOPE) - ELSE() - MESSAGE(FATAL_ERROR "${BoldRed}Found libunbound includes, but could not find libunbound library. Please make sure you have installed libunbound or libunbound-dev or the equivalent${ColourReset}") - ENDIF() -ELSE() +IF(!UNBOUND_INCLUDE_DIR OR STATIC) if(STATIC) message(STATUS "Using libunbound from local source tree for static build") else() @@ -101,29 +91,68 @@ ELSE() IF(MINGW) EXTERNALPROJECT_ADD( libunbound - URL ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound - BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/unbound - CONFIGURE_COMMAND export USE_WINSOCK=1 && ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound/configure --prefix=${CMAKE_FIND_ROOT_PATH} --build=${GCC_PREFIX} --host=${GCC_PREFIX} --disable-shared --enable-static --sysconfdir=${CMAKE_FIND_ROOT_PATH}/etc --localstatedir=${CMAKE_FIND_ROOT_PATH}/var --sbindir=${CMAKE_FIND_ROOT_PATH}/bin --disable-gost --disable-rpath --with-libevent=no --with-libexpat=${CMAKE_FIND_ROOT_PATH} --without-pyunbound --without-pythonmodule --with-ssl=${CMAKE_FIND_ROOT_PATH} --without-pthreads --with-libunbound-only + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/unbound + URL ${CMAKE_CURRENT_SOURCE_DIR}/unbound/ + CONFIGURE_COMMAND export USE_WINSOCK=1 && ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure --prefix=${CMAKE_FIND_ROOT_PATH} --build=${GCC_PREFIX} --host=${GCC_PREFIX} --disable-shared --enable-static --sysconfdir=${CMAKE_FIND_ROOT_PATH}/etc --localstatedir=${CMAKE_FIND_ROOT_PATH}/var --sbindir=${CMAKE_FIND_ROOT_PATH}/bin --disable-gost --disable-rpath --with-libevent=no --with-libexpat=${CMAKE_FIND_ROOT_PATH} --without-pyunbound --without-pythonmodule --with-ssl=${CMAKE_FIND_ROOT_PATH} --without-pthreads --with-libunbound-only BUILD_COMMAND make + UPDATE_COMMAND "" + PATCH_COMMAND "" + INSTALL_COMMAND "" + LOG_DOWNLOAD 1 + LOG_UPDATE 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_TEST 1 + LOG_INSTALL 1 ) ELSEIF(APPLE) + execute_process(COMMAND brew --prefix OUTPUT_VARIABLE BREW_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) EXTERNALPROJECT_ADD( libunbound - URL ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound - BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/unbound - CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound/configure --prefix=$(brew --prefix) --disable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/unbound + URL ${CMAKE_CURRENT_SOURCE_DIR}/unbound/ + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure --prefix=${BREW_PREFIX} --disable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only BUILD_COMMAND make + UPDATE_COMMAND "" + PATCH_COMMAND "" + INSTALL_COMMAND "" + LOG_DOWNLOAD 1 + LOG_UPDATE 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_TEST 1 + LOG_INSTALL 1 ) ELSE() EXTERNALPROJECT_ADD( libunbound - URL ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound - BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/unbound - CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/external/unbound/configure --disable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/unbound + URL ${CMAKE_CURRENT_SOURCE_DIR}/unbound/ + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure --disable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only BUILD_COMMAND make + UPDATE_COMMAND "" + PATCH_COMMAND "" + INSTALL_COMMAND "" + LOG_DOWNLOAD 1 + LOG_UPDATE 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_TEST 1 + LOG_INSTALL 1 ) ENDIF() set(UNBOUND_STATIC true PARENT_SCOPE) - set(UNBOUND_LIBRARY unbound-static PARENT_SCOPE) + set(UNBOUND_INCLUDE "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build" PARENT_SCOPE) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build" PARENT_SCOPE) +ELSE() + MESSAGE(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}") + IF(UNBOUND_LIBRARIES) + MESSAGE(STATUS "Found libunbound shared library") + set(UNBOUND_STATIC false PARENT_SCOPE) + set(UNBOUND_INCLUDE ${UNBOUND_INCLUDE_DIR} PARENT_SCOPE) + set(UNBOUND_LIBRARY ${UNBOUND_LIBRARIES} PARENT_SCOPE) + ELSE() + MESSAGE(FATAL_ERROR "${BoldRed}Found libunbound includes, but could not find libunbound library. Please make sure you have installed libunbound or libunbound-dev or the equivalent${ColourReset}") + ENDIF() ENDIF() From fd52015a2de015fc81ee9d750a5eaa54ca88ecbe Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 16:05:24 +0200 Subject: [PATCH 14/29] use the correct CMake variable for static builds --- external/CMakeLists.txt | 2 +- src/CMakeLists.txt | 8 ++++---- tests/CMakeLists.txt | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 0cafec53c..24aca9be0 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -144,7 +144,7 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) set(UNBOUND_STATIC true PARENT_SCOPE) set(UNBOUND_INCLUDE "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build" PARENT_SCOPE) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build" PARENT_SCOPE) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.la" PARENT_SCOPE) ELSE() MESSAGE(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}") IF(UNBOUND_LIBRARIES) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2393213cb..e000b635d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -63,14 +63,14 @@ add_library(mnemonics ${MNEMONICS}) add_executable(daemon ${DAEMON} ${P2P} ${CRYPTONOTE_PROTOCOL}) add_executable(connectivity_tool ${CONN_TOOL}) add_executable(simpleminer ${MINER}) -target_link_libraries(daemon rpc cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) -target_link_libraries(connectivity_tool cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) -target_link_libraries(simpleminer cryptonote_core crypto common ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(daemon rpc cryptonote_core crypto common ${UNBOUND_LIBRARY} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(connectivity_tool cryptonote_core crypto common ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(simpleminer cryptonote_core crypto common ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) add_library(rpc ${RPC}) add_library(wallet ${WALLET}) target_link_libraries(wallet mnemonics) add_executable(simplewallet ${SIMPLEWALLET} ) -target_link_libraries(simplewallet wallet rpc cryptonote_core crypto common mnemonics ${UNBOUND_LIBRARIES} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(simplewallet wallet rpc cryptonote_core crypto common mnemonics ${UNBOUND_LIBRARY} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) add_dependencies(daemon version) add_dependencies(rpc version) add_dependencies(simplewallet version) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 14695ddd8..a95c34f0f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -61,16 +61,16 @@ add_executable(unit_tests ${UNIT_TESTS}) add_executable(net_load_tests_clt net_load_tests/clt.cpp) add_executable(net_load_tests_srv net_load_tests/srv.cpp) -target_link_libraries(core_proxy cryptonote_core common crypto ${UNBOUND_LIBRARIES} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) -target_link_libraries(coretests cryptonote_core common crypto ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(core_proxy cryptonote_core common crypto ${UNBOUND_LIBRARY} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(coretests cryptonote_core common crypto ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) target_link_libraries(difficulty-tests cryptonote_core) -target_link_libraries(functional_tests cryptonote_core wallet common crypto ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(functional_tests cryptonote_core wallet common crypto ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) target_link_libraries(hash-tests crypto) target_link_libraries(hash-target-tests crypto cryptonote_core) -target_link_libraries(performance_tests cryptonote_core common crypto ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) -target_link_libraries(unit_tests gtest_main cryptonote_core wallet crypto common ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) -target_link_libraries(net_load_tests_clt cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) -target_link_libraries(net_load_tests_srv cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(performance_tests cryptonote_core common crypto ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(unit_tests gtest_main cryptonote_core wallet crypto common ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(net_load_tests_clt cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(net_load_tests_srv cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) if(NOT MSVC) set_property(TARGET gtest gtest_main unit_tests net_load_tests_clt net_load_tests_srv APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-sign-compare") From 954a244afefe84504cb42ee42be30de400ad5887 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 17:19:51 +0200 Subject: [PATCH 15/29] added libtool's install command --- external/CMakeLists.txt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 24aca9be0..cbd70800a 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -94,10 +94,10 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) PREFIX ${CMAKE_CURRENT_BINARY_DIR}/unbound URL ${CMAKE_CURRENT_SOURCE_DIR}/unbound/ CONFIGURE_COMMAND export USE_WINSOCK=1 && ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure --prefix=${CMAKE_FIND_ROOT_PATH} --build=${GCC_PREFIX} --host=${GCC_PREFIX} --disable-shared --enable-static --sysconfdir=${CMAKE_FIND_ROOT_PATH}/etc --localstatedir=${CMAKE_FIND_ROOT_PATH}/var --sbindir=${CMAKE_FIND_ROOT_PATH}/bin --disable-gost --disable-rpath --with-libevent=no --with-libexpat=${CMAKE_FIND_ROOT_PATH} --without-pyunbound --without-pythonmodule --with-ssl=${CMAKE_FIND_ROOT_PATH} --without-pthreads --with-libunbound-only - BUILD_COMMAND make + BUILD_COMMAND $(MAKE) UPDATE_COMMAND "" PATCH_COMMAND "" - INSTALL_COMMAND "" + INSTALL_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libtool --mode=install cp ${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.la ${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build LOG_DOWNLOAD 1 LOG_UPDATE 1 LOG_CONFIGURE 1 @@ -105,17 +105,18 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.dll.la" PARENT_SCOPE) ELSEIF(APPLE) execute_process(COMMAND brew --prefix OUTPUT_VARIABLE BREW_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) EXTERNALPROJECT_ADD( libunbound PREFIX ${CMAKE_CURRENT_BINARY_DIR}/unbound URL ${CMAKE_CURRENT_SOURCE_DIR}/unbound/ - CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure --prefix=${BREW_PREFIX} --disable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only - BUILD_COMMAND make + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure --prefix=${BREW_PREFIX} --enable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only + BUILD_COMMAND $(MAKE) UPDATE_COMMAND "" PATCH_COMMAND "" - INSTALL_COMMAND "" + INSTALL_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libtool --mode=install cp ${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.la ${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build LOG_DOWNLOAD 1 LOG_UPDATE 1 LOG_CONFIGURE 1 @@ -123,16 +124,17 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.la" PARENT_SCOPE) ELSE() EXTERNALPROJECT_ADD( libunbound PREFIX ${CMAKE_CURRENT_BINARY_DIR}/unbound URL ${CMAKE_CURRENT_SOURCE_DIR}/unbound/ CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure --disable-shared --enable-static --disable-gost --disable-rpath --with-libevent=no --without-pyunbound --without-pythonmodule --without-pthreads --with-libunbound-only - BUILD_COMMAND make + BUILD_COMMAND $(MAKE) UPDATE_COMMAND "" PATCH_COMMAND "" - INSTALL_COMMAND "" + INSTALL_COMMAND ${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libtool --mode=install cp ${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.la ${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build LOG_DOWNLOAD 1 LOG_UPDATE 1 LOG_CONFIGURE 1 @@ -140,6 +142,7 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.la" PARENT_SCOPE) ENDIF() set(UNBOUND_STATIC true PARENT_SCOPE) From c70fa8689f61c22166668eace25cc6a3e3d9e048 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 17:28:59 +0200 Subject: [PATCH 16/29] reference the correct unbound static lib --- external/CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index cbd70800a..58f81fd34 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -105,7 +105,7 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.dll.la" PARENT_SCOPE) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.dll.a" PARENT_SCOPE) ELSEIF(APPLE) execute_process(COMMAND brew --prefix OUTPUT_VARIABLE BREW_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) EXTERNALPROJECT_ADD( @@ -124,7 +124,7 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.la" PARENT_SCOPE) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.a" PARENT_SCOPE) ELSE() EXTERNALPROJECT_ADD( libunbound @@ -142,12 +142,11 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.la" PARENT_SCOPE) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.a" PARENT_SCOPE) ENDIF() set(UNBOUND_STATIC true PARENT_SCOPE) set(UNBOUND_INCLUDE "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build" PARENT_SCOPE) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.la" PARENT_SCOPE) ELSE() MESSAGE(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}") IF(UNBOUND_LIBRARIES) From 5829b351479e7ebd5a22d35af51f9fba033b0b31 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 18:06:25 +0200 Subject: [PATCH 17/29] include openssl in linbunbound static linking, added errors for openssl and expat --- external/CMakeLists.txt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 58f81fd34..77de69c17 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -86,7 +86,18 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) INCLUDE(ExternalProject) FIND_PACKAGE(OpenSSL REQUIRED) + IF(!OPENSSL_LIBRARIES) + MESSAGE(FATAL_ERROR "${BoldRed}Could not find the openssl library. Please make sure you have installed openssl or libssl-dev or the equivalent${ColourReset}") + ELSE() + MESSAGE(STATUS "Found openssl libraries") + ENDIF() + FIND_PACKAGE(Expat REQUIRED) + IF(!EXPAT_LIBRARIES) + MESSAGE(FATAL_ERROR "${BoldRed}Could not find the expat library. Please make sure you have installed libexpat or libexpat-dev or the equivalent${ColourReset}") + ELSE() + MESSAGE(STATUS "Found expat libraries") + ENDIF() IF(MINGW) EXTERNALPROJECT_ADD( @@ -105,7 +116,7 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.dll.a" PARENT_SCOPE) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.dll.a;${OPENSSL_LIBRARIES}" PARENT_SCOPE) ELSEIF(APPLE) execute_process(COMMAND brew --prefix OUTPUT_VARIABLE BREW_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) EXTERNALPROJECT_ADD( @@ -124,7 +135,7 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.a" PARENT_SCOPE) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.a;${OPENSSL_LIBRARIES}" PARENT_SCOPE) ELSE() EXTERNALPROJECT_ADD( libunbound @@ -142,7 +153,7 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.a" PARENT_SCOPE) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.a;${OPENSSL_LIBRARIES}" PARENT_SCOPE) ENDIF() set(UNBOUND_STATIC true PARENT_SCOPE) From 6b7ac4b37f6a3ed752e1db1e1be1a98b6ad6f19f Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 18:46:18 +0200 Subject: [PATCH 18/29] enforce static libraries when building statically --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b9bcc411c..54565464c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,6 +87,14 @@ else() endif() set(STATIC ${DEFAULT_STATIC} CACHE BOOL "Link libraries statically") +IF(STATIC) + IF(MSVC) + SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .dll.a .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + ELSE() + SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + ENDIF() +ENDIF() + if (UNIX AND NOT APPLE) # Note that at the time of this writing the -Wstrict-prototypes flag added below will make this fail find_package(Threads) From 735a017bb3b9ec8c3a240cf2a8feee789e0a95e8 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 18:51:03 +0200 Subject: [PATCH 19/29] removed required flags from miniupnp and unbound --- external/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 77de69c17..954424ea7 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -35,7 +35,7 @@ # ...except for FreeBSD, because FreeBSD is a special case that doesn't play well with # others. -find_package(MiniUpnpc REQUIRED) +find_package(MiniUpnpc) # FreeBSD doesn't play well with the local copy, so default to using shared SET(USE_SHARED_MINIUPNPC true) @@ -74,7 +74,7 @@ else() set(UPNP_LIBRARIES "upnpc-static" PARENT_SCOPE) endif() -find_package(Unbound REQUIRED) +find_package(Unbound) IF(!UNBOUND_INCLUDE_DIR OR STATIC) if(STATIC) From 1afba7311ee82aa3f951ace1dde38f179703b385 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 18:56:59 +0200 Subject: [PATCH 20/29] quieten CMake when it can't find packages --- CMakeLists.txt | 2 +- external/CMakeLists.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54565464c..633a5e8d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -201,7 +201,7 @@ if(STATIC) set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_STATIC_RUNTIME ON) endif() -find_package(Boost 1.53 REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options) +find_package(Boost 1.53 QUIET REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options) if(NOT Boost_FOUND) MESSAGE(FATAL_ERROR "${BoldRed}Could not find Boost libraries, please make sure you have installed Boost or libboost-all-dev (1.53 or 1.55+) or the equivalent${ColourReset}") diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 954424ea7..1fad9bfe5 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -35,7 +35,7 @@ # ...except for FreeBSD, because FreeBSD is a special case that doesn't play well with # others. -find_package(MiniUpnpc) +find_package(MiniUpnpc QUIET) # FreeBSD doesn't play well with the local copy, so default to using shared SET(USE_SHARED_MINIUPNPC true) @@ -85,14 +85,14 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) INCLUDE(ExternalProject) - FIND_PACKAGE(OpenSSL REQUIRED) + FIND_PACKAGE(OpenSSL QUIET) IF(!OPENSSL_LIBRARIES) MESSAGE(FATAL_ERROR "${BoldRed}Could not find the openssl library. Please make sure you have installed openssl or libssl-dev or the equivalent${ColourReset}") ELSE() MESSAGE(STATUS "Found openssl libraries") ENDIF() - FIND_PACKAGE(Expat REQUIRED) + FIND_PACKAGE(Expat QUIET) IF(!EXPAT_LIBRARIES) MESSAGE(FATAL_ERROR "${BoldRed}Could not find the expat library. Please make sure you have installed libexpat or libexpat-dev or the equivalent${ColourReset}") ELSE() From 6be3d1db944c776739cbb619f8a7ac3ff4d6943c Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 19:04:37 +0200 Subject: [PATCH 21/29] added bison/yacc static build dependency --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8ec56a53b..b40e06b8e 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Parts of the project are originally copyright (c) 2012-2013 The Cryptonote devel ### On Unix and Linux: Dependencies: GCC 4.7.3 or later, CMake 2.8.6 or later, libunbound 1.4.16 or later (note: Unbound is not a dependency, libunbound is), and Boost 1.53 or later (except 1.54, [more details here](http://goo.gl/RrCFmA)). -Static Build Additional Dependencies: ldns 1.6.17 or later, expat 1.1 or later +Static Build Additional Dependencies: ldns 1.6.17 or later, expat 1.1 or later, bison or yacc **Basic Process:** From f8fd03602c5dced6feba3bab56132a1d82fa1103 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 19:17:40 +0200 Subject: [PATCH 22/29] turns out mingw does actually produce .a libs and not .dll.a --- external/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 1fad9bfe5..9f24761ce 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -116,7 +116,6 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.dll.a;${OPENSSL_LIBRARIES}" PARENT_SCOPE) ELSEIF(APPLE) execute_process(COMMAND brew --prefix OUTPUT_VARIABLE BREW_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) EXTERNALPROJECT_ADD( @@ -135,7 +134,6 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.a;${OPENSSL_LIBRARIES}" PARENT_SCOPE) ELSE() EXTERNALPROJECT_ADD( libunbound @@ -153,11 +151,11 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) LOG_TEST 1 LOG_INSTALL 1 ) - set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.a;${OPENSSL_LIBRARIES}" PARENT_SCOPE) ENDIF() set(UNBOUND_STATIC true PARENT_SCOPE) set(UNBOUND_INCLUDE "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build" PARENT_SCOPE) + set(UNBOUND_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/unbound/src/libunbound-build/libunbound.a;${OPENSSL_LIBRARIES}" PARENT_SCOPE) ELSE() MESSAGE(STATUS "Found libunbound include (unbound.h) in ${UNBOUND_INCLUDE_DIR}") IF(UNBOUND_LIBRARIES) From 0586a27a1310066c7e32492360dafa997dfa8d0c Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 19:19:47 +0200 Subject: [PATCH 23/29] fixed configure_command for libunbound under mingw --- external/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 9f24761ce..bab2ac450 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -104,7 +104,7 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) libunbound PREFIX ${CMAKE_CURRENT_BINARY_DIR}/unbound URL ${CMAKE_CURRENT_SOURCE_DIR}/unbound/ - CONFIGURE_COMMAND export USE_WINSOCK=1 && ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure --prefix=${CMAKE_FIND_ROOT_PATH} --build=${GCC_PREFIX} --host=${GCC_PREFIX} --disable-shared --enable-static --sysconfdir=${CMAKE_FIND_ROOT_PATH}/etc --localstatedir=${CMAKE_FIND_ROOT_PATH}/var --sbindir=${CMAKE_FIND_ROOT_PATH}/bin --disable-gost --disable-rpath --with-libevent=no --with-libexpat=${CMAKE_FIND_ROOT_PATH} --without-pyunbound --without-pythonmodule --with-ssl=${CMAKE_FIND_ROOT_PATH} --without-pthreads --with-libunbound-only + CONFIGURE_COMMAND COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure USE_WINSOCK=1 --prefix=${CMAKE_FIND_ROOT_PATH} --build=${GCC_PREFIX} --host=${GCC_PREFIX} --disable-shared --enable-static --sysconfdir=${CMAKE_FIND_ROOT_PATH}/etc --localstatedir=${CMAKE_FIND_ROOT_PATH}/var --sbindir=${CMAKE_FIND_ROOT_PATH}/bin --disable-gost --disable-rpath --with-libevent=no --with-libexpat=${CMAKE_FIND_ROOT_PATH} --without-pyunbound --without-pythonmodule --with-ssl=${CMAKE_FIND_ROOT_PATH} --without-pthreads --with-libunbound-only BUILD_COMMAND $(MAKE) UPDATE_COMMAND "" PATCH_COMMAND "" From e55982a892563be91e9d6f14d3dfe95d952ff2e5 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 19:40:53 +0200 Subject: [PATCH 24/29] set the winsock variable differently on Windows --- external/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index bab2ac450..2b10442a4 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -100,11 +100,12 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) ENDIF() IF(MINGW) + set(ENV{USE_WINSOCK} 1) EXTERNALPROJECT_ADD( libunbound PREFIX ${CMAKE_CURRENT_BINARY_DIR}/unbound URL ${CMAKE_CURRENT_SOURCE_DIR}/unbound/ - CONFIGURE_COMMAND COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure USE_WINSOCK=1 --prefix=${CMAKE_FIND_ROOT_PATH} --build=${GCC_PREFIX} --host=${GCC_PREFIX} --disable-shared --enable-static --sysconfdir=${CMAKE_FIND_ROOT_PATH}/etc --localstatedir=${CMAKE_FIND_ROOT_PATH}/var --sbindir=${CMAKE_FIND_ROOT_PATH}/bin --disable-gost --disable-rpath --with-libevent=no --with-libexpat=${CMAKE_FIND_ROOT_PATH} --without-pyunbound --without-pythonmodule --with-ssl=${CMAKE_FIND_ROOT_PATH} --without-pthreads --with-libunbound-only + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure --prefix=${CMAKE_FIND_ROOT_PATH} --build=${GCC_PREFIX} --host=${GCC_PREFIX} --disable-shared --enable-static --sysconfdir=${CMAKE_FIND_ROOT_PATH}/etc --localstatedir=${CMAKE_FIND_ROOT_PATH}/var --sbindir=${CMAKE_FIND_ROOT_PATH}/bin --disable-gost --disable-rpath --with-libevent=no --with-libexpat=${CMAKE_FIND_ROOT_PATH} --without-pyunbound --without-pythonmodule --with-ssl=${CMAKE_FIND_ROOT_PATH} --without-pthreads --with-libunbound-only BUILD_COMMAND $(MAKE) UPDATE_COMMAND "" PATCH_COMMAND "" From b05e27f8b1be83287441f82cb2f19a37aed2c1b6 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 21:17:31 +0200 Subject: [PATCH 25/29] need to link with -ldl on Linux when building statically --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 633a5e8d2..6db1a723d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,6 +217,7 @@ if(MINGW) elseif(APPLE OR FREEBSD) set(Boost_LIBRARIES "${Boost_LIBRARIES}") elseif(NOT MSVC) + set(Boost_LIBRARIES "${Boost_LIBRARIES};ld") #set(Boost_LIBRARIES "${Boost_LIBRARIES};rt;pthread") endif() From 2cf94c1321438eb66ffefca547b74f746d7c283a Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 22:29:07 +0200 Subject: [PATCH 26/29] fix for mingw not playing nicely with libunbound configure, fix for correctly finding static libs on various operating systems --- CMakeLists.txt | 13 +++++++++---- external/CMakeLists.txt | 5 ++++- external/unbound/monero-config.sh | 3 +++ src/CMakeLists.txt | 8 ++++---- tests/CMakeLists.txt | 14 +++++++------- 5 files changed, 27 insertions(+), 16 deletions(-) create mode 100755 external/unbound/monero-config.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 6db1a723d..cdfb7d141 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,12 +213,17 @@ endif() include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) if(MINGW) - set(Boost_LIBRARIES "${Boost_LIBRARIES};pthread;mswsock;ws2_32") + find_library(PTHREAD pthread) + find_library(MSWSOCK mswsock) + find_library(WS2_32 ws2_32) + set(EXTRA_LIBRARIES ${PTHREAD} ${MSWSOCK} ${WS2_32}) elseif(APPLE OR FREEBSD) - set(Boost_LIBRARIES "${Boost_LIBRARIES}") + set(EXTRA_LIBRARIES "") elseif(NOT MSVC) - set(Boost_LIBRARIES "${Boost_LIBRARIES};ld") - #set(Boost_LIBRARIES "${Boost_LIBRARIES};rt;pthread") + find_library(RT rt) + find_library(PTHREAD pthread) + find_library(DL dl) + set(EXTRA_LIBRARIES ${RT} ${PTHREAD} ${DL}) endif() file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/version") diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 2b10442a4..3fb1cfce7 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -101,11 +101,14 @@ IF(!UNBOUND_INCLUDE_DIR OR STATIC) IF(MINGW) set(ENV{USE_WINSOCK} 1) + set(ENV{CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) + set(ENV{GCC_PREFIX} ${GCC_PREFIX}) + set(ENV{CMAKE_FIND_ROOT_PATH} ${CMAKE_FIND_ROOT_PATH}) EXTERNALPROJECT_ADD( libunbound PREFIX ${CMAKE_CURRENT_BINARY_DIR}/unbound URL ${CMAKE_CURRENT_SOURCE_DIR}/unbound/ - CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/unbound/configure --prefix=${CMAKE_FIND_ROOT_PATH} --build=${GCC_PREFIX} --host=${GCC_PREFIX} --disable-shared --enable-static --sysconfdir=${CMAKE_FIND_ROOT_PATH}/etc --localstatedir=${CMAKE_FIND_ROOT_PATH}/var --sbindir=${CMAKE_FIND_ROOT_PATH}/bin --disable-gost --disable-rpath --with-libevent=no --with-libexpat=${CMAKE_FIND_ROOT_PATH} --without-pyunbound --without-pythonmodule --with-ssl=${CMAKE_FIND_ROOT_PATH} --without-pthreads --with-libunbound-only + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/unbound/monero-config.sh BUILD_COMMAND $(MAKE) UPDATE_COMMAND "" PATCH_COMMAND "" diff --git a/external/unbound/monero-config.sh b/external/unbound/monero-config.sh new file mode 100755 index 000000000..cfdc7e04b --- /dev/null +++ b/external/unbound/monero-config.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +./configure --prefix=${CMAKE_FIND_ROOT_PATH} --build=${GCC_PREFIX} --host=${GCC_PREFIX} --disable-shared --enable-static --sysconfdir=${CMAKE_FIND_ROOT_PATH}/etc --localstatedir=${CMAKE_FIND_ROOT_PATH}/var --sbindir=${CMAKE_FIND_ROOT_PATH}/bin --disable-gost --disable-rpath --with-libevent=no --with-libexpat=${CMAKE_FIND_ROOT_PATH} --without-pyunbound --without-pythonmodule --with-ssl=${CMAKE_FIND_ROOT_PATH} --without-pthreads --with-libunbound-only diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e000b635d..321d0555b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -63,14 +63,14 @@ add_library(mnemonics ${MNEMONICS}) add_executable(daemon ${DAEMON} ${P2P} ${CRYPTONOTE_PROTOCOL}) add_executable(connectivity_tool ${CONN_TOOL}) add_executable(simpleminer ${MINER}) -target_link_libraries(daemon rpc cryptonote_core crypto common ${UNBOUND_LIBRARY} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) -target_link_libraries(connectivity_tool cryptonote_core crypto common ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) -target_link_libraries(simpleminer cryptonote_core crypto common ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(daemon rpc cryptonote_core crypto common ${UNBOUND_LIBRARY} ${UPNP_LIBRARIES} ${Boost_LIBRARIES} ${EXTRA_LIBRARIES}) +target_link_libraries(connectivity_tool cryptonote_core crypto common ${UNBOUND_LIBRARY} ${Boost_LIBRARIES} ${EXTRA_LIBRARIES}) +target_link_libraries(simpleminer cryptonote_core crypto common ${UNBOUND_LIBRARY} ${Boost_LIBRARIES} ${EXTRA_LIBRARIES}) add_library(rpc ${RPC}) add_library(wallet ${WALLET}) target_link_libraries(wallet mnemonics) add_executable(simplewallet ${SIMPLEWALLET} ) -target_link_libraries(simplewallet wallet rpc cryptonote_core crypto common mnemonics ${UNBOUND_LIBRARY} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(simplewallet wallet rpc cryptonote_core crypto common mnemonics ${UNBOUND_LIBRARY} ${UPNP_LIBRARIES} ${Boost_LIBRARIES} ${EXTRA_LIBRARIES}) add_dependencies(daemon version) add_dependencies(rpc version) add_dependencies(simplewallet version) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a95c34f0f..44582463d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -61,16 +61,16 @@ add_executable(unit_tests ${UNIT_TESTS}) add_executable(net_load_tests_clt net_load_tests/clt.cpp) add_executable(net_load_tests_srv net_load_tests/srv.cpp) -target_link_libraries(core_proxy cryptonote_core common crypto ${UNBOUND_LIBRARY} ${UPNP_LIBRARIES} ${Boost_LIBRARIES}) -target_link_libraries(coretests cryptonote_core common crypto ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(core_proxy cryptonote_core common crypto ${UNBOUND_LIBRARY} ${UPNP_LIBRARIES} ${Boost_LIBRARIES} ${EXTRA_LIBRARIES}) +target_link_libraries(coretests cryptonote_core common crypto ${UNBOUND_LIBRARY} ${Boost_LIBRARIES} ${EXTRA_LIBRARIES}) target_link_libraries(difficulty-tests cryptonote_core) -target_link_libraries(functional_tests cryptonote_core wallet common crypto ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(functional_tests cryptonote_core wallet common crypto ${UNBOUND_LIBRARY} ${Boost_LIBRARIES} ${EXTRA_LIBRARIES}) target_link_libraries(hash-tests crypto) target_link_libraries(hash-target-tests crypto cryptonote_core) -target_link_libraries(performance_tests cryptonote_core common crypto ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) -target_link_libraries(unit_tests gtest_main cryptonote_core wallet crypto common ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) -target_link_libraries(net_load_tests_clt cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) -target_link_libraries(net_load_tests_srv cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARY} ${Boost_LIBRARIES}) +target_link_libraries(performance_tests cryptonote_core common crypto ${UNBOUND_LIBRARY} ${Boost_LIBRARIES} ${EXTRA_LIBRARIES}) +target_link_libraries(unit_tests gtest_main cryptonote_core wallet crypto common ${UNBOUND_LIBRARY} ${Boost_LIBRARIES} ${EXTRA_LIBRARIES}) +target_link_libraries(net_load_tests_clt cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARY} ${Boost_LIBRARIES} ${EXTRA_LIBRARIES}) +target_link_libraries(net_load_tests_srv cryptonote_core common crypto gtest_main ${UNBOUND_LIBRARY} ${Boost_LIBRARIES} ${EXTRA_LIBRARIES}) if(NOT MSVC) set_property(TARGET gtest gtest_main unit_tests net_load_tests_clt net_load_tests_srv APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-sign-compare") From 26728d94fe8390ecb7a7e88d964da54475357258 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 22:34:44 +0200 Subject: [PATCH 27/29] mingw library tweaks --- CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cdfb7d141..78e4b426f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,10 +213,7 @@ endif() include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) if(MINGW) - find_library(PTHREAD pthread) - find_library(MSWSOCK mswsock) - find_library(WS2_32 ws2_32) - set(EXTRA_LIBRARIES ${PTHREAD} ${MSWSOCK} ${WS2_32}) + set(EXTRA_LIBRARIES pthread;mswsock;ws2_32) elseif(APPLE OR FREEBSD) set(EXTRA_LIBRARIES "") elseif(NOT MSVC) From 7c1d3b50906f9ee3598451f3c3f2a04a2aeb93d6 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Mon, 6 Oct 2014 23:54:48 +0200 Subject: [PATCH 28/29] fixed miniupnpc dynamic target --- external/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 3fb1cfce7..83e9e6dee 100755 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -38,11 +38,13 @@ find_package(MiniUpnpc QUIET) # FreeBSD doesn't play well with the local copy, so default to using shared -SET(USE_SHARED_MINIUPNPC true) +SET(USE_SHARED_MINIUPNPC false) # If we have the correct shared version and we're not building static, use it -IF(!MINIUPNP_FOUND OR !MINIUPNPC_VERSION_1_7_OR_HIGHER OR STATIC) +IF(STATIC) SET(USE_SHARED_MINIUPNPC false) +ELSEIF(MINIUPNP_FOUND AND MINIUPNPC_VERSION_1_7_OR_HIGHER) + SET(USE_SHARED_MINIUPNPC true) ENDIF() if(USE_SHARED_MINIUPNPC) From b41907574acfa50fba741b8b956dcfe4c5662ed0 Mon Sep 17 00:00:00 2001 From: Riccardo Spagni Date: Tue, 7 Oct 2014 00:08:47 +0200 Subject: [PATCH 29/29] added hardcoded checkpoint at block 249380 --- src/cryptonote_core/checkpoints_create.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cryptonote_core/checkpoints_create.cpp b/src/cryptonote_core/checkpoints_create.cpp index 4ac2f0e5b..9ad0a27e8 100644 --- a/src/cryptonote_core/checkpoints_create.cpp +++ b/src/cryptonote_core/checkpoints_create.cpp @@ -75,6 +75,7 @@ bool create_checkpoints(cryptonote::checkpoints& checkpoints) ADD_CHECKPOINT(230700, "93e631240ceac831da1aebfc5dac8f722c430463024763ebafa888796ceaeedf"); ADD_CHECKPOINT(231350, "b5add137199b820e1ea26640e5c3e121fd85faa86a1e39cf7e6cc097bdeb1131"); ADD_CHECKPOINT(232150, "955de8e6b6508af2c24f7334f97beeea651d78e9ade3ab18fec3763be3201aa8"); + ADD_CHECKPOINT(249380, "654fb0a81ce3e5caf7e3264a70f447d4bd07586c08fa50f6638cc54da0a52b2d"); return true; }