Skip to content

Commit

Permalink
fix(makefile): fix make files for OpenSSL
Browse files Browse the repository at this point in the history
Fix paths to the custom OpenSSL location.
  • Loading branch information
parfeon committed Dec 20, 2024
1 parent 1f97a86 commit 9ca0319
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 42 deletions.
2 changes: 1 addition & 1 deletion make/common/source_files.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ CORE_SOURCE_FILES = \
../core/pubnub_timers.c \
../core/pubnub_url_encode.c \
../lib/base64/pbbase64.c \
../lib/md5/md5.c \
../lib/pb_strncasecmp.c \
../lib/pb_strnlen_s.c \
../lib/sockets/pbpal_handle_socket_error.c \
Expand Down Expand Up @@ -77,6 +76,7 @@ CORE_CPP_SOURCE_FILES_WINDOWS = \
# `CORE_SOURCE_FILES` extension without OpenSSL support used for all
# platforms.
CORE_NON_OPENSSL_SOURCE_FILES = \
../lib/md5/md5.c \
../lib/sockets/pbpal_sockets.c

# `CORE_NON_OPENSSL_SOURCE_FILES` extension for POSIX build.
Expand Down
48 changes: 27 additions & 21 deletions make/windows_compiler_linker_flags.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
!if $(WITH_GCC)
# -std=c11 - enables `%z` and `%ll` in printf() - in general, we're "low"
# on C11 features
NMAKE_FLAGS = -std=c11 -W2
NMAKE_FLAGS = -std=c11 -W2l
!else
# /MP - uses one compiler (`cl`) process for each input file, enabling
# faster build
Expand All @@ -19,23 +19,23 @@ NMAKE_FLAGS = /W2 /MP

!if $(ASAN)
!if $(WITH_GCC)
# -g - enables debugging but with price of larger binary
# -fsanitize=address - run address sanityzer
NMAKE_FLAGS = $(NMAKE_FLAGS) -g -fsanitize=address
# -g - enables debugging but with price of larger binary
# -fsanitize=address - run address sanityzer
NMAKE_FLAGS = $(NMAKE_FLAGS) -g -fsanitize=address
!else
# /Zi - enables debugging, remove to get a smaller .exe and no .pdb
# /analyze - To run the static analyzer (not compatible w/clang-cl)
NMAKE_FLAGS = $(NMAKE_FLAGS) /Zi /analyze
# /Zi - enables debugging, remove to get a smaller .exe and no .pdb
# /analyze - To run the static analyzer (not compatible w/clang-cl)
NMAKE_FLAGS = $(NMAKE_FLAGS) /Zi /analyze
!endif
!else
NMAKE_FLAGS = $(NMAKE_FLAGS) /wd4005
!endif

!if $(WITH_CPP)
!if $(WITH_GCC)
NMAKE_FLAGS = $(NMAKE_FLAGS) -x c++
NMAKE_FLAGS = $(NMAKE_FLAGS) -x c++
!else
NMAKE_FLAGS = $(NMAKE_FLAGS) /TP
NMAKE_FLAGS = $(NMAKE_FLAGS) /TP
!endif
!endif
COMPILER_FLAGS = $(NMAKE_FLAGS) $(USER_C_FLAGS)
Expand All @@ -54,20 +54,26 @@ LDLIBS = ws2_32.lib IPHlpAPI.lib rpcrt4.lib
# TODO: Add support of OpenSSL when built with GCC if possible.
!if "$(OPENSSL)" == "1" && "$(WITH_GCC)" == "0"
OPENSSL_LIBS =
OPENSSL_FOUND = 0
!if "$(OPENSSL_ROOT_DIR)" != "" && "$(CUSTOM_OPENSSL_LIB_DIR)" != ""
!if EXISTS($(OPENSSL_ROOT_DIR)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR)$(PATH_SEP)libssl.lib)
OPENSSL_LIBS = \
$(OPENSSL_ROOT_DIR)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR)$(PATH_SEP)libssl.lib \
$(OPENSSL_ROOT_DIR)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR)$(PATH_SEP)libcrypto.lib
!elseif EXISTS($(OPENSSL_ROOT_DIR)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR)$(PATH_SEP)ssleay32.lib)
OPENSSL_LIBS = \
$(OPENSSL_ROOT_DIR)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR)$(PATH_SEP)ssleay32.lib \
$(OPENSSL_ROOT_DIR)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR)$(PATH_SEP)libeay32.lib
!endif
OPENSSL_ROOT_DIR_ = $(subst /,$(PATH_SEP),$(OPENSSL_ROOT_DIR))
CUSTOM_OPENSSL_LIB_DIR_ = $(subst /,$(PATH_SEP),$(CUSTOM_OPENSSL_LIB_DIR))

