Makefile 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. include ../../../../Scripts/Makefile.configs
  2. include Makefile.am
  3. ias_cert_url ?= https://certificates.trustedservices.intel.com/Intel_SGX_Attestation_RootCA.pem
  4. ias_cert_sha256 ?= e7b9113b647bc6bd421d4f140076a3acc31e410e01bf12883841e824cdaf1564
  5. ias_cert_file = quote/$(notdir $(ias_cert_url))
  6. CFLAGS += -I. -Iinclude -I../.. -I../../../include -I../../../include/pal \
  7. -I../../../lib/crypto/mbedtls/include -I../../../include/host/Linux-SGX \
  8. -I../../../include/lib -Isgx-driver
  9. ASFLAGS += -I. -I../.. -I../../../include
  10. host_files = libpal-Linux-SGX.a pal-sgx debugger/sgx_gdb.so pal.map generated_offsets.py
  11. defs = -DIN_PAL -DPAL_DIR=$(PAL_DIR) -DRUNTIME_DIR=$(RUNTIME_DIR)
  12. CFLAGS += $(defs)
  13. ASFLAGS += $(defs)
  14. enclave-objs = \
  15. db_devices.o \
  16. db_eventfd.o \
  17. db_events.o \
  18. db_exception.o \
  19. db_files.o \
  20. db_main.o \
  21. db_memory.o \
  22. db_misc.o \
  23. db_mutex.o \
  24. db_object.o \
  25. db_pipes.o \
  26. db_process.o \
  27. db_rtld.o \
  28. db_sockets.o \
  29. db_streams.o \
  30. db_threading.o \
  31. enclave_ecalls.o \
  32. enclave_framework.o \
  33. enclave_ocalls.o \
  34. enclave_pages.o \
  35. enclave_platform.o \
  36. enclave_untrusted.o \
  37. enclave_xstate.o
  38. enclave-asm-objs = enclave_entry.o
  39. urts-objs = \
  40. clone-x86_64.o \
  41. sgx_enclave.o \
  42. sgx_exception.o \
  43. sgx_framework.o \
  44. sgx_graphene.o \
  45. sgx_main.o \
  46. sgx_platform.o \
  47. sgx_process.o \
  48. sgx_rtld.o \
  49. sgx_thread.o \
  50. quote/aesm.pb-c.o
  51. urts-asm-objs = sgx_entry.o
  52. graphene_lib = .lib/graphene-lib.a
  53. .PHONY: all
  54. all: sgx-driver/sgx.h $(host_files)
  55. libpal-Linux-SGX.a: $(enclave-objs) $(enclave-asm-objs)
  56. $(call cmd,ar_a_o)
  57. $(enclave-objs): CFLAGS += -DIN_ENCLAVE
  58. $(patsubst %.o,%.i,$(enclave-objs)): CFLAGS += -DIN_ENCLAVE
  59. $(patsubst %.o,%.s,$(enclave-objs)): CFLAGS += -DIN_ENCLAVE
  60. $(enclave-asm-objs): ASFLAGS += -DIN_ENCLAVE
  61. $(patsubst %.o,%.s,$(enclave-asm-objs)): ASFLAGS += -DIN_ENCLAVE
  62. $(urts-objs): quote/aesm.pb-c.h
  63. $(enclave-objs): quote/generated-cacert.h
  64. %.o: %.c
  65. $(call cmd,cc_o_c)
  66. %.i: %.c
  67. $(call cmd,cpp_i_c)
  68. %.s: %.c
  69. $(call cmd,cc_s_c)
  70. %.o: %.S
  71. $(call cmd,as_o_S)
  72. %.s: %.S
  73. $(call cmd,cpp_s_S)
  74. CFLAGS-pal-sgx = -Wl,-z,relro,-z,now -pie
  75. LDLIBS-pal-sgx += -lprotobuf-c
  76. pal-sgx: $(urts-objs) $(urts-asm-objs) $(graphene_lib)
  77. $(call cmd,cmulti)
  78. quote/aesm.pb-c.o: quote/aesm.pb-c.c quote/aesm.pb-c.h
  79. quote/aesm.pb-c.c quote/aesm.pb-c.h: quote/aesm.proto
  80. @echo [ host/Linux-SGX/quote/aesm.pb-c.c ]
  81. @echo [ host/Linux-SGX/quote/aesm.pb-c.h ]
  82. @protoc-c --c_out=. $<
  83. quote/generated-cacert.h: $(ias_cert_file)
  84. @echo "#define IAS_CA_CERT \"$(shell cat $< | tr -d '[\r\n]')\"" > $@
  85. $(ias_cert_file):
  86. @../../../../Scripts/download --output $@ --url $(ias_cert_url) --sha256 $(ias_cert_sha256)
  87. debugger/sgx_gdb.so: CFLAGS =
  88. CFLAGS-debugger/sgx_gdb.so = -shared -Wall -fPIC -O2 -std=c11
  89. debugger/sgx_gdb.so: debugger/sgx_gdb.c
  90. $(call cmd,csingle)
  91. enclave_entry.o sgx_entry.o: asm-offsets.h
  92. sgx-driver/sgx.h:
  93. $(MAKE) -C sgx-driver $(notdir $@)
  94. ifeq ($(filter %clean,$(MAKECMDGOALS)),)
  95. include $(wildcard *.d) $(wildcard debugger/*.d)
  96. endif
  97. include ../../../../Scripts/Makefile.rules
  98. CLEAN_FILES += $(notdir $(pal_static) $(pal_lib) $(pal_loader))
  99. CLEAN_FILES += debugger/sgx_gdb.so
  100. CLEAN_FILES += quote/aesm.pb-c.c quote/aesm.pb-c.h quote/aesm.pb-c.d quote/aesm.pb-c.o
  101. CLEAN_FILES += quote/generated-cacert.h
  102. .PHONY: clean_
  103. clean_:
  104. $(RM) -r *.o *.e *.i *.s $(host_files) $(CLEAN_FILES) *.d debugger/*.d signer/*.pyc __pycache__ \
  105. signer/__pycache__
  106. .PHONY: clean
  107. clean: clean_
  108. $(MAKE) -C sgx-driver $@
  109. .PHONY: distclean
  110. distclean: clean_
  111. $(RM) $(ias_cert_file)
  112. $(MAKE) -C sgx-driver $@
  113. .PHONY: test
  114. test: