# $Id: Config.kmk 95261 2022-06-13 16:29:49Z vboxsync $ ## @file # OpenSSL kBuild Configuration file. # # # Copyright (C) 2006-2022 Oracle Corporation # # This file is part of VirtualBox Open Source Edition (OSE), as # available from http://www.virtualbox.org. This file is free software; # you can redistribute it and/or modify it under the terms of the GNU # General Public License (GPL) as published by the Free Software # Foundation, in version 2 as it comes in the "COPYING" file of the # VirtualBox OSE distribution. VirtualBox OSE is distributed in the # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. # # Include the top-level configure file. ifndef VBOX_ROOT_CONFIG_KMK_INCLUDED include $(PATH_ROOT)/Config.kmk endif # Figure out openssl perl asm style for the target VBOX_CRYPTO_ASM_SCHEME := portme if1of ($(KBUILD_TARGET), freebsd linux netbsd openbsd solaris) VBOX_CRYPTO_ASM_SCHEME := elf else ifeq ($(KBUILD_TARGET), darwin) VBOX_CRYPTO_ASM_SCHEME := macosx else ifeq ($(KBUILD_TARGET), win) VBOX_CRYPTO_ASM_SCHEME := nasm endif # Can't use relative paths when dealing with sub-makefiles. VBOX_PATH_OPENSSL := $(PATH_ROOT)/src/libs/openssl-3.0.3 VBOX_PATH_CRYPTO := $(VBOX_PATH_OPENSSL)/crypto VBOX_PATH_CRYPTO_GENASM := $(VBOX_PATH_CRYPTO)/genasm-$(VBOX_CRYPTO_ASM_SCHEME) VBOX_PATH_CRYPTO_AES := $(VBOX_PATH_CRYPTO)/aes VBOX_PATH_CRYPTO_BN := $(VBOX_PATH_CRYPTO)/bn VBOX_PATH_CRYPTO_CHACHA := $(VBOX_PATH_CRYPTO)/chacha VBOX_PATH_CRYPTO_EC := $(VBOX_PATH_CRYPTO)/ec VBOX_PATH_CRYPTO_MD5 := $(VBOX_PATH_CRYPTO)/md5 VBOX_PATH_CRYPTO_MODES := $(VBOX_PATH_CRYPTO)/modes VBOX_PATH_CRYPTO_POLY1305 := $(VBOX_PATH_CRYPTO)/poly1305 VBOX_PATH_CRYPTO_RC4 := $(VBOX_PATH_CRYPTO)/rc4 VBOX_PATH_CRYPTO_SHA := $(VBOX_PATH_CRYPTO)/sha VBOX_PATH_CRYPTO_DES := $(VBOX_PATH_CRYPTO)/des VBOX_PATH_CRYPTO_CAMELLIA := $(VBOX_PATH_CRYPTO)/camellia VBOX_INST_CRYPTO_HEADERS := obj/$(if-expr "$(CURSUBDIR)" == ".",,$(CURSUBDIR)/)crypto-3.0.3-headers/include/openssl/ VBOX_PATH_CRYPTO_HEADERS := $(abspath $(PATH_OUT))/$(patsubst %/,%,$(VBOX_INST_CRYPTO_HEADERS)) VBOX_PATH_CRYPTO_PROVIDERS := $(VBOX_PATH_OPENSSL)/providers # Enable asm implementation of crypto. if1of ($(KBUILD_TARGET_ARCH), x86 amd64) ifneq ($(VBOX_CRYPTO_ASM_SCHEME),portme) ifn1of ($(KBUILD_TARGET), ) # Selective exclusion for testing. VBOX_WITH_CRYPTO_ASM = 1 endif endif endif # # A target for installer the header files into a include directory # for the build. We have to put this in the Config.kmk because it # is required when running make from a sub directory too. # INSTALLS += crypto-headers crypto-headers_INST = $(VBOX_INST_CRYPTO_HEADERS) crypto-headers_MODE = a+r,u+w crypto-headers_DEFPATH = $(VBOX_PATH_OPENSSL) crypto-headers_SOURCES = \ include/openssl/aes.h=>aes.h \ include/openssl/asn1err.h=>asn1err.h \ include/openssl/asn1_mac.h=>asn1_mac.h \ include/openssl/async.h=>async.h \ include/openssl/asyncerr.h=>asyncerr.h \ include/openssl/bioerr.h=>bioerr.h \ include/openssl/blowfish.h=>blowfish.h \ include/openssl/bn.h=>bn.h \ include/openssl/bnerr.h=>bnerr.h \ include/openssl/buffer.h=>buffer.h \ include/openssl/buffererr.h=>buffererr.h \ include/openssl/camellia.h=>camellia.h \ include/openssl/cast.h=>cast.h \ include/openssl/cmac.h=>cmac.h \ include/openssl/cmserr.h=>cmserr.h \ include/openssl/comp.h=>comp.h \ include/openssl/comperr.h=>comperr.h \ include/openssl/conferr.h=>conferr.h \ include/openssl/conf_api.h=>conf_api.h \ include/openssl/conftypes.h=>conftypes.h \ include/openssl/core.h=>core.h \ include/openssl/core_dispatch.h=>core_dispatch.h \ include/openssl/core_names.h=>core_names.h \ include/openssl/cryptoerr.h=>cryptoerr.h \ include/openssl/cryptoerr_legacy.h=>cryptoerr_legacy.h \ include/openssl/cterr.h=>cterr.h \ include/openssl/des.h=>des.h \ include/openssl/dh.h=>dh.h \ include/openssl/dherr.h=>dherr.h \ include/openssl/dsa.h=>dsa.h \ include/openssl/dsaerr.h=>dsaerr.h \ include/openssl/dtls1.h=>dtls1.h \ include/openssl/ebcdic.h=>ebcdic.h \ include/openssl/ec.h=>ec.h \ include/openssl/ecerr.h=>ecerr.h \ include/openssl/ecdh.h=>ecdh.h \ include/openssl/ecdsa.h=>ecdsa.h \ include/openssl/engine.h=>engine.h \ include/openssl/engineerr.h=>engineerr.h \ include/openssl/evp.h=>evp.h \ include/openssl/evperr.h=>evperr.h \ include/openssl/e_os2.h=>e_os2.h \ include/openssl/hmac.h=>hmac.h \ include/openssl/http.h=>http.h \ include/openssl/idea.h=>idea.h \ include/openssl/macros.h=>macros.h \ include/openssl/md2.h=>md2.h \ include/openssl/md4.h=>md4.h \ include/openssl/md5.h=>md5.h \ include/openssl/mdc2.h=>mdc2.h \ include/openssl/modes.h=>modes.h \ include/openssl/objects.h=>objects.h \ include/openssl/objectserr.h=>objectserr.h \ include/openssl/obj_mac.h=>obj_mac.h \ include/openssl/ocsperr.h=>ocsperr.h \ openssl-mangling.h=>openssl-mangling.h \ include/openssl/opensslconf.h=>opensslconf.h \ include/openssl/ossl_typ.h=>ossl_typ.h \ include/openssl/params.h=>params.h \ include/openssl/pem.h=>pem.h \ include/openssl/pemerr.h=>pemerr.h \ include/openssl/pem2.h=>pem2.h \ include/openssl/pkcs12err.h=>pkcs12err.h \ include/openssl/pkcs7err.h=>pkcs7err.h \ include/openssl/prov_ssl.h=>prov_ssl.h \ include/openssl/rand.h=>rand.h \ include/openssl/randerr.h=>randerr.h \ include/openssl/rc2.h=>rc2.h \ include/openssl/rc4.h=>rc4.h \ include/openssl/ripemd.h=>ripemd.h \ include/openssl/rsa.h=>rsa.h \ include/openssl/rsaerr.h=>rsaerr.h \ include/openssl/seed.h=>seed.h \ include/openssl/sha.h=>sha.h \ include/openssl/srtp.h=>srtp.h \ include/openssl/sslerr.h=>sslerr.h \ include/openssl/sslerr_legacy.h=>sslerr_legacy.h \ include/openssl/ssl2.h=>ssl2.h \ include/openssl/ssl3.h=>ssl3.h \ include/openssl/stack.h=>stack.h \ include/openssl/symhacks.h=>symhacks.h \ include/openssl/tls1.h=>tls1.h \ include/openssl/ts.h=>ts.h \ include/openssl/txt_db.h=>txt_db.h \ include/openssl/types.h=>types.h \ include/openssl/uierr.h=>uierr.h \ include/openssl/x509err.h=>x509err.h \ include/openssl/x509v3err.h=>x509v3err.h \ gen-includes/openssl/asn1.h=>asn1.h \ gen-includes/openssl/asn1t.h=>asn1t.h \ gen-includes/openssl/bio.h=>bio.h \ gen-includes/openssl/cmp.h=>cmp.h \ gen-includes/openssl/cms.h=>cms.h \ gen-includes/openssl/conf.h=>conf.h \ gen-includes/openssl/configuration.h=>configuration.h \ gen-includes/openssl/crmf.h=>crmf.h \ gen-includes/openssl/crypto.h=>crypto.h \ gen-includes/openssl/ct.h=>ct.h \ gen-includes/openssl/err.h=>err.h \ gen-includes/openssl/ess.h=>ess.h \ gen-includes/openssl/fipskey.h=>fipskey.h \ gen-includes/openssl/lhash.h=>lhash.h \ gen-includes/openssl/ocsp.h=>ocsp.h \ gen-includes/openssl/opensslv.h=>opensslv.h \ gen-includes/openssl/pkcs12.h=>pkcs12.h \ gen-includes/openssl/pkcs7.h=>pkcs7.h \ gen-includes/openssl/safestack.h=>safestack.h \ gen-includes/openssl/srp.h=>srp.h \ gen-includes/openssl/ssl.h=>ssl.h \ gen-includes/openssl/ui.h=>ui.h \ gen-includes/openssl/x509.h=>x509.h \ gen-includes/openssl/x509_vfy.h=>x509_vfy.h \ gen-includes/openssl/x509v3.h=>x509v3.h # # The templates used for the crypo lib and all its sublibraries. # TEMPLATE_LIBCRYPTO = Template for the OpenSSL crypto library. TEMPLATE_LIBCRYPTO_EXTENDS = VBoxR3RuntimeDllNonPedantic ifneq ($(KBUILD_TARGET), win) ## @todo correct inheritance here to make it use all the VBOXR3NP settings instead of overriding all of them. TEMPLATE_LIBCRYPTO_ASTOOL = $(TEMPLATE_VBoxR3RuntimeDllNonPedantic_TOOL) TEMPLATE_LIBCRYPTO_ASFLAGS = -include $(VBOX_PATH_OPENSSL)/openssl-mangling.h TEMPLATE_LIBCRYPTO_ASFLAGS.x86 = -m32 TEMPLATE_LIBCRYPTO_ASFLAGS.amd64 = -m64 TEMPLATE_LIBCRYPTO_ASDEFS = $(NO_SUCH_VARIABLE) TEMPLATE_LIBCRYPTO_ASDEFS.darwin = OPENSSL_MANGLE_ASM endif TEMPLATE_LIBCRYPTO_DEFS = \ $(TEMPLATE_VBoxR3RuntimeDllNonPedantic_DEFS) \ VBOX_SUFF_DLL=$(VBOX_SUFF_DLL) \ IN_RT_R3 \ DSO_NONE \ OPENSSL_USE_NODELETE \ OPENSSL_PIC \ OPENSSL_IA32_SSE2 \ OPENSSL_BUILDING_OPENSSL ifdef VBOX_WITH_CRYPTO_ASM TEMPLATE_LIBCRYPTO_DEFS += \ OPENSSL_BN_ASM_MONT \ OPENSSL_BN_ASM_GF2m \ SHA1_ASM \ SHA256_ASM \ SHA512_ASM \ RC4_ASM \ MD5_ASM \ AES_ASM \ VPAES_ASM \ ECP_NISTZ256_ASM \ PADLOCK_ASM \ POLY1305_ASM TEMPLATE_LIBCRYPTO_DEFS.amd64 = \ BSAES_ASM \ GHASH_ASM \ KECCAK1600_ASM \ OPENSSL_BN_ASM_MONT5 \ X25519_ASM else TEMPLATE_LIBCRYPTO_DEFS += \ OPENSSL_NO_ASM endif if1of ($(KBUILD_TARGET), linux solaris) TEMPLATE_LIBCRYPTO_DEFS += \ _REENTRANT \ _GNU_SOURCE endif ifeq ($(sort $(filter -fPIC,$(TEMPLATE_VBoxR3RuntimeDllNonPedantic_CFLAGS))),-fPIC) TEMPLATE_LIBCRYPTO_DEFS += \ OPENSSL_PIC endif TEMPLATE_LIBCRYPTO_DEFS.amd64 += \ MD32_REG_T=int ifeq ($(KBUILD_TARGET),win) TEMPLATE_LIBCRYPTO_DEFS += \ OPENSSL_SYSNAME_WIN32 \ OPENSSL_RAND_SEED_OS # Exclude WinCrypt.h, causes trouble all over the place TEMPLATE_LIBCRYPTO_DEFS += \ NOCRYPT endif if1of ($(KBUILD_TARGET_ARCH), x86 amd64 arm64) TEMPLATE_LIBCRYPTO_DEFS += \ L_ENDIAN else TEMPLATE_LIBCRYPTO_DEFS += \ B_ENDIAN endif ifeq ($(KBUILD_TARGET),os2) TEMPLATE_LIBCRYPTO_DEFS += \ OPENSSL_NO_SECURE_MEMORY endif if defined(VBOX_WITH_PARFAIT) #&& VBOX_GCC_VERSION_CC == 50301 TEMPLATE_LIBCRYPTO_DEFS += __STDC_NO_ATOMICS__ endif # Enable for running with valgrind: #TEMPLATE_LIBCRYPTO_DEFS += PURIFY TEMPLATE_LIBCRYPTO_CFLAGS = $(filter-out $(VBOX_GCC_fvisibility-hidden),$(TEMPLATE_VBoxR3RuntimeDllNonPedantic_CFLAGS)) TEMPLATE_LIBCRYPTO_CFLAGS.win = $(TEMPLATE_VBoxR3RuntimeDllNonPedantic_CFLAGS.win) TEMPLATE_LIBCRYPTO_CFLAGS.win += -wd4305 # asn1_lib.c(455) : warning C4305: 'type cast' : truncation from 'const unsigned char *' to 'unsigned long' TEMPLATE_LIBCRYPTO_CFLAGS.win += -wd4306 # tasn_new.c(338) : warning C4306: 'type cast' : conversion from 'int' to 'ASN1_VALUE *' of greater size TEMPLATE_LIBCRYPTO_CFLAGS.win += -wd4701 # tasn_dec.c(840) : warning C4701: potentially uninitialized local variable 'buf' used TEMPLATE_LIBCRYPTO_CFLAGS.win += -wd4101 # bn_asm.c(619) : warning C4101: 'bh' : unreferenced local variable TEMPLATE_LIBCRYPTO_CFLAGS.win += -wd4206 # e_camellia.c(120) : warning C4206: nonstandard extension used : translation unit is empty TEMPLATE_LIBCRYPTO_CFLAGS.win += -wd4232 # warning C4232: nonstandard extension used : 'malloc_func' : address of dllimport 'malloc' is not stati c, identity not guaranteed TEMPLATE_LIBCRYPTO_CFLAGS.win += -wd4146 # x_long.c(79) : warning C4146: unary minus operator applied to unsigned type, result still unsigned TEMPLATE_LIBCRYPTO_CFLAGS.win += -wd4130 # b_addr.c(750) : warning C4130: '==' : logical operation on address of string constant TEMPLATE_LIBCRYPTO_CFLAGS.win += -wd4090 # ssl_lib.c(229) : warning C4090: 'function' : different 'const' qualifiers TEMPLATE_LIBCRYPTO_CFLAGS.win += -wd4310 # bss_acpt.c(223) : warning C4310: cast truncates constant value [(int)INVALID_SOCKET] TEMPLATE_LIBCRYPTO_CFLAGS.win += -wd4210 # bn_exp.c(913) : warning C4210: nonstandard extension used : function given file scope TEMPLATE_LIBCRYPTO_CFLAGS.win += -wd4067 # mem.c(14) : warning C4067: unexpected tokens following preprocessor directive - expected a newline if1of ($(VBOX_VCC_TOOL_STEM), VCC120) TEMPLATE_LIBCRYPTO_CFLAGS.win += -wd4005 # sdk\v7.1\include\sal_supp.h(57) : warning C4005: '__useHeader' : macro redefinition endif TEMPLATE_LIBCRYPTO_CFLAGS.freebsd = -std=gnu99 TEMPLATE_LIBCRYPTO_INCS := \ $(VBOX_PATH_OPENSSL) \ $(VBOX_PATH_OPENSSL)/include \ $(VBOX_PATH_OPENSSL)/providers/common/include \ $(VBOX_PATH_OPENSSL)/providers/implementations/include \ $(VBOX_PATH_OPENSSL)/gen-includes \ $(VBOX_PATH_CRYPTO)/include \ $(VBOX_PATH_CRYPTO_MODES) \ $(VBOX_PATH_CRYPTO)/ec/curve448 \ $(VBOX_PATH_CRYPTO)/ec/curve448/arch_32 \ $(patsubst %/openssl,%,$(VBOX_PATH_CRYPTO_HEADERS)) #TEMPLATE_LIBCRYPTO_INTERMEDIATES = $($(crypto-headers)_1_STAGE_TARGET) TEMPLATE_LIBCRYPTO_INTERMEDIATES := \ $(foreach f,$(crypto-headers_SOURCES),$(VBOX_PATH_CRYPTO_HEADERS)/$(lastword $(subst =>, ,$(f)))) # Same as LIBCRYPTO except that we don't install these libraries. TEMPLATE_SUBLIBCRYPTO = Template for the OpenSSL crypto sub-libraries. TEMPLATE_SUBLIBCRYPTO_EXTENDS = LIBCRYPTO TEMPLATE_SUBLIBCRYPTO_INSTTYPE = none # Somewhat similar to LIBCRYPTO. TEMPLATE_LIBCRYPTOTST = Template for the OpenSSL crypto testcases. TEMPLATE_LIBCRYPTOTST_EXTENDS = VBOXR3TSTEXE TEMPLATE_LIBCRYPTOTST_DEFS = $(TEMPLATE_VBOXR3TSTEXE_DEFS) $(filter-out $(TEMPLATE_VBoxR3RuntimeDllNonPedantic_DEFS) IN_RT_R3,$(TEMPLATE_LIBCRYPTO_DEFS)) TEMPLATE_LIBCRYPTOTST_INCS = $(TEMPLATE_LIBCRYPTO_INCS) $(TEMPLATE_VBOXR3TSTEXE_INCS) ifeq ($(KBUILD_TARGET),win) TEMPLATE_LIBCRYPTOTST_CFLAGS = $(filter-out $(VBOX_VCC_WERR), $(TEMPLATE_VBOXR3TSTEXE_CXXFLAGS)) $(VBOX_VCC_NON_PEDANTIC) else TEMPLATE_LIBCRYPTOTST_CFLAGS = $(filter-out $(VBOX_GCC_PEDANTIC_C), $(TEMPLATE_VBOXR3TSTEXE_CFLAGS)) $(VBOX_GCC_NON_PEDANTIC_C) endif TEMPLATE_LIBCRYPTOTST_LIBS = $(PATH_STAGE_LIB)/VBox-libcrypto$(VBOX_SUFF_LIB) $(TEMPLATE_VBOXR3TSTEXE_LIBS) # # 32-bit version of LIBCRYPTO and SUBLIBCRYPTO. # TEMPLATE_VBoxLibCrypto-x86 = 32-bit template for the OpenSSL crypto library. TEMPLATE_VBoxLibCrypto-x86_EXTENDS = LIBCRYPTO TEMPLATE_VBoxLibCrypto-x86_BLD_TRG_ARCH = x86 TEMPLATE_VBoxLibCrypto-x86_DEFS = $(filter-out HC_ARCH_BITS%,$(TEMPLATE_LIBCRYPTO_DEFS)) HC_ARCH_BITS=32 ARCH_BITS=32 TEMPLATE_VBoxSubLibCrypto-x86 = 32-bit template for the OpenSSL crypto sub-library. TEMPLATE_VBoxSubLibCrypto-x86_EXTENDS = VBoxLibCrypto-x86 TEMPLATE_VBoxSubLibCrypto-x86_INSTTYPE = none ifdef VBOX_WITH_32_ON_64_MAIN_API # 32-bit edition. define VBOX_OPENSSL_X86 $(eval LIBRARIES += $(1)-x86) $(1)-x86_TEMPLATE := VBoxSubLibCrypto-x86 $(1)-x86_EXTENDS := $(1) endef else define VBOX_OPENSSL_X86 endef endif