Makefile 3.8 KB

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