Makefile 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 = $(patsubst %.c,%,$(wildcard *.so.c))
  6. executables = $(filter-out $(preloads),$(patsubst %.c,%,$(wildcard *.c))) ..Bootstrap
  7. manifests = manifest $(patsubst %.manifest.template,%.manifest,$(wildcard *.manifest.template))
  8. target = $(executables) $(manifests)
  9. graphene_lib = .lib/graphene-lib.a
  10. pal_lib = ../../Runtime/libpal-$(PAL_HOST).so
  11. .PHONY: default
  12. default: all
  13. include ../../Makefile.configs
  14. include ../../Makefile.rules
  15. include ../src/Makefile.Test
  16. RUNTIME_DIR = $(CURDIR)/../../Runtime
  17. export PAL_LOADER = $(RUNTIME_DIR)/pal-$(PAL_HOST)
  18. .PHONY: all
  19. all: $(call expand_target,$(target)) $(preloads)
  20. ifeq ($(DEBUG),1)
  21. CC += -g
  22. endif
  23. export DEBUG
  24. ifeq ($(WERROR),1)
  25. CFLAGS += -Werror
  26. endif
  27. # To enable tests for remote attestation, please provide RA_CLIENT_SPID and RA_CLIENT_KEY
  28. # in the environment variables.
  29. # To obtain a SPID, register in the Intel API portal:
  30. # https://api.portal.trustedservices.intel.com/EPID-attestation
  31. manifest_rules = \
  32. -e 's:\$$(PAL):$(abspath ../../Runtime/pal_loader):g' \
  33. -e 's:\$$(PWD):$(shell pwd)/:g' \
  34. -e 's:\$$(RA_CLIENT_SPID):$(RA_CLIENT_SPID):g' \
  35. -e 's:\$$(RA_CLIENT_KEY):$(RA_CLIENT_KEY):g' \
  36. -e 's:\$$(RA_CLIENT_LINKABLE):$(if $(RA_CLIENT_LINKABLE),$(RA_CLIENT_LINKABLE),0):g' \
  37. $(extra_rules)
  38. manifest: manifest.template
  39. sed $(manifest_rules) $< >$@
  40. %.manifest: %.manifest.template $(executables) $(pal_lib)
  41. sed $(manifest_rules) $< >$@
  42. (grep -q "#\!" $@ && chmod +x $@) || true
  43. ../src/user_shared_start.o ../src/user_start.o: ../src/user_start.S
  44. $(MAKE) -C ../src $(notdir $@)
  45. CFLAGS-AvxDisable += -mavx
  46. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  47. LDLIBS-preloads = ../src/user_shared_start.o $(graphene_lib) $(pal_lib)
  48. $(preloads): CFLAGS += -shared -fPIC
  49. $(preloads): LDLIBS = $(LDLIBS-preloads)
  50. $(preloads): %.so: %.so.c $(LDLIBS-preloads)
  51. $(call cmd,csingle)
  52. LDLIBS-executables = ../src/user_start.o $(graphene_lib) $(pal_lib) $(preloads)
  53. $(executables): CFLAGS += -no-pie
  54. $(executables): LDLIBS = $(LDLIBS-executables)
  55. $(executables): %: %.c $(LDLIBS-executables)
  56. $(call cmd,csingle)
  57. include $(wildcard *.d)
  58. ifeq ($(filter clean,$(MAKECMDGOALS)),)
  59. ifeq ($(SGX), 1)
  60. include $(addsuffix .manifest.sgx.d,$(executables))
  61. endif
  62. endif
  63. .lib/host_endian.h: ../src/host/$(PAL_HOST)/host_endian.h
  64. @mkdir -p .lib
  65. cp -f $< $@
  66. $(graphene_lib): .lib/host_endian.h
  67. $(MAKE) -C ../lib target=$(abspath .lib)/
  68. Process2.manifest.sgx: Bootstrap.manifest.sgx
  69. else
  70. .IGNORE: $(preloads) $(executables)
  71. $(preloads) $(executables):
  72. endif
  73. export PYTHONPATH=../../Scripts
  74. .PHONY: regression
  75. regression:
  76. $(RM) pal-regression.xml
  77. $(MAKE) pal-regression.xml
  78. pal-regression.xml: test_pal.py $(call expand_target,$(target))
  79. python3 -m pytest --junit-xml $@ -v test_pal.py
  80. .PHONY: clean
  81. clean:
  82. rm -rf $(call expand_target,$(target)) $(preloads) *.tmp .lib *.cached *.sig *.d .output.*