generate and include arch-specific headers for CMake builds

This commit is contained in:
Brent Cook 2023-02-21 00:25:04 -06:00
parent c3e1e50cb1
commit 8fc30eca61
3 changed files with 82 additions and 6 deletions

View File

@ -306,6 +306,32 @@ if(HAVE_NETINET_IP_H)
add_definitions(-DHAVE_NETINET_IP_H) add_definitions(-DHAVE_NETINET_IP_H)
endif() endif()
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(aarch64|arm64)")
set(HOST_AARCH64 true)
elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm")
set(HOST_ARM true)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS" AND "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i386")
set(HOST_X86_64 true)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "i386")
set(HOST_I386 true)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "mips64")
set(HOST_MIPS64 true)
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "mips")
set(HOST_MIPS true)
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "powerpc")
set(HOST_POWERPC true)
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "ppc64")
set(HOST_PPC64 true)
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "riscv64")
set(HOST_RISCV64 true)
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "sparc64")
set(HOST_SPARC64 true)
elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(x86_64|amd64)")
set(HOST_X86_64 true)
else()
set(ENABLE_ASM false)
endif()
if(ENABLE_ASM) if(ENABLE_ASM)
if("${CMAKE_C_COMPILER_ABI}" STREQUAL "ELF") if("${CMAKE_C_COMPILER_ABI}" STREQUAL "ELF")
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(x86_64|amd64)") if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(x86_64|amd64)")
@ -361,13 +387,13 @@ else()
set(LIBTLS_TEST_LIBS tls ${PLATFORM_LIBS}) set(LIBTLS_TEST_LIBS tls ${PLATFORM_LIBS})
endif() endif()
add_subdirectory(include)
add_subdirectory(crypto) add_subdirectory(crypto)
add_subdirectory(ssl) add_subdirectory(ssl)
if(LIBRESSL_APPS) if(LIBRESSL_APPS)
add_subdirectory(apps) add_subdirectory(apps)
endif() endif()
add_subdirectory(tls) add_subdirectory(tls)
add_subdirectory(include)
if(NOT MSVC) if(NOT MSVC)
add_subdirectory(man) add_subdirectory(man)
endif() endif()

View File

