Skip to content

Commit

Permalink
fix *BSD / Solaris configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Fs <[email protected]>
  • Loading branch information
Fsu0413 committed Jan 20, 2024
1 parent bba5073 commit 2d23cfb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
20 changes: 16 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,6 @@ else()
set(OPENSSL_NO_DSO ON CACHE BOOL "build without DSO (automatically set, use OPENSSL_DSO if this is to be modified)" FORCE)
endif()

# TODO: uplink platforms (if not 386)
# cflags = -DOPENSSL_USE_APPLINK
# cpuid_obj += uplink.o uplink-x86.o

# list the original platform descriptions - How can this be so complicated?
# currently only supported platforms are listed - other platforms will be added when finished
if (WIN32)
Expand Down Expand Up @@ -605,6 +601,22 @@ elseif (CMAKE_SYSTEM_NAME MATCHES "BSD")
set(OPENSSL_BUILD_PLATFORM "BSD-generic32")
endif()
endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "SunOS")
if (OPENSSL_TARGET_ARCH STREQUAL "x64")
if (CMAKE_C_COMPILER_ID MATCHES "GNU")
set(OPENSSL_BUILD_PLATFORM "solaris64-x86_64-gcc")
elseif (CMAKE_C_COMPILER_ID MATCHES "SunPro")
set(OPENSSL_BUILD_PLATFORM "solaris64-x86_64-cc")
endif()
elseif (OPENSSL_TARGET_ARCH STREQUAL "x86")
if (CMAKE_C_COMPILER_ID MATCHES "GNU")
set(OPENSSL_BUILD_PLATFORM "solaris-x86-gcc")
elseif (CMAKE_C_COMPILER_ID MATCHES "SunPro")
# set(OPENSSL_BUILD_PLATFORM "solaris-x86-cc")
message(FATAL_ERROR "OpenSSL no longer supports solaris-x86-cc target. "
"Search \"solaris-x86-cc\" in openssl/Configurations/10-main.conf to see what happens to OpenSSL.")
endif()
endif()
endif()

if (BUILD_TESTING)
Expand Down
32 changes: 26 additions & 6 deletions crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ else()
endif()

