# $Id: Makefile.kmk 101211 2023-09-21 06:43:35Z vboxsync $ ## @file # Sub-Makefile for OpenSSL crypto. # # # Copyright (C) 2006-2023 Oracle and/or its affiliates. # # This file is part of VirtualBox base platform packages, as # available from https://www.virtualbox.org. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation, in version 3 of the # License. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # SPDX-License-Identifier: GPL-3.0-only # SUB_DEPTH = ../../../.. include $(KBUILD_PATH)/subheader.kmk # # Include sub-makefiles. # # Note! For joining the sub libraries into a crypto lib, we do some trickery to # collect the sub-library names here. # VBOX_LIBRARIES_BEFORE_CRYPTO_SUBDIRS := $(LIBRARIES) if defined(VBOX_ONLY_VALIDATIONKIT) && !defined(VBOX_WITH_VALIDATIONKIT_UNITTESTS_PACKING) include $(VBOX_PATH_CRYPTO)/sha/Makefile.kmk else # Validation Kit unit tests need this. include $(sort $(wildcard $(VBOX_PATH_CRYPTO)/*/Makefile.kmk)) endif VBOX_CRYPTO_SUBLIBS := $(filter-out $(VBOX_LIBRARIES_BEFORE_CRYPTO_SUBDIRS), $(LIBRARIES)) VBOX_CRYPTO_SUBLIBS_X86 := $(filter %-x86, $(VBOX_CRYPTO_SUBLIBS)) VBOX_CRYPTO_SUBLIBS := $(filter-out %-x86, $(VBOX_CRYPTO_SUBLIBS)) if defined(VBOX_ONLY_EXTPACKS_USE_IMPLIBS) $(eval LIBRARIES = $(VBOX_LIBRARIES_BEFORE_CRYPTO_SUBDIRS) crypto_sha) else if "$(SDK_VBoxOpenSslStatic_INCS)" != "$(SDK_VBoxOpenSslStatic_VBOX_DEFAULT_INCS)" $(eval LIBRARIES = $(VBOX_LIBRARIES_BEFORE_CRYPTO_SUBDIRS)) endif VBOX_LIBRARIES_BEFORE_CRYPTO_SUBDIRS := # # The VBoxRT libcrypto. # LIBRARIES += VBox-libcrypto VBox-libcrypto_TEMPLATE = LibCrypto VBox-libcrypto_INCS = $(VBox-libcrypto_0_OUTDIR) VBox-libcrypto_SOURCES = \ asn1_dsa.c \ bsearch.c \ context.c \ core_algorithm.c \ core_fetch.c \ core_namemap.c \ cpt_err.c \ cpuid.c \ cryptlib.c \ ctype.c \ cversion.c \ der_writer.c \ ebcdic.c \ ex_data.c \ getenv.c \ info.c \ init.c \ initthread.c \ mem.c \ mem_sec.c \ o_dir.c \ o_fopen.c \ o_init.c \ o_str.c \ o_time.c \ packet.c \ param_build.c \ param_build_set.c \ params.c \ params_dup.c \ params_from_text.c \ passphrase.c \ provider.c \ provider_child.c \ provider_conf.c \ provider_core.c \ provider_predefined.c \ punycode.c \ self_test_core.c \ sparse_array.c \ threads_iprt.c \ threads_none.c \ threads_win.c \ trace.c \ uid.c ifdef VBOX_WITH_CRYPTO_ASM VBox-libcrypto_DEFS.x86 += OPENSSL_CPUID_OBJ=x86cpuid.o VBox-libcrypto_SOURCES.x86 += $(VBOX_PATH_CRYPTO_GENASM)/x86cpuid.S VBox-libcrypto_DEFS.amd64 += OPENSSL_CPUID_OBJ=x86_64cpuid.o VBox-libcrypto_SOURCES.amd64 += $(VBOX_PATH_CRYPTO_GENASM)/x86_64cpuid.S else VBox-libcrypto_SOURCES += mem_clr.c endif ifdef VBOX_WITH_OPENSSL_FIPS VBox-libcrypto_SOURCES += o_fips.c fips_ers.c endif VBox-libcrypto_SOURCES += $(PATH_STAGE_LIB)/VBox-libproviders$(VBOX_SUFF_LIB) if defined(VBOX_ONLY_EXTPACKS_USE_IMPLIBS) VBox-libcrypto_SOURCES += $(crypto_sha_1_TARGET) else if "$(SDK_VBoxOpenSslStatic_INCS)" == "$(SDK_VBoxOpenSslStatic_VBOX_DEFAULT_INCS)" VBox-libcrypto_SOURCES += $(foreach sublib,$(VBOX_CRYPTO_SUBLIBS), $($(sublib)_1_TARGET)) endif VBox-libcrypto_CLEAN = $(VBox-libcrypto_0_OUTDIR)/buildinf.h VBox-libcrypto_INTERMEDIATES = $(VBox-libcrypto_0_OUTDIR)/buildinf.h ifdef VBOX_WITH_32_ON_64_MAIN_API # 32-bit edition. LIBRARIES += VBox-libcrypto-x86 VBox-libcrypto-x86_TEMPLATE = VBoxLibCrypto-x86 VBox-libcrypto-x86_EXTENDS = VBox-libcrypto VBox-libcrypto-x86_SOURCES = $(filter %.c %.cpp,$(VBox-libcrypto_SOURCES)) \ $(PATH_STAGE_LIB)/VBox-libproviders-x86$(VBOX_SUFF_LIB) \ $(foreach sublib,$(VBOX_CRYPTO_SUBLIBS_X86), $($(sublib)_1_TARGET)) endif if defined(VBOX_NEED_EXTPACK_OPENSSL) && !defined(VBOX_ONLY_VALIDATIONKIT) # Not needed for Validation Kit. # # The extension pack libcrypto. # LIBRARIES += VBoxExtPack-libcrypto VBoxExtPack-libcrypto = For the Oracle Extension Pack VBoxExtPack-libcrypto_EXTENDS = VBox-libcrypto VBoxExtPack-libcrypto_DEFS = $(VBox-libcrypto_DEFS) VBOX_IN_EXTPACK VBoxExtPack-libcrypto_SOURCES = \ $(filter %.c %.cpp,$(VBox-libcrypto_SOURCES)) \ $(foreach sublib,$(VBOX_CRYPTO_SUBLIBS), $(VBoxExtPack-$(sublib)_1_TARGET)) define def_VBoxExtPack_libcrypto_inherit LIBRARIES += VBoxExtPack-$(sublib) VBoxExtPack-$(sublib) = Oracle Extension Pack version of $(sublib) VBoxExtPack-$(sublib)_EXTENDS = $(sublib) VBoxExtPack-$(sublib)_EXTENDS_BY = appending VBoxExtPack-$(sublib)_DEFS = VBOX_IN_EXTPACK VBoxExtPack-$(sublib)_DEFPATH = $($(sublib)_DEFPATH) ## @todo kBuild: DEFPATH isn't inherited! FIXME! endef $(foreach sublib,$(VBOX_CRYPTO_SUBLIBS), $(eval $(def_VBoxExtPack_libcrypto_inherit))) endif # VBOX_NEED_EXTPACK_OPENSSL ifdef VBOX_WITH_BLD_RTSIGNTOOL_SIGNING # # The build program libcrypto version. # LIBRARIES += VBoxBldProg-libcrypto VBoxBldProg-libcrypto = For bldRTSignTool VBoxBldProg-libcrypto_EXTENDS = VBox-libcrypto VBoxBldProg-libcrypto_TEMPLATE = VBoxLibCryptoBldProg VBoxBldProg-libcrypto_DEFS = $(VBox-libcrypto_DEFS) VBoxBldProg-libcrypto_SOURCES = \ $(filter %.c %.cpp,$(VBox-libcrypto_SOURCES)) \ $(PATH_STAGE_LIB)/VBoxBldProg-libproviders$(VBOX_SUFF_LIB) \ $(foreach sublib,$(VBOX_CRYPTO_SUBLIBS), $(VBoxBldProg-$(sublib)_1_TARGET)) define def_VBoxBldProg_libcrypto_inherit LIBRARIES += VBoxBldProg-$(sublib) VBoxBldProg-$(sublib) = bldRTSignTool version of $(sublib) VBoxBldProg-$(sublib)_EXTENDS = $(sublib) VBoxBldProg-$(sublib)_EXTENDS_BY = appending VBoxBldProg-$(sublib)_TEMPLATE = VBoxSubLibCryptoBldProg VBoxBldProg-$(sublib)_DEFPATH = $($(sublib)_DEFPATH) ## @todo kBuild: DEFPATH isn't inherited! FIXME! endef $(foreach sublib,$(VBOX_CRYPTO_SUBLIBS), $(eval $(def_VBoxBldProg_libcrypto_inherit))) endif # VBOX_WITH_BLD_RTSIGNTOOL_SIGNING # # ... # recreate-openssl-asm: $(VBOX_PATH_CRYPTO)/perlasm/x86asm.pl \ $(VBOX_PATH_CRYPTO)/x86cpuid.pl \ $(VBOX_PATH_CRYPTO)/x86_64cpuid.pl \ recreate-aes-asm \ recreate-bn-asm \ recreate-chacha-asm \ recreate-ec-asm \ recreate-md5-asm \ recreate-modes-asm \ recreate-poly1305-asm \ recreate-rc4-asm \ recreate-sha-asm perl $(VBOX_PATH_CRYPTO)/x86cpuid.pl elf -fPIC $(VBOX_PATH_CRYPTO)/genasm-elf/x86cpuid.S perl $(VBOX_PATH_CRYPTO)/x86_64cpuid.pl elf $(VBOX_PATH_CRYPTO)/genasm-elf/x86_64cpuid.S perl $(VBOX_PATH_CRYPTO)/x86cpuid.pl macosx $(VBOX_PATH_CRYPTO)/genasm-macosx/x86cpuid.S perl $(VBOX_PATH_CRYPTO)/x86_64cpuid.pl macosx $(VBOX_PATH_CRYPTO)/genasm-macosx/x86_64cpuid.S perl $(VBOX_PATH_CRYPTO)/x86cpuid.pl win32n $(VBOX_PATH_CRYPTO)/genasm-nasm/x86cpuid.S perl $(VBOX_PATH_CRYPTO)/x86_64cpuid.pl nasm $(VBOX_PATH_CRYPTO)/genasm-nasm/x86_64cpuid.S include $(FILE_KBUILD_SUB_FOOTER) # # Generate # $(VBox-libcrypto_0_OUTDIR)/buildinf.h: $(VBOX_PATH_CRYPTO)/Makefile.kmk | $$(dir $$@) $(call MSG_GENERATE,,$@) $(QUIET)$(RM) -f $@ $(QUIET)$(APPEND) $@ '/* auto-generated by crypto/Makefile.kmk for crypto/cversion.c */' $(QUIET)$(APPEND) $@ '#ifndef MK1MF_BUILD' $(QUIET)$(APPEND) $@ '# define PLATFORM "$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)"' $(QUIET)$(APPEND) $@ '# define DATE "$(date-utc )"' $(QUIET)$(APPEND) $@ 'static const char compiler_flags[] =' $(QUIET)$(APPEND) $@ ' "$(VBox-libcrypto_CFLAGS)";' $(QUIET)$(APPEND) $@ '#endif'