@ -47,6 +47,18 @@ if(HOST_ASM_ELF_X86_64)
sha/sha512-elf-x86_64.S sha/sha512-elf-x86_64.S
whrlpool/wp-elf-x86_64.S whrlpool/wp-elf-x86_64.S
cpuid-elf-x86_64.S cpuid-elf-x86_64.S
bn/arch/amd64/bignum_add.S
bn/arch/amd64/bignum_cmadd.S
bn/arch/amd64/bignum_cmul.S
bn/arch/amd64/bignum_mul.S
bn/arch/amd64/bignum_mul_4_8_alt.S
bn/arch/amd64/bignum_mul_8_16_alt.S
bn/arch/amd64/bignum_sqr.S
bn/arch/amd64/bignum_sqr_4_8_alt.S
bn/arch/amd64/bignum_sqr_8_16_alt.S
bn/arch/amd64/bignum_sub.S
bn/arch/amd64/bn_arch.c
) )
add_definitions(-DAES_ASM) add_definitions(-DAES_ASM)
add_definitions(-DBSAES_ASM) add_definitions(-DBSAES_ASM)
@ -331,16 +343,13 @@ set(
bio/bss_null.c bio/bss_null.c
bio/bss_sock.c bio/bss_sock.c
bn/bn_add.c bn/bn_add.c
bn/bn_asm.c
bn/bn_blind.c bn/bn_blind.c
bn/bn_bpsw.c bn/bn_bpsw.c
bn/bn_const.c bn/bn_const.c
bn/bn_ctx.c bn/bn_ctx.c
bn/bn_depr.c
bn/bn_div.c bn/bn_div.c
bn/bn_err.c bn/bn_err.c
bn/bn_exp.c bn/bn_exp.c
bn/bn_exp2.c
bn/bn_gcd.c bn/bn_gcd.c
bn/bn_gf2m.c bn/bn_gf2m.c
bn/bn_isqrt.c bn/bn_isqrt.c
@ -461,8 +470,6 @@ set(
dsa/dsa_ossl.c dsa/dsa_ossl.c
dsa/dsa_pmeth.c dsa/dsa_pmeth.c
dsa/dsa_prn.c dsa/dsa_prn.c
dsa/dsa_sign.c
dsa/dsa_vrf.c
dso/dso_dlfcn.c dso/dso_dlfcn.c
dso/dso_err.c dso/dso_err.c
dso/dso_lib.c dso/dso_lib.c
@ -1010,6 +1017,26 @@ target_include_directories(crypto_obj
PUBLIC PUBLIC
../include) ../include)
if(HOST_AARCH64)
target_include_directories(crypto_obj PRIVATE bn/arch/aarch64/)
elseif(HOST_ARM)
target_include_directories(crypto_obj PRIVATE bn/arch/arm/)
elseif(HOST_I386)
target_include_directories(crypto_obj PRIVATE bn/arch/i386/)
elseif(HOST_MIPS64)
target_include_directories(crypto_obj PRIVATE bn/arch/mips64)
elseif(HOST_POWERPC)
target_include_directories(crypto_obj PRIVATE bn/arch/powerpc)
elseif(HOST_POWERPC64)
target_include_directories(crypto_obj PRIVATE bn/arch/powerpc64)
elseif(HOST_RISCV64)
target_include_directories(crypto_obj PRIVATE bn/arch/riscv64)
elseif(HOST_SPARC64)
target_include_directories(crypto_obj PRIVATE bn/arch/sparc64)
elseif(HOST_X86_64)
target_include_directories(crypto_obj PRIVATE bn/arch/amd64)
endif()
add_library(crypto $<TARGET_OBJECTS:crypto_obj> empty.c) add_library(crypto $<TARGET_OBJECTS:crypto_obj> empty.c)
export_symbol(crypto ${CMAKE_CURRENT_BINARY_DIR}/crypto_p.sym) export_symbol(crypto ${CMAKE_CURRENT_BINARY_DIR}/crypto_p.sym)

View File

@ -6,3 +6,26 @@ if(ENABLE_LIBRESSL_INSTALL)
PATTERN "pqueue.h" EXCLUDE PATTERN "pqueue.h" EXCLUDE
PATTERN "Makefile*" EXCLUDE) PATTERN "Makefile*" EXCLUDE)
endif(ENABLE_LIBRESSL_INSTALL) endif(ENABLE_LIBRESSL_INSTALL)
file(READ openssl/opensslconf.h.in OPENSSLCONF)
file(WRITE openssl/opensslconf.h "${OPENSSLCONF}")
if(HOST_AARCH64)
file(READ arch/aarch64/opensslconf.h OPENSSLCONF)
elseif(HOST_ARM)
file(READ arch/arm/opensslconf.h OPENSSLCONF)
elseif(HOST_I386)
file(READ arch/i386/opensslconf.h OPENSSLCONF)
elseif(HOST_MIPS64)
file(READ arch/mips64/opensslconf.h OPENSSLCONF)
elseif(HOST_POWERPC)
file(READ arch/powerpc/opensslconf.h OPENSSLCONF)
elseif(HOST_POWERPC64)
file(READ arch/powerpc64/opensslconf.h OPENSSLCONF)
elseif(HOST_RISCV64)
file(READ arch/riscv64/opensslconf.h OPENSSLCONF)
elseif(HOST_SPARC64)
file(READ arch/sparc64/opensslconf.h OPENSSLCONF)
elseif(HOST_X86_64)
file(READ arch/amd64/opensslconf.h OPENSSLCONF)
endif()
file(APPEND openssl/opensslconf.h "${OPENSSLCONF}")