Skip to content

Commit ca362f0

Browse files
committed
update to 2.9.2
1 parent 3b1be69 commit ca362f0

File tree

1,053 files changed

+115522
-21987
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,053 files changed

+115522
-21987
lines changed

CMakeLists.txt

+67-47
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
cmake_minimum_required (VERSION 2.8.8)
1+
cmake_minimum_required (VERSION 3.0)
22
include(CheckFunctionExists)
3+
include(CheckSymbolExists)
34
include(CheckLibraryExists)
45
include(CheckIncludeFiles)
56
include(CheckTypeSize)
@@ -8,7 +9,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" ${CMAKE_MODULE_PATH})
89
include(cmake_export_symbol)
910
include(GNUInstallDirs)
1011

11-
project (LibreSSL C)
12+
project (LibreSSL C ASM)
1213

1314
enable_testing()
1415

@@ -28,10 +29,11 @@ string(REPLACE ":" "." TLS_VERSION ${TLS_VERSION})
2829
string(REGEX REPLACE "\\..*" "" TLS_MAJOR_VERSION ${TLS_VERSION})
2930

3031
option(LIBRESSL_SKIP_INSTALL "Skip installation" ${LIBRESSL_SKIP_INSTALL})
32+
option(LIBRESSL_APPS "Build apps" ON)
33+
option(LIBRESSL_TESTS "Build tests" ON)
3134
option(ENABLE_ASM "Enable assembly" ON)
3235
option(ENABLE_EXTRATESTS "Enable extra tests that may be unreliable on some platforms" OFF)
3336
option(ENABLE_NC "Enable installing TLS-enabled nc(1)" OFF)
34-
option(ENABLE_VSTEST "Enable test on Visual Studio" OFF)
3537
set(OPENSSLDIR ${OPENSSLDIR} CACHE PATH "Set the default openssl directory" FORCE)
3638

3739
if(NOT LIBRESSL_SKIP_INSTALL)
@@ -47,39 +49,45 @@ endif()
4749

4850
if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
4951
add_definitions(-DHAVE_ATTRIBUTE__BOUNDED__)
52+
add_definitions(-DHAVE_ATTRIBUTE__DEAD__)
5053
endif()
5154

5255
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
5356
add_definitions(-D_DEFAULT_SOURCE)
5457
add_definitions(-D_BSD_SOURCE)
5558
add_definitions(-D_POSIX_SOURCE)
5659
add_definitions(-D_GNU_SOURCE)
60+
set(PLATFORM_LIBS ${PLATFORM_LIBS} pthread)
5761
endif()
5862

59-
if(CMAKE_SYSTEM_NAME MATCHES "MINGW")
63+
if(WIN32 OR (CMAKE_SYSTEM_NAME MATCHES "MINGW"))
6064
set(BUILD_NC false)
65+
add_definitions(-D_GNU_SOURCE)
66+
add_definitions(-D_POSIX)
67+
add_definitions(-D_POSIX_SOURCE)
68+
add_definitions(-D__USE_MINGW_ANSI_STDIO)
6169
endif()
6270

63-
if(WIN32)
64-
set(BUILD_NC false)
65-
endif()
71+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -Wall")
6672

6773
if(CMAKE_SYSTEM_NAME MATCHES "HP-UX")
6874
if(CMAKE_C_COMPILER MATCHES "gcc")
69-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=gnu99 -fno-strict-aliasing")
75+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -fno-strict-aliasing")
7076
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mlp64")
7177
else()
72-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O2 +DD64 +Otype_safety=off")
78+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} +DD64 +Otype_safety=off")
7379
endif()
7480
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=600 -D__STRICT_ALIGNMENT")
81+
set(PLATFORM_LIBS ${PLATFORM_LIBS} pthread)
7582
endif()
7683

