Makefile 3.6 KB

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