Makefile.manifest 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. SGX_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
  2. RUNTIME_DIR = $(SGX_DIR)/../../../../Runtime
  3. LIBPAL = $(RUNTIME_DIR)/libpal-Linux-SGX.so
  4. SGX_SIGNER_KEY ?= $(SGX_DIR)/signer/enclave-key.pem
  5. SGX_SIGN = $(SGX_DIR)/signer/pal-sgx-sign -libpal $(LIBPAL) -key $(SGX_SIGNER_KEY)
  6. SGX_GET_TOKEN = $(SGX_DIR)/signer/pal-sgx-get-token
  7. # sgx manifest.sgx/sig/token
  8. drop_manifest_suffix = $(filter-out manifest,$(sort $(patsubst %.manifest,%,$(1))))
  9. expand_target_to_token = $(addsuffix .token,$(call drop_manifest_suffix,$(1)))
  10. expand_target_to_sig = $(addsuffix .sig,$(call drop_manifest_suffix,$(1)))
  11. expand_target_to_sgx = $(addsuffix .manifest.sgx,$(call drop_manifest_suffix,$(1)))
  12. $(SGX_SIGNER_KEY):
  13. $(error "Cannot find any enclave key. Generate $(abspath $(SGX_SIGNER_KEY)) or specify 'SGX_SIGNER_KEY=' with make")
  14. %.token: %.sig
  15. $(call cmd,sgx_get_token)
  16. %.sig %.manifest.sgx: %.manifest % %.manifest.sgx.d
  17. $(call cmd,sgx_sign_exec)
  18. %.sig %.manifest.sgx: manifest % %.manifest.sgx.d
  19. $(call cmd,sgx_sign_exec)
  20. %.sig %.manifest.sgx: %.manifest %.manifest.sgx.d
  21. $(call cmd,sgx_sign)
  22. .PRECIOUS: %.manifest.sgx.d
  23. %.manifest.sgx.d: %.manifest
  24. $(call cmd,sgx_sign_depend_exec)
  25. %.manifest.sgx.d: manifest
  26. $(call cmd,sgx_sign_depend)
  27. # It is possible to have an SGX manifest without main executable: manifest may not have
  28. # loader.exec but only preloaded libraries. There is no good way to distinguish this rule
  29. # from the above rule. Since manifests without main executables are very rare, these cases
  30. # use static pattern rules in the corresponding Makefiles (e.g., in Pal/regression).
  31. # %.manifest.sgx.d: %.manifest
  32. # $(call cmd,sgx_sign_depend)
  33. ifeq ($(filter %clean,$(MAKECMDGOALS)),)
  34. ifeq ($(target),)
  35. $(error define "target" variable for manifest.sgx dependency calculation)
  36. endif
  37. include $(addsuffix .manifest.sgx.d,$(call drop_manifest_suffix,$(target)))
  38. endif