mirror of
https://github.com/stefanberger/libtpms
synced 2026-01-13 10:33:54 +00:00
feat: Add full source lists for TPM1 and TPM2
This commit implements Step 4 of the Meson migration plan. - Populates the build with the full list of source files for both TPM 1.2 and TPM 2.0 implementations. - Refactors the build to use intermediate static libraries for TPM1 and TPM2, allowing for implementation-specific compiler flags. - Adds necessary preprocessor definitions to successfully compile the full library. - Adds header checks for arpa/inet.h and time.h. Signed-off-by: Gemini <gemini@google.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
de29c4b8d2
commit
d851618afe
@ -1,3 +1,5 @@
|
||||
/* config.h.in. Generated from meson.build by Meson. */
|
||||
|
||||
#mesondefine PACKAGE_VERSION
|
||||
#mesondefine HAVE_ARPA_INET_H
|
||||
#mesondefine HAVE_TIME_H
|
||||
|
||||
11
meson.build
11
meson.build
@ -4,12 +4,21 @@ project('libtpms', 'c',
|
||||
default_options: ['c_std=c99'])
|
||||
|
||||
# Add an include directory that points to the build directory.
|
||||
# This is necessary so that source files can find the generated config.h
|
||||
add_project_arguments('-I' + meson.current_build_dir(), language: 'c')
|
||||
|
||||
# Create a configuration header file
|
||||
conf_data = configuration_data()
|
||||
conf_data.set('PACKAGE_VERSION', '"' + meson.project_version() + '"')
|
||||
|
||||
# Check for headers
|
||||
c_compiler = meson.get_compiler('c')
|
||||
if c_compiler.has_header('arpa/inet.h')
|
||||
conf_data.set('HAVE_ARPA_INET_H', 1)
|
||||
endif
|
||||
if c_compiler.has_header('time.h')
|
||||
conf_data.set('HAVE_TIME_H', 1)
|
||||
endif
|
||||
|
||||
configure_file(
|
||||
input: 'config.h.in',
|
||||
output: 'config.h',
|
||||
|
||||
128
src/meson.build
128
src/meson.build
@ -9,7 +9,7 @@ with_tpm1 = get_option('tpm1')
|
||||
with_tpm2 = get_option('tpm2')
|
||||
|
||||
# Start with the common source files
|
||||
libtpms_sources = files(
|
||||
common_sources = files(
|
||||
'tpm_debug.c',
|
||||
'tpm_library.c',
|
||||
'tpm_memory.c',
|
||||
@ -17,24 +17,130 @@ libtpms_sources = files(
|
||||
'disabled_interface.c'
|
||||
)
|
||||
|
||||
link_with_libs = []
|
||||
extra_deps = []
|
||||
|
||||
# Common c_args for all libraries
|
||||
common_c_args = [
|
||||
'-DTPM_NV_DISK',
|
||||
'-DTPM_LIBTPMS_CALLBACKS',
|
||||
'-include', 'tpm_library_conf.h'
|
||||
]
|
||||
|
||||
if with_tpm1
|
||||
# Add TPM1 sources here in the next step
|
||||
message('Building with TPM 1.2 support')
|
||||
tpm1_sources = files(
|
||||
'tpm12/tpm_admin.c', 'tpm12/tpm_audit.c', 'tpm12/tpm_auth.c',
|
||||
'tpm12/tpm_cryptoh.c', 'tpm12/tpm_counter.c', 'tpm12/tpm_daa.c',
|
||||
'tpm12/tpm_delegate.c', 'tpm12/tpm_digest.c', 'tpm12/tpm_error.c',
|
||||
'tpm12/tpm_global.c', 'tpm12/tpm_identity.c', 'tpm12/tpm_init.c',
|
||||
'tpm12/tpm_libtpms_io.c', 'tpm12/tpm_key.c', 'tpm12/tpm_load.c',
|
||||
'tpm12/tpm_maint.c', 'tpm12/tpm_migration.c', 'tpm12/tpm_nonce.c',
|
||||
'tpm12/tpm_nvram.c', 'tpm12/tpm_openssl_helpers.c', 'tpm12/tpm_owner.c',
|
||||
'tpm12/tpm_pcr.c', 'tpm12/tpm_permanent.c', 'tpm12/tpm_platform.c',
|
||||
'tpm12/tpm_process.c', 'tpm12/tpm_secret.c', 'tpm12/tpm_session.c',
|
||||
'tpm12/tpm_sizedbuffer.c', 'tpm12/tpm_startup.c', 'tpm12/tpm_store.c',
|
||||
'tpm12/tpm_storage.c', 'tpm12/tpm_ticks.c', 'tpm12/tpm_time.c',
|
||||
'tpm12/tpm_transport.c', 'tpm12/tpm_ver.c', 'tpm12/tpm_svnrevision.c',
|
||||
'tpm_tpm12_interface.c', 'tpm_tpm12_tis.c', 'tpm12/tpm_crypto.c'
|
||||
)
|
||||
|
||||
tpm1_lib = static_library('tpms_tpm12', tpm1_sources,
|
||||
c_args: common_c_args + [
|
||||
'-DTPM_V12',
|
||||
'-DTPM_PCCLIENT',
|
||||
'-DTPM_POSIX',
|
||||
'-DTPM_AES',
|
||||
'-DTPM_NOMAINTENANCE_COMMANDS',
|
||||
'-DTPM_ENABLE_ACTIVATE',
|
||||
'-DTPM_VOLATILE_LOAD',
|
||||
],
|
||||
include_directories: [lib_inc],
|
||||
)
|
||||
link_with_libs += tpm1_lib
|
||||
endif
|
||||
|
||||
if with_tpm2
|
||||
# Add TPM2 sources here in the next step
|
||||
message('Building with TPM 2.0 support')
|
||||
rt_dep = meson.get_compiler('c').find_library('rt', required: false)
|
||||
extra_deps += rt_dep
|
||||
|
||||
tpm2_sources = files(
|
||||
'tpm2/ACT_spt.c', 'tpm2/ACTCommands.c', 'tpm2/AlgorithmCap.c',
|
||||
'tpm2/AlgorithmTests.c', 'tpm2/AsymmetricCommands.c',
|
||||
'tpm2/AttestationCommands.c', 'tpm2/Attest_spt.c', 'tpm2/AuditCommands.c',
|
||||
'tpm2/Bits.c', 'tpm2/BnEccConstants.c', 'tpm2/BnConvert.c', 'tpm2/BnMath.c',
|
||||
'tpm2/BnMemory.c', 'tpm2/Cancel.c', 'tpm2/CapabilityCommands.c',
|
||||
'tpm2/Clock.c', 'tpm2/ClockCommands.c', 'tpm2/CommandAudit.c',
|
||||
'tpm2/CommandCodeAttributes.c', 'tpm2/CommandDispatcher.c',
|
||||
'tpm2/ContextCommands.c', 'tpm2/Context_spt.c', 'tpm2/CryptEccData.c',
|
||||
'tpm2/CryptSelfTest.c', 'tpm2/CryptUtil.c', 'tpm2/DA.c',
|
||||
'tpm2/DebugHelpers.c', 'tpm2/DictionaryCommands.c',
|
||||
'tpm2/DuplicationCommands.c', 'tpm2/EACommands.c',
|
||||
'tpm2/EncryptDecrypt_spt.c', 'tpm2/Entity.c', 'tpm2/Entropy.c',
|
||||
'tpm2/EphemeralCommands.c', 'tpm2/ExecCommand.c', 'tpm2/ExtraData.c',
|
||||
'tpm2/Global.c', 'tpm2/Handle.c', 'tpm2/HashCommands.c',
|
||||
'tpm2/Hierarchy.c', 'tpm2/HierarchyCommands.c', 'tpm2/IntegrityCommands.c',
|
||||
'tpm2/IoBuffers.c', 'tpm2/Locality.c', 'tpm2/LocalityPlat.c',
|
||||
'tpm2/ManagementCommands.c', 'tpm2/Manufacture.c', 'tpm2/Marshal.c',
|
||||
'tpm2/MathOnByteBuffers.c', 'tpm2/Memory.c', 'tpm2/NVCommands.c',
|
||||
'tpm2/NvDynamic.c', 'tpm2/NVMem.c', 'tpm2/NvReserved.c', 'tpm2/NV_spt.c',
|
||||
'tpm2/Object.c', 'tpm2/ObjectCommands.c', 'tpm2/Object_spt.c', 'tpm2/PCR.c',
|
||||
'tpm2/PlatformACT.c', 'tpm2/PlatformData.c', 'tpm2/PlatformPCR.c',
|
||||
'tpm2/Policy_spt.c', 'tpm2/Power.c', 'tpm2/PowerPlat.c', 'tpm2/PP.c',
|
||||
'tpm2/PPPlat.c', 'tpm2/PrimeData.c', 'tpm2/PropertyCap.c',
|
||||
'tpm2/RandomCommands.c', 'tpm2/Response.c',
|
||||
'tpm2/ResponseCodeProcessing.c', 'tpm2/RunCommand.c', 'tpm2/Session.c',
|
||||
'tpm2/SessionCommands.c', 'tpm2/SessionProcess.c',
|
||||
'tpm2/SigningCommands.c', 'tpm2/StartupCommands.c',
|
||||
'tpm2/SymmetricCommands.c', 'tpm2/TestingCommands.c', 'tpm2/Ticket.c',
|
||||
'tpm2/Time.c', 'tpm2/TpmASN1.c', 'tpm2/TpmBigNumThunks.c',
|
||||
'tpm2/TpmEcc_Signature_ECDAA.c', 'tpm2/TpmEcc_Signature_ECDSA.c',
|
||||
'tpm2/TpmEcc_Signature_Schnorr.c', 'tpm2/TpmEcc_Signature_SM2.c',
|
||||
'tpm2/TpmEcc_Signature_Util.c', 'tpm2/TpmEcc_Util.c',
|
||||
'tpm2/TpmMath_Debug.c', 'tpm2/TpmMath_Util.c', 'tpm2/TpmSizeChecks.c',
|
||||
'tpm2/TPMCmdp.c', 'tpm2/TpmFail.c', 'tpm2/Unique.c', 'tpm2/Unmarshal.c',
|
||||
'tpm2/VendorInfo.c', 'tpm2/Vendor_TCG_Test.c', 'tpm2/X509_ECC.c',
|
||||
'tpm2/X509_RSA.c', 'tpm2/X509_spt.c', 'tpm_tpm2_interface.c',
|
||||
'tpm_tpm2_tis.c', 'tpm2/BackwardsCompatibilityBitArray.c',
|
||||
'tpm2/BackwardsCompatibilityObject.c', 'tpm2/LibtpmsCallbacks.c',
|
||||
'tpm2/NVMarshal.c', 'tpm2/RuntimeAlgorithm.c', 'tpm2/RuntimeAttributes.c',
|
||||
'tpm2/RuntimeCommands.c', 'tpm2/RuntimeProfile.c', 'tpm2/StateMarshal.c',
|
||||
'tpm2/Volatile.c',
|
||||
'tpm2/crypto/openssl/BnToOsslMath.c', 'tpm2/crypto/openssl/CryptCmac.c',
|
||||
'tpm2/crypto/openssl/CryptDes.c', 'tpm2/crypto/openssl/CryptEccCrypt.c',
|
||||
'tpm2/crypto/openssl/CryptEccKeyExchange.c', 'tpm2/crypto/openssl/CryptEccMain.c',
|
||||
'tpm2/crypto/openssl/CryptEccSignature.c', 'tpm2/crypto/openssl/CryptHash.c',
|
||||
'tpm2/crypto/openssl/CryptPrime.c', 'tpm2/crypto/openssl/CryptPrimeSieve.c',
|
||||
'tpm2/crypto/openssl/CryptRand.c', 'tpm2/crypto/openssl/CryptRsa.c',
|
||||
'tpm2/crypto/openssl/CryptSmac.c', 'tpm2/crypto/openssl/CryptSym.c',
|
||||
'tpm2/crypto/openssl/ExpDCache.c', 'tpm2/crypto/openssl/Helpers.c',
|
||||
'tpm2/crypto/openssl/TpmToOsslDesSupport.c', 'tpm2/crypto/openssl/TpmToOsslSupport.c'
|
||||
)
|
||||
|
||||
tpm2_lib = static_library('tpms_tpm2', tpm2_sources,
|
||||
c_args: common_c_args + [
|
||||
'-D_POSIX_C_SOURCE=200809L',
|
||||
'-DTPM_POSIX',
|
||||
'-include', 'config.h'
|
||||
],
|
||||
include_directories: [
|
||||
lib_inc,
|
||||
'.',
|
||||
'tpm2',
|
||||
'tpm2/crypto',
|
||||
'tpm2/crypto/openssl'
|
||||
],
|
||||
)
|
||||
link_with_libs += tpm2_lib
|
||||
endif
|
||||
|
||||
# Define the shared library
|
||||
# Define the final shared library
|
||||
libtpms = shared_library('tpms',
|
||||
libtpms_sources,
|
||||
c_args: [
|
||||
'-DTPM_NV_DISK',
|
||||
'-include', 'tpm_library_conf.h'
|
||||
],
|
||||
dependencies: crypto_dep,
|
||||
common_sources,
|
||||
c_args: common_c_args + ['-include', 'config.h'],
|
||||
link_with: link_with_libs,
|
||||
dependencies: [crypto_dep] + extra_deps,
|
||||
include_directories: [lib_inc],
|
||||
install: true,
|
||||
)
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user