#define RC4_INT unsigned @OPENSSL_RC4_INT@
if ( WIN32 OR ( ANDROID AND ( ( OPENSSL_TARGET_ARCH STREQUAL "x86" ) OR ( OPENSSL_TARGET_ARCH STREQUAL "x64" ) ) ) OR APPLE )
if ( WIN32
OR ( ANDROID AND ( ( OPENSSL_TARGET_ARCH STREQUAL "x86" ) OR ( OPENSSL_TARGET_ARCH STREQUAL "x64" ) ) )
OR APPLE
OR ( CMAKE_SYSTEM_NAME MATCHES "BSD" )
OR ( CMAKE_SYSTEM_NAME MATCHES "SunOS" ) # TODO: Solaris on sparcv7 and sparcv9-64 have RC4_CHAR
)
set(OPENSSL_RC4_INT "int")
else()
set(OPENSSL_RC4_INT "char")
Expand All @@ -64,6 +69,7 @@ if ( ( ( CMAKE_SYSTEM_NAME MATCHES "BSD" ) AND ( OPENSSL_TARGET_ARCH STREQ
OR ( WIN32 AND ( OPENSSL_TARGET_ARCH STREQUAL "x86" ) )
OR ( ANDROID AND ( ( OPENSSL_TARGET_ARCH STREQUAL "x86" ) OR ( OPENSSL_TARGET_ARCH STREQUAL "arm32" ) ) )
OR ( CMAKE_SYSTEM_NAME MATCHES "[Ll]inux" AND ( ( OPENSSL_TARGET_ARCH STREQUAL "x86" ) OR ( OPENSSL_TARGET_ARCH STREQUAL "arm32" ) ) )
OR ( CMAKE_SYSTEM_NAME MATCHES "SunOS" AND ( OPENSSL_TARGET_ARCH STREQUAL "x86" ) ) # # TODO: Solaris on sparcv7 and sparcv9-64 have BN_LLONG
)
set(BN_LLONG YES)
else()
Expand Down Expand Up @@ -115,6 +121,7 @@ if (OPENSSL_DSO)
OR ANDROID
OR APPLE
OR ( CMAKE_SYSTEM_NAME MATCHES "[Ll]inux" )
OR ( CMAKE_SYSTEM_NAME MATCHES "SunOS" )
)
set(DSO_WIN32 OFF)
set(DSO_DLFCN ON)
Expand Down Expand Up @@ -156,7 +163,7 @@ if (OPENSSL_ASM OR OPENSSL_UPLINK)
set(OPENSSL_PERLASM_SCHEME "win32")
elseif (ANDROID)
set(OPENSSL_PERLASM_SCHEME "android")
elseif( CMAKE_SYSTEM_NAME MATCHES "BSD" OR ( CMAKE_SYSTEM_NAME MATCHES "[Ll]inux" ) )
elseif( CMAKE_SYSTEM_NAME MATCHES "BSD" OR ( CMAKE_SYSTEM_NAME MATCHES "[Ll]inux" ) OR ( CMAKE_SYSTEM_NAME MATCHES "SunOS" ) )
set(OPENSSL_PERLASM_SCHEME "elf")
endif()
elseif ( OPENSSL_TARGET_ARCH STREQUAL "x64" )
Expand All @@ -166,7 +173,7 @@ if (OPENSSL_ASM OR OPENSSL_UPLINK)
set(OPENSSL_PERLASM_SCHEME "mingw64")
elseif (MSVC)
set(OPENSSL_PERLASM_SCHEME "masm")
elseif ( ANDROID OR ( CMAKE_SYSTEM_NAME MATCHES "BSD" ) OR ( CMAKE_SYSTEM_NAME MATCHES "[Ll]inux" ) )
elseif ( ANDROID OR ( CMAKE_SYSTEM_NAME MATCHES "BSD" ) OR ( CMAKE_SYSTEM_NAME MATCHES "[Ll]inux" ) OR ( CMAKE_SYSTEM_NAME MATCHES "SunOS" ) )
set(OPENSSL_PERLASM_SCHEME "elf")
elseif ( APPLE AND NOT IOS )
set(OPENSSL_PERLASM_SCHEME "macosx")
Expand Down Expand Up @@ -224,10 +231,14 @@ macro (perlasm_generate_src OUT_ASMFILE SRC_PERLFILE)
set(${_CURRENTPARSING} ${${_CURRENTPARSING}} ${_ITEM})
endif()
endforeach()
if ( CMAKE_POSITION_INDEPENDENT_CODE AND NOT ( WIN32 OR CYGWIN ) AND OPENSSL_TARGET_ARCH STREQUAL "x86" )
if (CMAKE_POSITION_INDEPENDENT_CODE)
# PIC needs to be specified manually...???
# Only recoginzed when target is x86
set(FLAGS ${FLAGS} -fPIC)
if (CMAKE_SYSTEM_NAME MATCHES "SunOS" AND CMAKE_C_COMPILER_ID MATCHES "SunPro" )
set(FLAGS ${FLAGS} -KPIC)
elseif ( NOT ( WIN32 OR CYGWIN ) AND OPENSSL_TARGET_ARCH STREQUAL "x86" )
# Only recoginzed when target is x86
set(FLAGS ${FLAGS} -fPIC)
endif()
endif()
add_custom_command(
OUTPUT ${OUT_ASMFILE}
Expand Down Expand Up @@ -263,6 +274,9 @@ set(LIBCRYPTO_CFLAGS)
if (WIN32)
set(LIBCRYPTO_CFLAGS ${LIBCRYPTO_CFLAGS} "-DOPENSSL_SYS_WIN32" "-DWIN32_LEAN_AND_MEAN" "-D_WINSOCK_DEPRECATED_NO_WARNINGS" "-DUNICODE" "-D_UNICODE")
endif()
if (CMAKE_SYSTEM_NAME MATCHES "SunOS")
set(LIBCRYPTO_CFLAGS ${LIBCRYPTO_CFLAGS} "-DFILIO_H")
endif()
if (OPENSSL_SSE2)
set(LIBCRYPTO_CFLAGS ${LIBCRYPTO_CFLAGS} "-DOPENSSL_IA32_SSE2")
endif()
Expand Down Expand Up @@ -802,6 +816,12 @@ if (WIN32)
)
endif()

if (CMAKE_SYSTEM_NAME MATCHES "SunOS")
target_link_libraries(crypto
PUBLIC socket nsl
)
endif()

if (OPENSSL_DSO)
target_link_libraries(crypto
PUBLIC ${CMAKE_DL_LIBS}
Expand Down

0 comments on commit 2d23cfb

Please sign in to comment.