Makefile 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. include ../../Scripts/Makefile.configs
  2. include ../src/Makefile.Host
  3. include ../../Scripts/Makefile.rules
  4. CFLAGS = -Wall -O2 -std=c11 -fno-builtin -nostdlib \
  5. -I../include/pal -I../lib -I../src
  6. preloads = \
  7. Preload1.so \
  8. Preload2.so
  9. executables = \
  10. ..Bootstrap \
  11. Attestation \
  12. AtomicMath \
  13. AvxDisable \
  14. Bootstrap \
  15. Bootstrap2 \
  16. Bootstrap3 \
  17. Bootstrap7 \
  18. Directory \
  19. Event \
  20. Exception \
  21. Exit \
  22. File \
  23. Hex \
  24. Memory \
  25. Misc \
  26. Pipe \
  27. Process \
  28. Process2 \
  29. Process3 \
  30. Semaphore \
  31. SendHandle \
  32. Socket \
  33. Symbols \
  34. Thread \
  35. Thread2 \
  36. normalize_path
  37. manifests = manifest $(patsubst %.manifest.template,%.manifest,$(wildcard *.manifest.template))
  38. target = $(executables) $(manifests)
  39. include ../../Scripts/Makefile.manifest
  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. ../src/user_shared_start.o ../src/user_start.o: ../src/user_start.S
  68. $(MAKE) -C ../src $(notdir $@)
  69. CFLAGS-AvxDisable += -mavx
  70. # workaround: File.manifest.template has strange reference
  71. # to ../regression/File
  72. ../regression/File: | File
  73. @true
  74. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  75. LDLIBS-preloads = ../src/user_shared_start.o $(graphene_lib) $(pal_lib)
  76. $(preloads): CFLAGS += -shared -fPIC
  77. $(preloads): LDLIBS = $(LDLIBS-preloads)
  78. $(preloads): %.so: %.c $(LDLIBS-preloads)
  79. $(call cmd,csingle)
  80. LDLIBS-executables = ../src/user_start.o $(graphene_lib) $(pal_lib) $(preloads)
  81. $(executables): CFLAGS += -no-pie
  82. $(executables): LDLIBS = $(LDLIBS-executables)
  83. $(executables): %: %.c $(LDLIBS-executables)
  84. $(call cmd,csingle)
  85. ifeq ($(filter %clean,$(MAKECMDGOALS)),)
  86. include $(wildcard *.d)
  87. ifeq ($(SGX), 1)
  88. # Bootstrap5.manifest doesn't have main executable, but only preloaded
  89. # libraries. Static pattern rule is needed to override the implicit pattern
  90. # rule defined in Pal/src/host/Linux-SGX/Makefile.Test.
  91. Bootstrap5.manifest.sgx.d: %.manifest.sgx.d: %.manifest
  92. $(call cmd,sgx_sign_depend)
  93. endif
  94. endif
  95. .lib/host_endian.h: ../src/host/$(PAL_HOST)/host_endian.h
  96. @mkdir -p .lib
  97. cp -f $< $@
  98. $(graphene_lib): .lib/host_endian.h
  99. $(MAKE) -C ../lib target=$(abspath .lib)/
  100. else
  101. .IGNORE: $(preloads) $(executables)
  102. $(preloads) $(executables):
  103. endif
  104. export PYTHONPATH=../../Scripts
  105. .PHONY: regression
  106. regression:
  107. $(RM) pal-regression.xml
  108. $(MAKE) pal-regression.xml
  109. 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))
  110. python3 -m pytest --junit-xml $@ -v $<
  111. .PHONY: clean
  112. clean:
  113. $(RM) -r $(target) $(preloads) *.tmp .lib *.cached *.sig .*.sig *.d .*.d .output.* *.token .*.token *.manifest.sgx .*.manifest.sgx __pycache__ .cache pal-regression.xml
  114. .PHONY: distclean
  115. distclean: clean