!if EXISTS($(OPENSSL_ROOT_DIR_)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR_)$(PATH_SEP)libssl.lib)
OPENSSL_FOUND = 1
OPENSSL_LIBS = \
"$(OPENSSL_ROOT_DIR_)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR_)$(PATH_SEP)libssl.lib" \
"$(OPENSSL_ROOT_DIR_)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR_)$(PATH_SEP)libcrypto.lib"
!elseif EXISTS($(OPENSSL_ROOT_DIR_)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR_)$(PATH_SEP)ssleay32.lib)
OPENSSL_FOUND = 1
OPENSSL_LIBS = \
"$(OPENSSL_ROOT_DIR_)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR_)$(PATH_SEP)ssleay32.lib" \
"$(OPENSSL_ROOT_DIR_)$(PATH_SEP)$(CUSTOM_OPENSSL_LIB_DIR_)$(PATH_SEP)libeay32.lib"
!endif
!endif
!if "$(OPENSSL_LIBS)" == ""
!error "Cannot find OpenSSL libraries, OPENSSLPATH=$(OPENSSL_ROOT_DIR)"
!if $(OPENSSL_FOUND) == 0
!error Cannot find OpenSSL libraries, OPENSSLPATH="$(subst /,$(PATH_SEP),$(OPENSSL_ROOT_DIR))"
!else
LDLIBS = $(LDLIBS) $(OPENSSL_LIBS)
LDLIBS = $(strip $(LDLIBS)) $(strip $(OPENSSL_LIBS))
!endif
!endif
8 changes: 4 additions & 4 deletions make/windows_cpp_targets.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ COMPILER_FLAGS = \
$(OPTION_PREFIX)D _WINSOCK_DEPRECATED_NO_WARNINGS

!if $(OPENSSL)
COMPILER_FLAGS = \
$(COMPILER_FLAGS) \
$(OPTION_PREFIX)D PUBNUB_USE_WIN_SSPI=1
COMPILER_FLAGS = \
$(COMPILER_FLAGS) \
$(OPTION_PREFIX)D PUBNUB_USE_WIN_SSPI=1
!endif

!include <../make/common/targets_cpp_app.mk>

!if $(OPENSSL)
!include <../make/common/targets_cpp_app_openssl.mk>
!include <../make/common/targets_cpp_app_openssl.mk>
!endif
28 changes: 15 additions & 13 deletions make/windows_preprocessing.mk
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ COMPILER = $(DEFAULT_COMPILER_TYPE)
!if $(WITH_CPP)
COMPILER = $(CXX)
!ifndef $(USE_EXTERN_API)
USE_EXTERN_API = $(DEFAULT_USE_EXTERN_API)
USE_EXTERN_API = $(DEFAULT_USE_EXTERN_API)
!endif
!ifndef $(USE_CPP11)
USE_CPP11 = $(DEFAULT_USE_CPP11)
USE_CPP11 = $(DEFAULT_USE_CPP11)
!endif
!endif
!if "$(COMPILER)" == ""
Expand Down Expand Up @@ -132,7 +132,7 @@ USE_CRYPTO_API = $(DEFAULT_USE_CRYPTO_API)
!endif
!if $(USE_CRYPTO_API)
!if !$(OPENSSL)
!error "You can't use Crypto API without OpenSSL!"
!error "You can't use Crypto API without OpenSSL!"
!endif
!endif

Expand All @@ -156,7 +156,7 @@ USE_GRANT_TOKEN = $(DEFAULT_USE_GRANT_TOKEN)
!endif
!if $(USE_GRANT_TOKEN) == 1
!if $(OPENSSL) == 0
!error "You can't use Grant Token API without OpenSSL!"
!error "You can't use Grant Token API without OpenSSL!"
!endif
!endif

Expand Down Expand Up @@ -202,7 +202,7 @@ USE_REVOKE_TOKEN = $(DEFAULT_USE_REVOKE_TOKEN)
!endif
!if $(USE_REVOKE_TOKEN)
!if !$(OPENSSL)
!error "You can't use Revoke Token API without OpenSSL!"
!error "You can't use Revoke Token API without OpenSSL!"
!endif
!endif

Expand Down Expand Up @@ -257,7 +257,7 @@ OUT_FLAG = -o

# Compiler's flag to enforce C++11 standard.
!if "$(WITH_CPP)" == "1" && "$(USE_CPP11)" == "1"
CPP11_STANDARD_FLAG = -std=c++11
CPP11_STANDARD_FLAG = -std=c++11
!endif
!else
OBJ_EXT = .obj
Expand All @@ -284,11 +284,11 @@ OUT_FLAG = /Fe

# Compiler's flag to enforce C++11 standard.
!if $(WITH_CPP)
# Linker flag.
LINK_FLAG = /link
!if $(USE_CPP11)
CPP11_STANDARD_FLAG = /std:c++11
!endif
# Linker flag.
LINK_FLAG = /link
!if $(USE_CPP11)
CPP11_STANDARD_FLAG = /std:c++11
!endif
!endif
!endif

Expand Down Expand Up @@ -318,8 +318,10 @@ DEFINE_RANDOM_IV = $(OPTION_PREFIX)D PUBNUB_RAND_INIT_VECTOR=$(USE_LEGACY_CRYPTO
INCLUDES_OPENSSL = $(OPTION_PREFIX)I..$(PATH_SEP)openssl

!if "$(OPENSSL_ROOT_DIR)" != "" && "$(CUSTOM_OPENSSL_INCLUDE_DIR)" != ""
INCLUDES_OPENSSL = $(INCLUDES_OPENSSL) \
$(OPTION_PREFIX)I$(OPENSSL_ROOT_DIR)$(PATH_SEP)$(CUSTOM_OPENSSL_INCLUDE_DIR)
OPENSSL_ROOT_DIR_ = $(subst /,$(PATH_SEP),$(OPENSSL_ROOT_DIR))
CUSTOM_OPENSSL_INCLUDE_DIR_ = $(subst /,$(PATH_SEP),$(CUSTOM_OPENSSL_INCLUDE_DIR))
INCLUDES_OPENSSL = $(INCLUDES_OPENSSL) \
$(OPTION_PREFIX)I"$(OPENSSL_ROOT_DIR_)$(PATH_SEP)$(CUSTOM_OPENSSL_INCLUDE_DIR_)"
!endif
!else
INCLUDES_PLATFORM = $(INCLUDES_PLATFORM) $(OPTION_PREFIX)I..$(PATH_SEP)windows
Expand Down
6 changes: 3 additions & 3 deletions openssl/windows.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
# Making OpenSSL version of the PubNub SDK.
OPENSSL = 1
!ifndef USE_CRYPTO_API
USE_CRYPTO_API = 0
USE_CRYPTO_API = 0
!endif
!ifndef USE_GRANT_TOKEN
USE_GRANT_TOKEN = 1
USE_GRANT_TOKEN = 1
!endif
!ifndef USE_REVOKE_TOKEN
USE_REVOKE_TOKEN = 1
USE_REVOKE_TOKEN = 1
!endif

!include <../make/windows_preprocessing.mk>
Expand Down

0 comments on commit 9ca0319

Please sign in to comment.