Makefile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 = $(addprefix db_,files devices pipes eventfd sockets streams memory \
  15. threading mutex events process object main rtld \
  16. exception misc) \
  17. $(addprefix enclave_,ocalls ecalls framework platform pages untrusted xstate)
  18. enclave-asm-objs = enclave_entry
  19. urts-objs = $(addprefix sgx_,enclave framework platform main rtld thread process exception graphene) \
  20. quote/aesm.pb-c clone-x86_64
  21. urts-asm-objs = sgx_entry
  22. graphene_lib = .lib/graphene-lib.a
  23. .PHONY: all
  24. all: sgx-driver/isgx_version.h $(host_files)
  25. libpal-Linux-SGX.a: $(addsuffix .o,$(enclave-objs) $(enclave-asm-objs))
  26. $(call cmd,ar_a_o)
  27. $(addsuffix .o,$(enclave-objs)): CFLAGS += -DIN_ENCLAVE
  28. $(addsuffix .i,$(enclave-objs)): CFLAGS += -DIN_ENCLAVE
  29. $(addsuffix .s,$(enclave-objs)): CFLAGS += -DIN_ENCLAVE
  30. $(addsuffix .o,$(enclave-asm-objs)): ASFLAGS += -DIN_ENCLAVE
  31. $(addsuffix .s,$(enclave-asm-objs)): ASFLAGS += -DIN_ENCLAVE
  32. $(addsuffix .o,$(urts-objs)): quote/aesm.pb-c.h
  33. $(addsuffix .o,$(enclave-objs)): quote/generated-cacert.h
  34. %.o: %.c
  35. $(call cmd,cc_o_c)
  36. %.i: %.c
  37. $(call cmd,cpp_i_c)
  38. %.s: %.c
  39. $(call cmd,cc_s_c)
  40. %.o: %.S
  41. $(call cmd,as_o_S)
  42. %.s: %.S
  43. $(call cmd,cpp_s_S)
  44. CFLAGS-pal-sgx = -Wl,-z,relro,-z,now -pie
  45. LDLIBS-pal-sgx += -lprotobuf-c
  46. pal-sgx: $(addsuffix .o,$(urts-objs) $(urts-asm-objs)) $(graphene_lib)
  47. $(call cmd,cmulti)
  48. quote/aesm.pb-c.o: quote/aesm.pb-c.c quote/aesm.pb-c.h
  49. quote/aesm.pb-c.c quote/aesm.pb-c.h: quote/aesm.proto
  50. @echo [ host/Linux-SGX/quote/aesm.pb-c.c ]
  51. @echo [ host/Linux-SGX/quote/aesm.pb-c.h ]
  52. @protoc-c --c_out=. $<
  53. quote/generated-cacert.h: $(ias_cert_file)
  54. @echo "#define IAS_CA_CERT \"$(shell cat $< | tr -d '[\r\n]')\"" > $@
  55. $(ias_cert_file):
  56. @../../../../Scripts/download --output $@ --url $(ias_cert_url) --sha256 $(ias_cert_sha256)
  57. debugger/sgx_gdb.so: CFLAGS =
  58. CFLAGS-debugger/sgx_gdb.so = -shared -Wall -fPIC -O2 -std=c11
  59. debugger/sgx_gdb.so: debugger/sgx_gdb.c
  60. $(call cmd,csingle)
  61. enclave_entry.o sgx_entry.o: asm-offsets.h
  62. sgx-driver/isgx_version.h:
  63. $(MAKE) -C sgx-driver $(notdir $@)
  64. ifeq ($(filter %clean,$(MAKECMDGOALS)),)
  65. include $(wildcard *.d) $(wildcard debugger/*.d)
  66. endif
  67. include ../../../../Scripts/Makefile.rules
  68. CLEAN_FILES += $(notdir $(pal_static) $(pal_lib) $(pal_loader))
  69. CLEAN_FILES += debugger/sgx_gdb.so
  70. CLEAN_FILES += quote/aesm.pb-c.c quote/aesm.pb-c.h quote/aesm.pb-c.d quote/aesm.pb-c.o
  71. CLEAN_FILES += quote/generated-cacert.h
  72. .PHONY: clean_
  73. clean_:
  74. $(RM) -r *.o *.e *.i *.s $(host_files) $(CLEAN_FILES) *.d debugger/*.d signer/*.pyc __pycache__ \
  75. signer/__pycache__
  76. .PHONY: clean
  77. clean: clean_
  78. $(MAKE) -C sgx-driver $@
  79. .PHONY: distclean
  80. distclean: clean_
  81. $(RM) $(ias_cert_file)
  82. $(MAKE) -C sgx-driver $@
  83. .PHONY: test
  84. test: