Makefile.Test 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. expand_target_to_token = $(foreach t,$(filter-out manifest,$(1)),$(patsubst %.manifest,%,$(t)).token)
  8. %.token: %.sig
  9. $(call cmd,sgx_get_token)
  10. expand_target = $(1) $(foreach t,$(filter-out manifest,$(1)), \
  11. $(patsubst %.manifest,%,$(t)).manifest.sgx)
  12. $(SGX_SIGNER_KEY):
  13. $(error "Cannot find any enclave key. Generate $(abspath $(SGX_SIGNER_KEY)) or specify 'SGX_SIGNER_KEY=' with make")
  14. %.sig %.manifest.sgx: %.manifest % $(LIBPAL) $(SGX_SIGNER_KEY) %.manifest.sgx.d
  15. $(call cmd,sgx_sign_exec)
  16. %.sig %.manifest.sgx: manifest % $(LIBPAL) $(SGX_SIGNER_KEY) %.manifest.sgx.d
  17. $(call cmd,sgx_sign_exec)
  18. %.sig %.manifest.sgx: %.manifest $(LIBPAL) $(SGX_SIGNER_KEY) %.manifest.sgx.d
  19. $(call cmd,sgx_sign)
  20. .PRECIOUS: %.manifest.sgx.d
  21. %.manifest.sgx.d: %.manifest
  22. $(call cmd,sgx_sign_depend_exec)
  23. %.manifest.sgx.d: manifest
  24. $(call cmd,sgx_sign_depend_exec)
  25. # It is possible to have an SGX manifest without main executable: manifest may not have
  26. # loader.exec but only preloaded libraries. There is no good way to distinguish this rule
  27. # from the above rule. Since manifests without main executables are very rare, these cases
  28. # use static pattern rules in the corresponding Makefiles (e.g., in Pal/regression).
  29. # %.manifest.sgx.d: %.manifest
  30. # $(call cmd,sgx_sign_depend)