Makefile 3.7 KB

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