4 # For the license, see the LICENSE file in the root directory.
7 AM_CFLAGS = @AM_CFLAGS@
8 AM_LDFLAGS = @AM_LDFLAGS@ $(HARDENING_LDFLAGS) $(SANITIZERS) $(FUZZER)
10 lib_LTLIBRARIES=libtpms.la
12 common_CFLAGS = -include tpm_library_conf.h \
13 -I$(top_srcdir)/include/libtpms \
14 -I$(top_builddir)/include/libtpms \
20 # build with libtpms callback support
21 common_CFLAGS += -DTPM_LIBTPMS_CALLBACKS
22 # let the default NVRAM write to disk
23 common_CFLAGS += -DTPM_NV_DISK
29 noinst_LTLIBRARIES = libtpms_tpm12.la
31 libtpms_la_LIBADD = libtpms_tpm12.la
33 libtpms_tpm12_la_LIBADD =
35 libtpms_tpm12_la_CFLAGS = $(common_CFLAGS)
38 libtpms_tpm12_la_CFLAGS += -DTPM_V12
39 # build a PC Client TPM
40 libtpms_tpm12_la_CFLAGS += -DTPM_PCCLIENT
41 # upon initialization have the TPM load the volatile state
42 libtpms_tpm12_la_CFLAGS += -DTPM_VOLATILE_LOAD
43 # build the TPM enabled and activated
44 libtpms_tpm12_la_CFLAGS += -DTPM_ENABLE_ACTIVATE
45 # build with AES support for symmetric crypto
46 libtpms_tpm12_la_CFLAGS += -DTPM_AES
47 # build a POSIX type of TPM
48 libtpms_tpm12_la_CFLAGS += -DTPM_POSIX
49 # build without maintenance commands
50 libtpms_tpm12_la_CFLAGS += -DTPM_NOMAINTENANCE_COMMANDS
52 libtpms_tpm12_la_CFLAGS += @DEBUG_DEFINES@
56 libtpms_tpm12_la_SOURCES = \
63 tpm12/tpm_delegate.c \
67 tpm12/tpm_identity.c \
69 tpm12/tpm_libtpms_io.c \
73 tpm12/tpm_migration.c \
76 tpm12/tpm_openssl_helpers.c \
79 tpm12/tpm_permanent.c \
80 tpm12/tpm_platform.c \
84 tpm12/tpm_sizedbuffer.c \
90 tpm12/tpm_transport.c \
92 tpm12/tpm_svnrevision.c \
93 tpm_tpm12_interface.c \
100 tpm12/tpm_commands.h \
101 tpm12/tpm_constants.h \
102 tpm12/tpm_counter.h \
104 tpm12/tpm_cryptoh.h \
107 tpm12/tpm_delegate.h \
110 tpm12/tpm_identity.h \
115 tpm_library_intern.h \
118 tpm12/tpm_migration.h \
121 tpm12/tpm_nvram_const.h \
123 tpm12/tpm_openssl_helpers.h \
126 tpm12/tpm_permanent.h \
127 tpm12/tpm_platform.h \
128 tpm12/tpm_process.h \
130 tpm12/tpm_session.h \
131 tpm12/tpm_sizedbuffer.h \
132 tpm12/tpm_startup.h \
133 tpm12/tpm_storage.h \
135 tpm12/tpm_structures.h \
136 tpm12/tpm_svnrevision.h \
139 tpm12/tpm_transport.h \
142 if LIBTPMS_USE_FREEBL
144 libtpms_tpm12_la_SOURCES += tpm12/tpm_crypto_freebl.c
145 libtpms_tpm12_la_LIBADD += -lfreebl -lgmp -lnspr4 -lnssutil3 -lnss3
147 #work-around broken freebl includes
148 libtpms_tpm12_la_CFLAGS += $(shell [ ! -r /usr/include/nss3/alghmac.h ] && \
151 # tpm12/tpm_crypto_freebl.c: work around #include "blapi.h" : should be <nss3/blapi.h>
152 libtpms_tpm12_la_CFLAGS += $(shell nss-config --cflags)
153 #including nss3/blapi.h requires a look into nspr4 dir
154 libtpms_tpm12_la_CFLAGS += $(shell nspr-config --cflags)
158 if LIBTPMS_USE_OPENSSL
160 libtpms_tpm12_la_SOURCES += tpm12/tpm_crypto.c
161 libtpms_tpm12_la_LIBADD += -lcrypto
163 endif # LIBTPMS_USE_OPENSSL
165 endif # LIBTPMS_USE_FREEBL
172 noinst_LTLIBRARIES += libtpms_tpm2.la
174 libtpms_la_LIBADD += libtpms_tpm2.la
176 libtpms_tpm2_la_LIBADD = $(LIBRT_LIBS)
178 libtpms_tpm2_la_CFLAGS = $(common_CFLAGS)
180 libtpms_tpm2_la_CFLAGS += -D_POSIX_
181 libtpms_tpm2_la_CFLAGS += -DTPM_POSIX
183 libtpms_tpm2_la_SOURCES = \
186 tpm2/AlgorithmCap.c \
187 tpm2/AlgorithmTests.c \
188 tpm2/AsymmetricCommands.c \
189 tpm2/AttestationCommands.c \
191 tpm2/AuditCommands.c \
197 tpm2/CapabilityCommands.c \
199 tpm2/ClockCommands.c \
200 tpm2/CommandAudit.c \
201 tpm2/CommandCodeAttributes.c \
202 tpm2/CommandDispatcher.c \
203 tpm2/ContextCommands.c \
205 tpm2/CryptEccData.c \
206 tpm2/CryptSelfTest.c \
209 tpm2/DebugHelpers.c \
210 tpm2/DictionaryCommands.c \
211 tpm2/DuplicationCommands.c \
213 tpm2/EncryptDecrypt_spt.c \
216 tpm2/EphemeralCommands.c \
220 tpm2/HashCommands.c \
222 tpm2/HierarchyCommands.c \
223 tpm2/IntegrityCommands.c \
226 tpm2/LocalityPlat.c \
227 tpm2/ManagementCommands.c \
230 tpm2/MathOnByteBuffers.c \
238 tpm2/ObjectCommands.c \
242 tpm2/PlatformData.c \
250 tpm2/RandomCommands.c \
252 tpm2/ResponseCodeProcessing.c \
255 tpm2/SessionCommands.c \
256 tpm2/SessionProcess.c \
257 tpm2/SigningCommands.c \
258 tpm2/StartupCommands.c \
259 tpm2/SymmetricCommands.c \
260 tpm2/TestingCommands.c \
264 tpm2/TpmSizeChecks.c \
269 tpm2/Vendor_TCG_Test.c \
273 tpm_tpm2_interface.c \
276 tpm2/BackwardsCompatibilityObject.c \
277 tpm2/LibtpmsCallbacks.c \
279 tpm2/StateMarshal.c \
284 tpm2/crypto/CryptCmac_fp.h \
285 tpm2/crypto/CryptDes_fp.h \
286 tpm2/crypto/CryptEcc.h \
287 tpm2/crypto/CryptEccCrypt_fp.h \
288 tpm2/crypto/CryptEccKeyExchange_fp.h \
289 tpm2/crypto/CryptEccMain_fp.h \
290 tpm2/crypto/CryptEccSignature_fp.h \
291 tpm2/crypto/CryptHash_fp.h \
292 tpm2/crypto/CryptHash.h \
293 tpm2/crypto/CryptPrime_fp.h \
294 tpm2/crypto/CryptPrimeSieve_fp.h \
295 tpm2/crypto/CryptRand_fp.h \
296 tpm2/crypto/CryptRand.h \
297 tpm2/crypto/CryptRsa_fp.h \
298 tpm2/crypto/CryptRsa.h \
299 tpm2/crypto/CryptSelfTest_fp.h \
300 tpm2/crypto/CryptSmac_fp.h \
301 tpm2/crypto/CryptSym.h \
302 tpm2/crypto/CryptSym_fp.h \
303 tpm2/crypto/CryptTest.h \
304 tpm2/crypto/CryptUtil_fp.h \
307 tpm2/ACT_SetTimeout_fp.h \
308 tpm2/ActivateCredential_fp.h \
309 tpm2/AlgorithmCap_fp.h \
310 tpm2/AlgorithmTests_fp.h \
311 tpm2/Attest_spt_fp.h \
314 tpm2/Capabilities.h \
315 tpm2/CertifyCreation_fp.h \
316 tpm2/CertifyX509_fp.h \
318 tpm2/ChangeEPS_fp.h \
319 tpm2/ChangePPS_fp.h \
320 tpm2/ClearControl_fp.h \
322 tpm2/ClockRateAdjust_fp.h \
324 tpm2/CommandAttributeData.h \
325 tpm2/CommandAttributes.h \
326 tpm2/CommandAudit_fp.h \
327 tpm2/CommandCodeAttributes_fp.h \
328 tpm2/CommandDispatchData.h \
329 tpm2/CommandDispatcher_fp.h \
331 tpm2/CompilerDependencies.h \
332 tpm2/ContextLoad_fp.h \
333 tpm2/ContextSave_fp.h \
334 tpm2/Context_spt_fp.h \
336 tpm2/CreateLoaded_fp.h \
337 tpm2/CreatePrimary_fp.h \
338 tpm2/CryptSelfTest_fp.h \
340 tpm2/DebugHelpers_fp.h \
341 tpm2/DictionaryAttackLockReset_fp.h \
342 tpm2/DictionaryAttackParameters_fp.h \
343 tpm2/Duplicate_fp.h \
345 tpm2/ECC_Parameters_fp.h \
346 tpm2/ECDH_KeyGen_fp.h \
347 tpm2/ECDH_ZGen_fp.h \
348 tpm2/EC_Ephemeral_fp.h \
349 tpm2/EncryptDecrypt2_fp.h \
350 tpm2/EncryptDecrypt_fp.h \
351 tpm2/EncryptDecrypt_spt_fp.h \
353 tpm2/EventSequenceComplete_fp.h \
354 tpm2/EvictControl_fp.h \
355 tpm2/ExecCommand_fp.h \
356 tpm2/FlushContext_fp.h \
357 tpm2/GetCapability_fp.h \
358 tpm2/GetCommandAuditDigest_fp.h \
359 tpm2/GetRandom_fp.h \
360 tpm2/GetSessionAuditDigest_fp.h \
361 tpm2/GetTestResult_fp.h \
367 tpm2/HashSequenceStart_fp.h \
368 tpm2/HashTestData.h \
369 tpm2/HierarchyChangeAuth_fp.h \
370 tpm2/HierarchyControl_fp.h \
371 tpm2/Hierarchy_fp.h \
373 tpm2/HMAC_Start_fp.h \
375 tpm2/IncrementalSelfTest_fp.h \
376 tpm2/InternalRoutines.h \
377 tpm2/IoBuffers_fp.h \
379 tpm2/LoadExternal_fp.h \
383 tpm2/MAC_Start_fp.h \
384 tpm2/MakeCredential_fp.h \
385 tpm2/Manufacture_fp.h \
387 tpm2/MathOnByteBuffers_fp.h \
390 tpm2/NV_Certify_fp.h \
391 tpm2/NV_ChangeAuth_fp.h \
392 tpm2/NV_DefineSpace_fp.h \
393 tpm2/NVDynamic_fp.h \
394 tpm2/NV_Extend_fp.h \
395 tpm2/NV_GlobalWriteLock_fp.h \
397 tpm2/NV_Increment_fp.h \
399 tpm2/NV_ReadLock_fp.h \
400 tpm2/NV_ReadPublic_fp.h \
401 tpm2/NVReserved_fp.h \
402 tpm2/NV_SetBits_fp.h \
404 tpm2/NV_UndefineSpace_fp.h \
405 tpm2/NV_UndefineSpaceSpecial_fp.h \
407 tpm2/NV_WriteLock_fp.h \
409 tpm2/ObjectChangeAuth_fp.h \
411 tpm2/Object_spt_fp.h \
412 tpm2/PCR_Allocate_fp.h \
413 tpm2/PCR_Event_fp.h \
414 tpm2/PCR_Extend_fp.h \
417 tpm2/PCR_Reset_fp.h \
418 tpm2/PCR_SetAuthPolicy_fp.h \
419 tpm2/PCR_SetAuthValue_fp.h \
422 tpm2/PlatformACT_fp.h \
423 tpm2/PlatformClock.h \
424 tpm2/PlatformData.h \
426 tpm2/PolicyAuthorize_fp.h \
427 tpm2/PolicyAuthorizeNV_fp.h \
428 tpm2/PolicyAuthValue_fp.h \
429 tpm2/PolicyCommandCode_fp.h \
430 tpm2/PolicyCounterTimer_fp.h \
431 tpm2/PolicyCpHash_fp.h \
432 tpm2/PolicyDuplicationSelect_fp.h \
433 tpm2/PolicyGetDigest_fp.h \
434 tpm2/PolicyLocality_fp.h \
435 tpm2/PolicyNameHash_fp.h \
437 tpm2/PolicyNvWritten_fp.h \
439 tpm2/PolicyPassword_fp.h \
440 tpm2/PolicyPCR_fp.h \
441 tpm2/PolicyPhysicalPresence_fp.h \
442 tpm2/PolicyRestart_fp.h \
443 tpm2/PolicySecret_fp.h \
444 tpm2/PolicySigned_fp.h \
445 tpm2/Policy_spt_fp.h \
446 tpm2/PolicyTemplate_fp.h \
447 tpm2/PolicyTicket_fp.h \
449 tpm2/PP_Commands_fp.h \
451 tpm2/PRNG_TestVectors.h \
452 tpm2/PropertyCap_fp.h \
454 tpm2/ReadClock_fp.h \
455 tpm2/ReadPublic_fp.h \
456 tpm2/ResponseCodeProcessing_fp.h \
460 tpm2/RSA_Decrypt_fp.h \
461 tpm2/RSA_Encrypt_fp.h \
464 tpm2/SequenceComplete_fp.h \
465 tpm2/SequenceUpdate_fp.h \
467 tpm2/SessionProcess_fp.h \
468 tpm2/SetAlgorithmSet_fp.h \
469 tpm2/SetCommandCodeAuditStatus_fp.h \
470 tpm2/SetPrimaryPolicy_fp.h \
473 tpm2/Simulator_fp.h \
474 tpm2/StartAuthSession_fp.h \
476 tpm2/StirRandom_fp.h \
477 tpm2/SupportLibraryFunctionPrototypes_fp.h \
478 tpm2/SymmetricTest.h \
479 tpm2/SymmetricTestData.h \
481 tpm2/TcpServerPosix_fp.h \
482 tpm2/TestParms_fp.h \
486 tpm2/TpmAlgorithmDefines.h \
489 tpm2/TpmBuildSwitches.h \
494 tpm2/_TPM_Hash_Data_fp.h \
495 tpm2/_TPM_Hash_End_fp.h \
496 tpm2/_TPM_Hash_Start_fp.h \
497 tpm2/_TPM_Init_fp.h \
498 tpm2/TpmSizeChecks_fp.h \
499 tpm2/TpmTcpProtocol.h \
501 tpm2/Unmarshal_fp.h \
503 tpm2/VendorString.h \
504 tpm2/Vendor_TCG_Test_fp.h \
505 tpm2/VerifySignature_fp.h \
510 tpm2/ZGen_2Phase_fp.h \
512 tpm2/BackwardsCompatibility.h \
513 tpm2/BackwardsCompatibilityObject.h \
514 tpm2/LibtpmsCallbacks.h \
516 tpm2/StateMarshal.h \
520 if LIBTPMS_USE_OPENSSL
522 libtpms_tpm2_la_SOURCES += \
523 tpm2/crypto/openssl/CryptCmac.c \
524 tpm2/crypto/openssl/CryptDes.c \
525 tpm2/crypto/openssl/CryptEccKeyExchange.c \
526 tpm2/crypto/openssl/CryptEccMain.c \
527 tpm2/crypto/openssl/CryptEccSignature.c \
528 tpm2/crypto/openssl/CryptHash.c \
529 tpm2/crypto/openssl/CryptPrime.c \
530 tpm2/crypto/openssl/CryptPrimeSieve.c \
531 tpm2/crypto/openssl/CryptRand.c \
532 tpm2/crypto/openssl/CryptRsa.c \
533 tpm2/crypto/openssl/CryptSmac.c \
534 tpm2/crypto/openssl/CryptSym.c \
535 tpm2/crypto/openssl/ExpDCache.c \
536 tpm2/crypto/openssl/Helpers.c \
537 tpm2/crypto/openssl/TpmToOsslDesSupport.c \
538 tpm2/crypto/openssl/TpmToOsslMath.c \
539 tpm2/crypto/openssl/TpmToOsslSupport.c
542 tpm2/crypto/openssl/ConsttimeUtils.h \
543 tpm2/crypto/openssl/BnConvert_fp.h \
544 tpm2/crypto/openssl/BnMath_fp.h \
545 tpm2/crypto/openssl/BnMemory_fp.h \
546 tpm2/crypto/openssl/BnValues.h \
547 tpm2/crypto/openssl/ExpDCache_fp.h \
548 tpm2/crypto/openssl/Helpers_fp.h \
549 tpm2/crypto/openssl/LibSupport.h \
550 tpm2/crypto/openssl/TpmToOsslDesSupport_fp.h \
551 tpm2/crypto/openssl/TpmToOsslHash.h \
552 tpm2/crypto/openssl/TpmToOsslMath_fp.h \
553 tpm2/crypto/openssl/TpmToOsslMath.h \
554 tpm2/crypto/openssl/TpmToOsslSupport_fp.h \
555 tpm2/crypto/openssl/TpmToOsslSym.h
557 libtpms_tpm2_la_CFLAGS += \
559 -I $(srcdir)/tpm2/crypto \
560 -I $(srcdir)/tpm2/crypto/openssl
562 endif # LIBTPMS_USE_OPENSSL
570 libtpms_la_SOURCES = \
576 libtpms_la_CFLAGS = $(common_CFLAGS)
578 libtpms_la_LDFLAGS = -version-info $(LIBTPMS_VERSION_INFO) \
579 -no-undefined $(AM_LDFLAGS)
581 if HAVE_VERSION_SCRIPT
582 libtpms_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libtpms.syms
585 LDFLAGS_ARCH = $(findstring -m32, $(AM_CFLAGS))
586 LDFLAGS_ARCH += $(findstring -m64, $(AM_CFLAGS))
587 LDFLAGS_ARCH += $(findstring -m32, $(AM_LDFLAGS))
588 LDFLAGS_ARCH += $(findstring -m64, $(AM_LDFLAGS))
590 check-local: SHELL?="/usr/bin/env bash"
592 @case $(host_os) in \
593 openbsd*) ADDLIBS="-lc" ;; \
594 darwin*|freebsd*) LDFLAGS_OS="-shared" ;; \
597 ($(CC) $$LDFLAGS_OS $(LDFLAGS_ARCH) -nostdlib -L./.libs -ltpms $$ADDLIBS 2>/dev/null || \
598 (echo "There are undefined symbols in libtpms ($$LDFLAGS_OS $(LDFLAGS_ARCH))";\
599 $(CC) $$LDFLAGS_OS $(LDFLAGS_ARCH) -nostdlib -L./.libs -ltpms $$ADDLIBS 2>&1 | grep libtpms))
600 @case $(host_os) in \
601 openbsd*) ADDLIBS="-lc" ;; \
602 darwin*|freebsd*) LDFLAGS_OS="-shared" ;; \
605 $(CC) $$LDFLAGS_OS $(LDFLAGS_ARCH) -nostdlib -L./.libs -ltpms $$ADDLIBS 2>/dev/null
609 tpm12/tpm_crypto_freebl.c \
625 tpm2/crypto/openssl/*.gcov \
626 tpm2/crypto/openssl/*.gcda \
627 tpm2/crypto/openssl/*.gcno