Makefile 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. include ../../Scripts/Makefile.configs
  2. include ../../Scripts/Makefile.rules
  3. CFLAGS += -fno-builtin -nostdlib \
  4. -I../include/pal -I../include/lib -I../src
  5. preloads = \
  6. Preload1.so \
  7. Preload2.so
  8. executables = \
  9. ..Bootstrap \
  10. Attestation \
  11. AtomicMath \
  12. AvxDisable \
  13. Bootstrap \
  14. Bootstrap2 \
  15. Bootstrap3 \
  16. Bootstrap7 \
  17. Directory \
  18. Event \
  19. Exception \
  20. Exit \
  21. File \
  22. Hex \
  23. Memory \
  24. Misc \
  25. Pipe \
  26. Process \
  27. Process2 \
  28. Process3 \
  29. Semaphore \
  30. SendHandle \
  31. Socket \
  32. Symbols \
  33. Thread \
  34. Thread2 \
  35. normalize_path
  36. manifests = \
  37. manifest \
  38. Attestation.manifest \
  39. AvxDisable.manifest \
  40. Bootstrap2.manifest \
  41. Bootstrap3.manifest \
  42. Bootstrap4.manifest \
  43. Bootstrap5.manifest \
  44. Bootstrap6.manifest \
  45. Bootstrap7.manifest \
  46. File.manifest \
  47. Process.manifest \
  48. Process2.manifest \
  49. Process3.manifest \
  50. SendHandle.manifest \
  51. Thread2.manifest \
  52. nonelf_binary.manifest
  53. target = $(executables) $(manifests)
  54. include ../../Scripts/Makefile.manifest
  55. graphene_lib = .lib/graphene-lib.a
  56. pal_lib = ../../Runtime/libpal-$(PAL_HOST).so
  57. RUNTIME_DIR = $(CURDIR)/../../Runtime
  58. ifneq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  59. $(error unsupported platform. $(SYS))
  60. endif
  61. .PHONY: all
  62. all: $(target) $(call expand_target_to_sig,$(target)) $(call expand_target_to_sgx,$(target)) $(preloads)
  63. .PHONY: sgx-tokens
  64. sgx-tokens: $(call expand_target_to_token,$(target))
  65. # To enable tests for remote attestation, please provide RA_CLIENT_SPID and RA_CLIENT_KEY
  66. # in the environment variables.
  67. # To obtain a SPID, register in the Intel API portal:
  68. # https://api.portal.trustedservices.intel.com/EPID-attestation
  69. manifest_rules = \
  70. -e 's:\$$(PAL):$(abspath ../../Runtime/pal_loader):g' \
  71. -e 's:\$$(PWD):$(shell pwd)/:g' \
  72. -e 's:\$$(RA_CLIENT_SPID):$(RA_CLIENT_SPID):g' \
  73. -e 's:\$$(RA_CLIENT_KEY):$(RA_CLIENT_KEY):g' \
  74. -e 's:\$$(RA_CLIENT_LINKABLE):$(if $(RA_CLIENT_LINKABLE),$(RA_CLIENT_LINKABLE),0):g'
  75. .PHONY: crt_init-recurse
  76. crt_init-recurse:
  77. $(MAKE) -C ../crt_init all
  78. ../crt_init/user_shared_start.o ../crt_init/user_start.o: crt_init-recurse
  79. @true
  80. CFLAGS-AvxDisable += -mavx
  81. # workaround: File.manifest.template has strange reference
  82. # to ../regression/File
  83. ../regression/File: | File
  84. @true
  85. LDLIBS-preloads = ../crt_init/user_shared_start.o $(graphene_lib) $(pal_lib)
  86. $(preloads): CFLAGS += -shared -fPIC
  87. $(preloads): LDLIBS = $(LDLIBS-preloads)
  88. $(preloads): %.so: %.c $(LDLIBS-preloads)
  89. $(call cmd,csingle)
  90. LDLIBS-executables = ../crt_init/user_start.o $(graphene_lib) $(pal_lib) $(preloads)
  91. $(executables): CFLAGS += -no-pie
  92. $(executables): LDLIBS = $(LDLIBS-executables)
  93. $(executables): %: %.c $(LDLIBS-executables)
  94. $(call cmd,csingle)
  95. ifeq ($(filter %clean,$(MAKECMDGOALS)),)
  96. include $(wildcard *.d)
  97. ifeq ($(SGX), 1)
  98. # Bootstrap5.manifest doesn't have main executable, but only preloaded
  99. # libraries. Static pattern rule is needed to override the implicit pattern
  100. # rule defined in Pal/src/host/Linux-SGX/Makefile.Test.
  101. Bootstrap5.manifest.sgx.d: %.manifest.sgx.d: %.manifest
  102. $(call cmd,sgx_sign_depend)
  103. endif
  104. endif
  105. $(graphene_lib):
  106. $(MAKE) -C ../lib target=$(abspath .lib)/
  107. export PAL_LOADER = $(RUNTIME_DIR)/pal-$(PAL_HOST)
  108. export PYTHONPATH=../../Scripts
  109. .PHONY: regression
  110. regression:
  111. $(RM) pal-regression.xml
  112. $(MAKE) pal-regression.xml
  113. pal-regression.xml: test_pal.py $(target) $(call expand_target_to_sig,$(target)) $(call expand_target_to_sgx,$(target)) $(call expand_target_to_token,$(target))
  114. python3 -m pytest --junit-xml $@ -v $<
  115. .PHONY: clean
  116. clean:
  117. $(RM) -r $(target) $(preloads) *.tmp .lib *.cached *.sig .*.sig *.d .*.d .output.* *.token .*.token *.manifest.sgx .*.manifest.sgx __pycache__ .cache pal-regression.xml
  118. .PHONY: distclean
  119. distclean: clean