7784
if(CMAKE_SYSTEM_NAME MATCHES "SunOS")
78-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=gnu99 -fno-strict-aliasing")
85+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -fno-strict-aliasing")
7986
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__EXTENSIONS__")
8087
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=600")
8188
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBSD_COMP")
82-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpic -m64")
89+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpic")
90+
set(PLATFORM_LIBS ${PLATFORM_LIBS} nsl socket)
8391
endif()
8492

8593
add_definitions(-DLIBRESSL_INTERNAL)
@@ -98,8 +106,9 @@ if(WIN32)
98106
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
99107
add_definitions(-D_CRT_DEPRECATED_NO_WARNINGS)
100108
add_definitions(-D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS)
101-
add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0501)
109+
add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600)
102110
add_definitions(-DCPPFLAGS -DOPENSSL_NO_SPEED -DNO_SYSLOG -DNO_CRYPT)
111+
set(PLATFORM_LIBS ${PLATFORM_LIBS} ws2_32)
103112
endif()
104113

105114
if(MSVC)
@@ -154,11 +163,6 @@ if(HAVE_ASPRINTF)
154163
add_definitions(-DHAVE_ASPRINTF)
155164
endif()
156165

157-
check_function_exists(inet_pton HAVE_INET_PTON)
158-
if(HAVE_INET_PTON)
159-
add_definitions(-DHAVE_INET_PTON)
160-
endif()
161-
162166
check_function_exists(reallocarray HAVE_REALLOCARRAY)
163167
if(HAVE_REALLOCARRAY)
164168
add_definitions(-DHAVE_REALLOCARRAY)
@@ -229,11 +233,31 @@ if(HAVE_GETENTROPY)
229233
add_definitions(-DHAVE_GETENTROPY)
230234
endif()
231235

232-
check_function_exists(getpagesize HAVE_GETPAGESIZE)
236+
check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE)
233237
if(HAVE_GETPAGESIZE)
234238
add_definitions(-DHAVE_GETPAGESIZE)
235239
endif()
236240

