Makefile 3.4 KB

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