2017-02-21 17:38:18 +00:00
|
|
|
# Copyright (c) 2014-2017, The Monero Project
|
2017-06-16 10:16:05 +00:00
|
|
|
#
|
2015-03-02 15:20:42 +00:00
|
|
|
# All rights reserved.
|
2017-06-16 10:16:05 +00:00
|
|
|
#
|
2015-03-02 15:20:42 +00:00
|
|
|
# Redistribution and use in source and binary forms, with or without modification, are
|
|
|
|
# permitted provided that the following conditions are met:
|
2017-06-16 10:16:05 +00:00
|
|
|
#
|
2015-03-02 15:20:42 +00:00
|
|
|
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
|
|
# conditions and the following disclaimer.
|
2017-06-16 10:16:05 +00:00
|
|
|
#
|
2015-03-02 15:20:42 +00:00
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
|
|
# of conditions and the following disclaimer in the documentation and/or other
|
|
|
|
# materials provided with the distribution.
|
2017-06-16 10:16:05 +00:00
|
|
|
#
|
2015-03-02 15:20:42 +00:00
|
|
|
# 3. Neither the name of the copyright holder nor the names of its contributors may be
|
|
|
|
# used to endorse or promote products derived from this software without specific
|
|
|
|
# prior written permission.
|
2017-06-16 10:16:05 +00:00
|
|
|
#
|
2015-03-02 15:20:42 +00:00
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
|
|
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
|
|
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
|
|
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2015-04-04 21:56:12 +00:00
|
|
|
cmake_minimum_required(VERSION 2.8.7)
|
|
|
|
|
|
|
|
project(unbound C)
|
|
|
|
|
|
|
|
find_package(Threads)
|
|
|
|
|
|
|
|
include(configure_checks.cmake)
|
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
set(USE_MINI_EVENT 1)
|
|
|
|
set(USE_WINSOCK 1)
|
|
|
|
else ()
|
|
|
|
find_package(PkgConfig REQUIRED)
|
2015-10-05 19:57:52 +00:00
|
|
|
set(USE_MINI_EVENT 1)
|
2015-04-04 21:56:12 +00:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
set(RETSIGTYPE void)
|
|
|
|
|
2017-10-10 13:05:28 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "(SunOS|Solaris)")
|
|
|
|
add_definitions(-D_XOPEN_SOURCE=600)
|
|
|
|
else()
|
2015-04-04 21:56:12 +00:00
|
|
|
add_definitions(-D_GNU_SOURCE)
|
2017-10-10 13:05:28 +00:00
|
|
|
endif()
|
|
|
|
add_definitions(-std=c99)
|
2018-01-14 18:49:10 +00:00
|
|
|
add_definitions(-fPIC)
|
2015-04-04 21:56:12 +00:00
|
|
|
|
|
|
|
option(USE_ECDSA "Use ECDSA algorithms" ON)
|
|
|
|
option(USE_SHA2 "Enable SHA2 support" ON)
|
2017-12-23 16:09:56 +00:00
|
|
|
option(USE_SHA1 "Enable SHA1 support" ON)
|
2015-04-04 21:56:12 +00:00
|
|
|
set(ENABLE_DNSTAP 0)
|
|
|
|
set(HAVE_SSL 1)
|
|
|
|
if (CMAKE_USE_PTHREADS_INIT AND NOT CMAKE_USE_WIN32_THREADS_INIT)
|
|
|
|
set(HAVE_PTHREAD 1)
|
|
|
|
else ()
|
|
|
|
set(HAVE_PTHREAD 0)
|
|
|
|
endif ()
|
|
|
|
if (CMAKE_USE_WIN32_THREADS_INIT)
|
|
|
|
set(HAVE_WINDOWS_THREADS 1)
|
|
|
|
else ()
|
|
|
|
set(HAVE_WINDOWS_THREADS 0)
|
|
|
|
endif ()
|
2017-10-26 22:15:18 +00:00
|
|
|
|
|
|
|
# determine if we have libressl
|
|
|
|
check_symbol_exists(LIBRESSL_VERSION_TEXT "openssl/opensslv.h" HAVE_LIBRESSL)
|
|
|
|
# check if we have found HAVE_DECL_REALLOCARRAY already, so we can safely undefine and redefine it with value 1
|
|
|
|
if (HAVE_LIBRESSL AND HAVE_DECL_REALLOCARRAY)
|
|
|
|
unset(HAVE_DECL_REALLOCARRAY CACHE)
|
|
|
|
add_definitions(-DHAVE_DECL_REALLOCARRAY=1)
|
|
|
|
endif ()
|
|
|
|
|
2015-04-04 21:56:12 +00:00
|
|
|
configure_file(
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/config.h")
|
|
|
|
configure_file(
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/dnstap/dnstap_config.h.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/dnstap/dnstap_config.h")
|
|
|
|
|
|
|
|
set(common_src
|
|
|
|
services/cache/dns.c
|
|
|
|
services/cache/infra.c
|
|
|
|
services/cache/rrset.c
|
|
|
|
util/data/dname.c
|
|
|
|
util/data/msgencode.c
|
|
|
|
util/data/msgparse.c
|
|
|
|
util/data/msgreply.c
|
|
|
|
util/data/packed_rrset.c
|
|
|
|
iterator/iterator.c
|
|
|
|
iterator/iter_delegpt.c
|
|
|
|
iterator/iter_donotq.c
|
|
|
|
iterator/iter_fwd.c
|
|
|
|
iterator/iter_hints.c
|
|
|
|
iterator/iter_priv.c
|
|
|
|
iterator/iter_resptype.c
|
|
|
|
iterator/iter_scrub.c
|
|
|
|
iterator/iter_utils.c
|
2017-06-16 10:16:05 +00:00
|
|
|
respip/respip.c
|
2015-04-04 21:56:12 +00:00
|
|
|
services/listen_dnsport.c
|
|
|
|
services/localzone.c
|
|
|
|
services/mesh.c
|
|
|
|
services/modstack.c
|
|
|
|
services/outbound_list.c
|
|
|
|
services/outside_network.c
|
2017-06-16 10:16:05 +00:00
|
|
|
services/view.c
|
2015-04-04 21:56:12 +00:00
|
|
|
util/alloc.c
|
2017-06-16 10:16:05 +00:00
|
|
|
util/as112.c
|
2015-04-04 21:56:12 +00:00
|
|
|
util/config_file.c
|
|
|
|
util/configlexer.c
|
|
|
|
util/configparser.c
|
|
|
|
util/fptr_wlist.c
|
|
|
|
util/locks.c
|
|
|
|
util/log.c
|
|
|
|
util/mini_event.c
|
|
|
|
util/module.c
|
|
|
|
util/netevent.c
|
|
|
|
util/net_help.c
|
|
|
|
util/random.c
|
|
|
|
util/rbtree.c
|
|
|
|
util/regional.c
|
|
|
|
util/rtt.c
|
|
|
|
util/storage/dnstree.c
|
|
|
|
util/storage/lookup3.c
|
|
|
|
util/storage/lruhash.c
|
|
|
|
util/storage/slabhash.c
|
|
|
|
util/timehist.c
|
|
|
|
util/tube.c
|
2017-06-16 10:16:05 +00:00
|
|
|
util/ub_event.c
|
2015-04-04 21:56:12 +00:00
|
|
|
util/winsock_event.c
|
|
|
|
validator/autotrust.c
|
|
|
|
validator/val_anchor.c
|
|
|
|
validator/validator.c
|
|
|
|
validator/val_kcache.c
|
|
|
|
validator/val_kentry.c
|
|
|
|
validator/val_neg.c
|
|
|
|
validator/val_nsec3.c
|
|
|
|
validator/val_nsec.c
|
|
|
|
validator/val_secalgo.c
|
|
|
|
validator/val_sigcrypt.c
|
|
|
|
validator/val_utils.c
|
|
|
|
dns64/dns64.c
|
|
|
|
|
|
|
|
#$(CHECKLOCK_SRC)
|
|
|
|
testcode/checklocks.c)
|
|
|
|
|
|
|
|
set(compat_src)
|
|
|
|
|
2017-06-16 10:16:05 +00:00
|
|
|
foreach (symbol IN ITEMS ctime_r gmtime_r inet_aton inet_ntop inet_pton isblank malloc memmove snprintf strsep strlcat strlcpy strptime explicit_bzero arc4random arc4random_uniform reallocarray)
|
2015-04-04 21:56:12 +00:00
|
|
|
string(TOUPPER "${symbol}" upper_sym)
|
|
|
|
if (NOT HAVE_${upper_sym})
|
|
|
|
list(APPEND compat_src
|
|
|
|
compat/${symbol}.c)
|
|
|
|
endif ()
|
|
|
|
endforeach ()
|
|
|
|
|
|
|
|
if (NOT HAVE_ARC4RANDOM)
|
|
|
|
list(APPEND compat_src
|
|
|
|
compat/arc4_lock.c)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
list(APPEND compat_src
|
|
|
|
compat/getentropy_linux.c)
|
|
|
|
elseif (APPLE)
|
|
|
|
list(APPEND compat_src
|
|
|
|
compat/getentropy_osx.c)
|
|
|
|
#elseif (SunOS)
|
|
|
|
# list(APPEND compat_src
|
|
|
|
# compat/getentropy_solaris.c)
|
|
|
|
elseif (WIN32)
|
|
|
|
list(APPEND compat_src
|
|
|
|
compat/getentropy_win.c)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (NOT HAVE_GETADDRINFO)
|
|
|
|
list(APPEND compat_src
|
|
|
|
compat/fake-rfc2553.c)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
set(sldns_src
|
2015-04-04 22:09:06 +00:00
|
|
|
sldns/keyraw.c
|
|
|
|
sldns/sbuffer.c
|
|
|
|
sldns/wire2str.c
|
|
|
|
sldns/parse.c
|
|
|
|
sldns/parseutil.c
|
|
|
|
sldns/rrdef.c
|
|
|
|
sldns/str2wire.c)
|
2015-04-04 21:56:12 +00:00
|
|
|
|
|
|
|
set(libunbound_src
|
|
|
|
libunbound/context.c
|
|
|
|
libunbound/libunbound.c
|
|
|
|
libunbound/libworker.c)
|
|
|
|
|
|
|
|
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
|
|
|
|
include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR})
|
|
|
|
add_library(unbound
|
|
|
|
${common_src}
|
|
|
|
${sldns_src}
|
|
|
|
${compat_src}
|
|
|
|
${libunbound_src})
|
|
|
|
target_link_libraries(unbound
|
2016-09-17 17:59:29 +00:00
|
|
|
PRIVATE
|
2015-04-04 21:56:12 +00:00
|
|
|
${OPENSSL_LIBRARIES}
|
|
|
|
${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
target_link_libraries(unbound
|
2016-09-17 17:59:29 +00:00
|
|
|
PRIVATE
|
2015-04-04 21:56:12 +00:00
|
|
|
iphlpapi
|
|
|
|
ws2_32)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (MINGW)
|
|
|
|
# There is no variable for this (probably due to the fact that the pthread
|
|
|
|
# library is implicit with a link in msys).
|
|
|
|
find_library(win32pthread
|
|
|
|
NAMES libwinpthread-1.dll)
|
|
|
|
foreach (input IN LISTS win32pthread OPENSSL_LIBRARIES)
|
|
|
|
# Copy shared libraries into the build tree so that no PATH manipulation is
|
|
|
|
# necessary.
|
|
|
|
get_filename_component(name "${input}" NAME)
|
|
|
|
configure_file(
|
|
|
|
"${input}"
|
|
|
|
"${CMAKE_BINARY_DIR}/bin/${name}"
|
|
|
|
COPYONLY)
|
|
|
|
endforeach ()
|
|
|
|
endif ()
|
2016-09-03 10:32:06 +00:00
|
|
|
|
|
|
|
|
2016-09-03 12:11:26 +00:00
|
|
|
if (INSTALL_VENDORED_LIBUNBOUND)
|
2017-04-02 10:19:25 +00:00
|
|
|
if(IOS)
|
|
|
|
set(lib_folder lib-${ARCH})
|
|
|
|
else()
|
|
|
|
set(lib_folder lib)
|
|
|
|
endif()
|
2016-09-03 10:32:06 +00:00
|
|
|
install(TARGETS unbound
|
2017-04-02 10:19:25 +00:00
|
|
|
ARCHIVE DESTINATION ${lib_folder})
|
2017-06-16 10:16:05 +00:00
|
|
|
endif()
|