241+
check_function_exists(getprogname HAVE_GETPROGNAME)
242+
if(HAVE_GETPROGNAME)
243+
add_definitions(-DHAVE_GETPROGNAME)
244+
endif()
245+
246+
check_function_exists(syslog_r HAVE_SYSLOG_R)
247+
if(HAVE_SYSLOG_R)
248+
add_definitions(-DHAVE_SYSLOG_R)
249+
endif()
250+
251+
check_function_exists(syslog HAVE_SYSLOG)
252+
if(HAVE_SYSLOG)
253+
add_definitions(-DHAVE_SYSLOG)
254+
endif()
255+
256+
check_symbol_exists(timespecsub sys/time.h HAVE_TIMESPECSUB)
257+
if(HAVE_TIMESPECSUB)
258+
add_definitions(-DHAVE_TIMESPECSUB)
259+
endif()
260+
237261
check_function_exists(timingsafe_bcmp HAVE_TIMINGSAFE_BCMP)
238262
if(HAVE_TIMINGSAFE_BCMP)
239263
add_definitions(-DHAVE_TIMINGSAFE_BCMP)
@@ -258,46 +282,36 @@ if(ENABLE_ASM)
258282
if("${CMAKE_C_COMPILER_ABI}" STREQUAL "ELF")
259283
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(x86_64|amd64)")
260284
set(HOST_ASM_ELF_X86_64 true)
285+
elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm")
286+
set(HOST_ASM_ELF_ARMV4 true)
261287
elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i386")
262288
set(HOST_ASM_ELF_X86_64 true)
263289
endif()
264290
elseif(APPLE AND "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
265291
set(HOST_ASM_MACOSX_X86_64 true)
292+
elseif(MSVC AND "${CMAKE_GENERATOR}" MATCHES "Win64" AND FALSE)
293+
# XXX Disabled for now, CMake's MASM support seems to either never
294+
# build supply ASM or build it with the C compiler in a mode where it
295+
# does not parse correctly. It might be easier to get NASM support working.
296+
set(HOST_ASM_MASM_X86_64 true)
297+
ENABLE_LANGUAGE(ASM_MASM)
298+
elseif(CMAKE_SYSTEM_NAME MATCHES "MINGW" AND "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
299+
set(HOST_ASM_MINGW64_X86_64 true)
266300
endif()
267301
endif()
268302

269-
if(NOT (CMAKE_SYSTEM_NAME MATCHES "(Darwin|CYGWIN)"))
270-
set(BUILD_SHARED true)
271-
endif()
272-
273-
# USE_SHARED builds applications (e.g. openssl) using shared LibreSSL.
274-
# By default, applications use LibreSSL static library to avoid dependencies.
275-
# USE_SHARED isn't set by default; use -DUSE_SHARED=ON with CMake to enable.
276-
# Can be helpful for debugging; don't use for public releases.
277-
if(NOT BUILD_SHARED)
278-
set(USE_SHARED off)
279-
endif()
280-
281-
if(USE_SHARED)
282-
set(OPENSSL_LIBS tls-shared ssl-shared crypto-shared)
283-
else()
284-
set(OPENSSL_LIBS tls ssl crypto)
285-
endif()
286-
287-
if(CMAKE_HOST_WIN32)
288-
set(OPENSSL_LIBS ${OPENSSL_LIBS} ws2_32)
289-
endif()
290303
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
304+
# Check if we need -lrt to get clock_gettime on Linux
291305
check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
292306
if (HAVE_CLOCK_GETTIME)
293-
set(OPENSSL_LIBS ${OPENSSL_LIBS} rt)
307+
set(PLATFORM_LIBS ${PLATFORM_LIBS} rt)
294308
endif()
309+
else()
310+
# Otherwise, simply check if it exists
311+
check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
295312
endif()
296-
if(CMAKE_SYSTEM_NAME MATCHES "HP-UX")
297-
set(OPENSSL_LIBS ${OPENSSL_LIBS} pthread)
298-
endif()
299-
if(CMAKE_SYSTEM_NAME MATCHES "SunOS")
300-
set(OPENSSL_LIBS ${OPENSSL_LIBS} nsl socket)
313+
if(HAVE_CLOCK_GETTIME)
314+
add_definitions(-DHAVE_CLOCK_GETTIME)
301315
endif()
302316

303317
check_type_size(time_t SIZEOF_TIME_T)
@@ -309,15 +323,20 @@ if(SIZEOF_TIME_T STREQUAL "4")
309323
endif()
310324
add_definitions(-DSIZEOF_TIME_T=${SIZEOF_TIME_T})
311325

326+
set(OPENSSL_LIBS tls ssl crypto ${PLATFORM_LIBS})
327+
312328
add_subdirectory(crypto)
313329
add_subdirectory(ssl)
314-
add_subdirectory(apps)
330+
if(LIBRESSL_APPS)
331+
add_subdirectory(apps)
332+
endif()
315333
add_subdirectory(tls)
316334
add_subdirectory(include)
317335
if(NOT MSVC)
318336
add_subdirectory(man)
319337
endif()
320-
if(NOT MSVC OR ENABLE_VSTEST)
338+
# Tests require the openssl executable and are unavailable when building shared libraries
339+
if(LIBRESSL_APPS AND LIBRESSL_TESTS)
321340
add_subdirectory(tests)
322341
endif()
323342

@@ -327,6 +346,7 @@ if(NOT MSVC)
327346
set(exec_prefix \${prefix})
328347
set(libdir \${exec_prefix}/${CMAKE_INSTALL_LIBDIR})
329348
set(includedir \${prefix}/include)
349+
string(REGEX REPLACE ";" " -l" PLATFORM_LDADD ";${PLATFORM_LIBS}")
330350
file(STRINGS "VERSION" VERSION LIMIT_COUNT 1)
331351
file(GLOB OPENSSL_PKGCONFIGS "*.pc.in")
332352
foreach(file ${OPENSSL_PKGCONFIGS})

0 commit comments

Comments
 (0)