Makefile 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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: $(call expand_target,$(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. export DEBUG
  54. ifeq ($(WERROR),1)
  55. CFLAGS += -Werror
  56. endif
  57. # To enable tests for remote attestation, please provide RA_CLIENT_SPID and RA_CLIENT_KEY
  58. # in the environment variables.
  59. # To obtain a SPID, register in the Intel API portal:
  60. # https://api.portal.trustedservices.intel.com/EPID-attestation
  61. manifest_rules = \
  62. -e 's:\$$(PAL):$(abspath ../../Runtime/pal_loader):g' \
  63. -e 's:\$$(PWD):$(shell pwd)/:g' \
  64. -e 's:\$$(RA_CLIENT_SPID):$(RA_CLIENT_SPID):g' \
  65. -e 's:\$$(RA_CLIENT_KEY):$(RA_CLIENT_KEY):g' \
  66. -e 's:\$$(RA_CLIENT_LINKABLE):$(if $(RA_CLIENT_LINKABLE),$(RA_CLIENT_LINKABLE),0):g' \
  67. $(extra_rules)
  68. manifest: manifest.template
  69. $(call cmd,manifest,$(manifest_rules))
  70. %.manifest: %.manifest.template $(executables) $(pal_lib)
  71. $(call cmd,manifest,$(manifest_rules))
  72. ../src/user_shared_start.o ../src/user_start.o: ../src/user_start.S
  73. $(MAKE) -C ../src $(notdir $@)
  74. CFLAGS-AvxDisable += -mavx
  75. # workaround: File.manifest.template has strange reference
  76. # to ../regression/File
  77. ../regression/File: | File
  78. @true
  79. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  80. LDLIBS-preloads = ../src/user_shared_start.o $(graphene_lib) $(pal_lib)
  81. $(preloads): CFLAGS += -shared -fPIC
  82. $(preloads): LDLIBS = $(LDLIBS-preloads)
  83. $(preloads): %.so: %.c $(LDLIBS-preloads)
  84. $(call cmd,csingle)
  85. LDLIBS-executables = ../src/user_start.o $(graphene_lib) $(pal_lib) $(preloads)
  86. $(executables): CFLAGS += -no-pie
  87. $(executables): LDLIBS = $(LDLIBS-executables)
  88. $(executables): %: %.c $(LDLIBS-executables)
  89. $(call cmd,csingle)
  90. ifeq ($(filter %clean,$(MAKECMDGOALS)),)
  91. include $(wildcard *.d)
  92. ifeq ($(SGX), 1)
  93. # Bootstrap5.manifest doesn't have main executable, but only preloaded
  94. # libraries. Static pattern rule is needed to override the implicit pattern
  95. # rule defined in Pal/src/host/Linux-SGX/Makefile.Test.
  96. Bootstrap5.manifest.sgx.d: %.manifest.sgx.d: %.manifest
  97. $(call cmd,sgx_sign_depend)
  98. include $(addsuffix .manifest.sgx.d,$(executables))
  99. endif
  100. endif
  101. .lib/host_endian.h: ../src/host/$(PAL_HOST)/host_endian.h
  102. @mkdir -p .lib
  103. cp -f $< $@
  104. $(graphene_lib): .lib/host_endian.h
  105. $(MAKE) -C ../lib target=$(abspath .lib)/
  106. else
  107. .IGNORE: $(preloads) $(executables)
  108. $(preloads) $(executables):
  109. endif
  110. export PYTHONPATH=../../Scripts
  111. .PHONY: regression
  112. regression:
  113. $(RM) pal-regression.xml
  114. $(MAKE) pal-regression.xml
  115. pal-regression.xml: test_pal.py $(call expand_target_to_token,$(target))
  116. python3 -m pytest --junit-xml $@ -v $<
  117. .PHONY: clean
  118. clean:
  119. rm -rf $(call expand_target,$(target)) $(preloads) *.tmp .lib *.cached *.sig *.d .output.* *.token .*.d .*.sig .*.token __pycache__ .cache pal-regression.xml
  120. .PHONY: distclean
  121. distclean: clean