From f80a029f28213487f92155550bf666e5d43fce7d Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 4 Nov 2021 15:18:00 +0100 Subject: [PATCH] Don't build dlopen when building for Windows Windows doesn't have dlopen, not even Linux emulation environments such as MinGW. Signed-off-by: Gilles Peskine --- programs/Makefile | 16 ++++++++++++++-- programs/test/CMakeLists.txt | 3 ++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/programs/Makefile b/programs/Makefile index 84399f9be..1ebf8d241 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -61,6 +61,18 @@ else PYTHON ?= $(shell if type python3 >/dev/null 2>/dev/null; then echo python3; else echo python; fi) endif +# Only build the dlopen test in shared library builds, and not when building +# for Windows. +ifdef BUILD_DLOPEN +# Don't override the value +else ifdef WINDOWS_BUILD +BUILD_DLOPEN = +else ifdef SHARED +BUILD_DLOPEN = y +else +BUILD_DLOPEN = +endif + ## The following assignment is the list of base names of applications that ## will be built on Windows. Extra Linux/Unix/POSIX-only applications can ## be declared by appending with `APPS += ...` afterwards. @@ -124,7 +136,7 @@ ifdef PTHREAD APPS += ssl/ssl_pthread_server endif -ifdef SHARED +ifdef BUILD_DLOPEN APPS += test/dlopen endif @@ -354,7 +366,7 @@ test/cpp_dummy_build$(EXEXT): test/cpp_dummy_build.cpp $(DEP) echo " CXX test/cpp_dummy_build.cpp" $(CXX) $(LOCAL_CXXFLAGS) $(CXXFLAGS) test/cpp_dummy_build.cpp $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ -ifdef SHARED +ifdef BUILD_DLOPEN test/dlopen$(EXEXT): test/dlopen.c $(DEP) echo " CC test/dlopen.c" # Do not link any test objects (that would bring in a static dependency on diff --git a/programs/test/CMakeLists.txt b/programs/test/CMakeLists.txt index 3a8affbfa..1a79e974e 100644 --- a/programs/test/CMakeLists.txt +++ b/programs/test/CMakeLists.txt @@ -27,7 +27,8 @@ if(TEST_CPP) target_link_libraries(cpp_dummy_build ${mbedcrypto_target}) endif() -if(USE_SHARED_MBEDTLS_LIBRARY) +if(USE_SHARED_MBEDTLS_LIBRARY AND + NOT ${CMAKE_SYSTEM_NAME} MATCHES "[Ww][Ii][Nn]") add_executable(dlopen "dlopen.c") target_include_directories(dlopen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")