1 2# Copyright 2015 The Chromium OS Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6obj ?= ./build 7CROSS_COMPILE ?= 8CC ?= $(CROSS_COMPILE)gcc 9AR ?= $(CROSS_COMPILE)ar 10 11HOST_SOURCES = 12SOURCES = ActivateCredential.c 13SOURCES += AlgorithmCap.c 14SOURCES += Attest_spt.c 15SOURCES += Bits.c 16SOURCES += Cancel.c 17SOURCES += Certify.c 18SOURCES += CertifyCreation.c 19SOURCES += ChangeEPS.c 20SOURCES += ChangePPS.c 21SOURCES += Clear.c 22SOURCES += ClearControl.c 23SOURCES += Clock.c 24SOURCES += ClockRateAdjust.c 25SOURCES += ClockSet.c 26SOURCES += CommandAudit.c 27SOURCES += CommandCodeAttributes.c 28SOURCES += CommandDispatcher.c 29SOURCES += Commit.c 30SOURCES += ContextLoad.c 31SOURCES += ContextSave.c 32SOURCES += Context_spt.c 33HOST_SOURCES += CpriCryptPri.c 34HOST_SOURCES += CpriECC.c 35HOST_SOURCES += CpriHash.c 36HOST_SOURCES += CpriMisc.c 37HOST_SOURCES += CpriRNG.c 38HOST_SOURCES += CpriRSA.c 39HOST_SOURCES += CpriSym.c 40SOURCES += Create.c 41SOURCES += CreatePrimary.c 42SOURCES += CryptSelfTest.c 43SOURCES += CryptUtil.c 44SOURCES += DA.c 45SOURCES += DRTM.c 46SOURCES += DictionaryAttackLockReset.c 47SOURCES += DictionaryAttackParameters.c 48SOURCES += Duplicate.c 49SOURCES += ECC_Parameters.c 50SOURCES += ECDH_KeyGen.c 51SOURCES += ECDH_ZGen.c 52SOURCES += EC_Ephemeral.c 53SOURCES += EncryptDecrypt.c 54SOURCES += Entity.c 55HOST_SOURCES += Entropy.c 56SOURCES += EventSequenceComplete.c 57SOURCES += EvictControl.c 58SOURCES += ExecCommand.c 59SOURCES += FieldUpgradeData.c 60SOURCES += FieldUpgradeStart.c 61SOURCES += FirmwareRead.c 62SOURCES += FlushContext.c 63SOURCES += GetCapability.c 64SOURCES += GetCommandAuditDigest.c 65SOURCES += GetCommandCodeString.c 66SOURCES += GetRandom.c 67SOURCES += GetSessionAuditDigest.c 68SOURCES += GetTestResult.c 69SOURCES += GetTime.c 70SOURCES += Global.c 71SOURCES += HMAC.c 72SOURCES += HMAC_Start.c 73SOURCES += Handle.c 74SOURCES += HandleProcess.c 75SOURCES += Hash.c 76SOURCES += HashSequenceStart.c 77SOURCES += Hierarchy.c 78SOURCES += HierarchyChangeAuth.c 79SOURCES += HierarchyControl.c 80SOURCES += Import.c 81SOURCES += IncrementalSelfTest.c 82SOURCES += Load.c 83SOURCES += LoadExternal.c 84SOURCES += Locality.c 85SOURCES += LocalityPlat.c 86SOURCES += MakeCredential.c 87SOURCES += Marshal_ActivateCredential.c 88SOURCES += Marshal_Certify.c 89SOURCES += Marshal_CertifyCreation.c 90SOURCES += Marshal_ChangeEPS.c 91SOURCES += Marshal_ChangePPS.c 92SOURCES += Marshal_Clear.c 93SOURCES += Marshal_ClearControl.c 94SOURCES += Marshal_ClockRateAdjust.c 95SOURCES += Marshal_ClockSet.c 96SOURCES += Marshal_Commit.c 97SOURCES += Marshal_ContextLoad.c 98SOURCES += Marshal_ContextSave.c 99SOURCES += Marshal_Create.c 100SOURCES += Marshal_CreatePrimary.c 101SOURCES += Marshal_DictionaryAttackLockReset.c 102SOURCES += Marshal_DictionaryAttackParameters.c 103SOURCES += Marshal_Duplicate.c 104SOURCES += Marshal_ECC_Parameters.c 105SOURCES += Marshal_ECDH_KeyGen.c 106SOURCES += Marshal_ECDH_ZGen.c 107SOURCES += Marshal_EC_Ephemeral.c 108SOURCES += Marshal_EncryptDecrypt.c 109SOURCES += Marshal_EventSequenceComplete.c 110SOURCES += Marshal_EvictControl.c 111SOURCES += Marshal_FieldUpgradeData.c 112SOURCES += Marshal_FieldUpgradeStart.c 113SOURCES += Marshal_FirmwareRead.c 114SOURCES += Marshal_FlushContext.c 115SOURCES += Marshal_GetCapability.c 116SOURCES += Marshal_GetCommandAuditDigest.c 117SOURCES += Marshal_GetRandom.c 118SOURCES += Marshal_GetSessionAuditDigest.c 119SOURCES += Marshal_GetTestResult.c 120SOURCES += Marshal_GetTime.c 121SOURCES += Marshal_HMAC.c 122SOURCES += Marshal_HMAC_Start.c 123SOURCES += Marshal_Hash.c 124SOURCES += Marshal_HashSequenceStart.c 125SOURCES += Marshal_HierarchyChangeAuth.c 126SOURCES += Marshal_HierarchyControl.c 127SOURCES += Marshal_Import.c 128SOURCES += Marshal_IncrementalSelfTest.c 129SOURCES += Marshal_Load.c 130SOURCES += Marshal_LoadExternal.c 131SOURCES += Marshal_MakeCredential.c 132SOURCES += Marshal_NV_Certify.c 133SOURCES += Marshal_NV_ChangeAuth.c 134SOURCES += Marshal_NV_DefineSpace.c 135SOURCES += Marshal_NV_Extend.c 136SOURCES += Marshal_NV_GlobalWriteLock.c 137SOURCES += Marshal_NV_Increment.c 138SOURCES += Marshal_NV_Read.c 139SOURCES += Marshal_NV_ReadLock.c 140SOURCES += Marshal_NV_ReadPublic.c 141SOURCES += Marshal_NV_SetBits.c 142SOURCES += Marshal_NV_UndefineSpace.c 143SOURCES += Marshal_NV_UndefineSpaceSpecial.c 144SOURCES += Marshal_NV_Write.c 145SOURCES += Marshal_NV_WriteLock.c 146SOURCES += Marshal_ObjectChangeAuth.c 147SOURCES += Marshal_PCR_Allocate.c 148SOURCES += Marshal_PCR_Event.c 149SOURCES += Marshal_PCR_Extend.c 150SOURCES += Marshal_PCR_Read.c 151SOURCES += Marshal_PCR_Reset.c 152SOURCES += Marshal_PCR_SetAuthPolicy.c 153SOURCES += Marshal_PCR_SetAuthValue.c 154SOURCES += Marshal_PP_Commands.c 155SOURCES += Marshal_PolicyAuthValue.c 156SOURCES += Marshal_PolicyAuthorize.c 157SOURCES += Marshal_PolicyCommandCode.c 158SOURCES += Marshal_PolicyCounterTimer.c 159SOURCES += Marshal_PolicyCpHash.c 160SOURCES += Marshal_PolicyDuplicationSelect.c 161SOURCES += Marshal_PolicyGetDigest.c 162SOURCES += Marshal_PolicyLocality.c 163SOURCES += Marshal_PolicyNV.c 164SOURCES += Marshal_PolicyNameHash.c 165SOURCES += Marshal_PolicyNvWritten.c 166SOURCES += Marshal_PolicyOR.c 167SOURCES += Marshal_PolicyPCR.c 168SOURCES += Marshal_PolicyPassword.c 169SOURCES += Marshal_PolicyPhysicalPresence.c 170SOURCES += Marshal_PolicyRestart.c 171SOURCES += Marshal_PolicySecret.c 172SOURCES += Marshal_PolicySigned.c 173SOURCES += Marshal_PolicyTicket.c 174SOURCES += Marshal_Quote.c 175SOURCES += Marshal_RSA_Decrypt.c 176SOURCES += Marshal_RSA_Encrypt.c 177SOURCES += Marshal_ReadClock.c 178SOURCES += Marshal_ReadPublic.c 179SOURCES += Marshal_Rewrap.c 180SOURCES += Marshal_SelfTest.c 181SOURCES += Marshal_SequenceComplete.c 182SOURCES += Marshal_SequenceUpdate.c 183SOURCES += Marshal_SetAlgorithmSet.c 184SOURCES += Marshal_SetCommandCodeAuditStatus.c 185SOURCES += Marshal_SetPrimaryPolicy.c 186SOURCES += Marshal_Shutdown.c 187SOURCES += Marshal_Sign.c 188SOURCES += Marshal_StartAuthSession.c 189SOURCES += Marshal_Startup.c 190SOURCES += Marshal_StirRandom.c 191SOURCES += Marshal_TestParms.c 192SOURCES += Marshal_Unseal.c 193SOURCES += Marshal_VerifySignature.c 194SOURCES += Marshal_ZGen_2Phase.c 195SOURCES += Manufacture.c 196SOURCES += MathFunctions.c 197SOURCES += MemoryLib.c 198SOURCES += NV.c 199HOST_SOURCES += NVMem.c 200SOURCES += NV_Certify.c 201SOURCES += NV_ChangeAuth.c 202SOURCES += NV_DefineSpace.c 203SOURCES += NV_Extend.c 204SOURCES += NV_GlobalWriteLock.c 205SOURCES += NV_Increment.c 206SOURCES += NV_Read.c 207SOURCES += NV_ReadLock.c 208SOURCES += NV_ReadPublic.c 209SOURCES += NV_SetBits.c 210SOURCES += NV_UndefineSpace.c 211SOURCES += NV_UndefineSpaceSpecial.c 212SOURCES += NV_Write.c 213SOURCES += NV_WriteLock.c 214SOURCES += NV_spt.c 215SOURCES += Object.c 216SOURCES += ObjectChangeAuth.c 217SOURCES += Object_spt.c 218SOURCES += PCR.c 219SOURCES += PCR_Allocate.c 220SOURCES += PCR_Event.c 221SOURCES += PCR_Extend.c 222SOURCES += PCR_Read.c 223SOURCES += PCR_Reset.c 224SOURCES += PCR_SetAuthPolicy.c 225SOURCES += PCR_SetAuthValue.c 226SOURCES += PP.c 227SOURCES += PPPlat.c 228SOURCES += PP_Commands.c 229SOURCES += PlatformData.c 230SOURCES += PolicyAuthValue.c 231SOURCES += PolicyAuthorize.c 232SOURCES += PolicyCommandCode.c 233SOURCES += PolicyCounterTimer.c 234SOURCES += PolicyCpHash.c 235SOURCES += PolicyDuplicationSelect.c 236SOURCES += PolicyGetDigest.c 237SOURCES += PolicyLocality.c 238SOURCES += PolicyNV.c 239SOURCES += PolicyNameHash.c 240SOURCES += PolicyNvWritten.c 241SOURCES += PolicyOR.c 242SOURCES += PolicyPCR.c 243SOURCES += PolicyPassword.c 244SOURCES += PolicyPhysicalPresence.c 245SOURCES += PolicyRestart.c 246SOURCES += PolicySecret.c 247SOURCES += PolicySigned.c 248SOURCES += PolicyTicket.c 249SOURCES += Policy_spt.c 250SOURCES += Power.c 251SOURCES += PowerPlat.c 252SOURCES += PropertyCap.c 253SOURCES += Quote.c 254HOST_SOURCES += RSAData.c 255HOST_SOURCES += RSAKeySieve.c 256SOURCES += RSA_Decrypt.c 257SOURCES += RSA_Encrypt.c 258SOURCES += ReadClock.c 259SOURCES += ReadPublic.c 260SOURCES += Rewrap.c 261SOURCES += SelfTest.c 262SOURCES += SequenceComplete.c 263SOURCES += SequenceUpdate.c 264SOURCES += Session.c 265SOURCES += SessionProcess.c 266SOURCES += SetAlgorithmSet.c 267SOURCES += SetCommandCodeAuditStatus.c 268SOURCES += SetPrimaryPolicy.c 269SOURCES += Shutdown.c 270SOURCES += Sign.c 271SOURCES += StartAuthSession.c 272SOURCES += Startup.c 273SOURCES += StirRandom.c 274#SOURCES += TPMCmdp.c 275#SOURCES += TPMCmds.c 276#SOURCES += TcpServer.c 277SOURCES += TestParms.c 278SOURCES += Ticket.c 279SOURCES += Time.c 280SOURCES += TpmFail.c 281SOURCES += Unique.c 282SOURCES += Unseal.c 283SOURCES += VerifySignature.c 284SOURCES += ZGen_2Phase.c 285SOURCES += _TPM_Hash_Data.c 286SOURCES += _TPM_Hash_End.c 287SOURCES += _TPM_Hash_Start.c 288SOURCES += _TPM_Init.c 289SOURCES += tpm_generated.c 290 291# Use V=1 for verbose output 292ifeq ($(V),) 293Q := @ 294else 295Q := 296endif 297 298ifeq ($(EMBEDDED_MODE),) 299SOURCES += $(HOST_SOURCES) 300CFLAGS += -Wall -Werror -fPIC 301else 302SOURCES += stubs_ecc.c 303SOURCES += stubs_hash.c 304SOURCES += stubs_sym.c 305CFLAGS += -DEMBEDDED_MODE 306# Configure system headers appropriately. 307CFLAGS += -DTHIRD_PARTY 308ifneq ($(ROOTDIR),) 309CFLAGS += -I$(ROOTDIR) 310endif 311endif 312 313# Caller may specify OBJ_PREFIX to prefix all object filenames in the 314# archive with a common string. This allows the caller's linker 315# script to group the data and bss sections for this library in one 316# place. For example, if OBJ_PREFIX=Tpm2_, the caller's linker script 317# can have something like 318# 319# __bss_libtpm2_start = .; 320# Tpm2_*(.bss) 321# __bss_libtpm2_end = .; 322# 323# Using a unique prefix is necessary in this case because files in 324# archives only have a filename, not a full path. 325OBJS = $(patsubst %.c,$(obj)/$(OBJ_PREFIX)%.o,$(SOURCES)) 326DEPS = $(patsubst %.c,$(obj)/$(OBJ_PREFIX)%.d,$(SOURCES)) 327 328# This is the default target 329$(obj)/libtpm2.a: $(OBJS) 330 @echo " AR $(notdir $@)" 331 $(Q)$(AR) scr $@ $^ 332 333$(obj): 334 @echo " MKDIR $(obj)" 335 $(Q)mkdir -p $(obj) 336 337$(obj)/$(OBJ_PREFIX)%.d $(obj)/$(OBJ_PREFIX)%.o: %.c | $(obj) 338 @echo " CC $(notdir $<)" 339 $(Q)$(CC) $(CFLAGS) -c -MMD -MF $(basename $@).d -o $(basename $@).o $< 340 341.PHONY: clean 342clean: 343 @echo " RM $(obj)" 344 $(Q)rm -rf $(obj) 345 346ifneq ($(MAKECMDGOALS),clean) 347-include $(DEPS) 348endif 349