Makefile 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. include ../../../../Makefile.configs
  2. include Makefile.am
  3. ias_cert_url ?= https://certificates.trustedservices.intel.com/Intel_SGX_Attestation_RootCA.pem
  4. ias_cert_file = quote/$(notdir $(ias_cert_url))
  5. CFLAGS += -I. -Iinclude -I../.. -I../../../include -I../../../lib -Isgx-driver
  6. ASFLAGS += -I. -I../.. -I../../../include
  7. host_files = libpal-Linux-SGX.a pal-sgx debugger/sgx_gdb.so pal.map generated_offsets.py
  8. defs = -DIN_PAL -DPAL_DIR=$(PAL_DIR) -DRUNTIME_DIR=$(RUNTIME_DIR)
  9. CFLAGS += $(defs)
  10. ASFLAGS += $(defs)
  11. enclave-objs = $(addprefix db_,files devices pipes sockets streams memory \
  12. threading mutex events process object main rtld \
  13. exception misc ipc spinlock) \
  14. $(addprefix enclave_,ocalls ecalls framework platform pages untrusted)
  15. enclave-asm-objs = enclave_entry
  16. urts-objs = $(addprefix sgx_,enclave framework platform main rtld thread process exception graphene) \
  17. quote/aesm.pb-c
  18. urts-asm-objs = sgx_entry
  19. graphene_lib = .lib/graphene-lib.a
  20. .PHONY: all
  21. all: $(host_files)
  22. ifeq ($(DEBUG),1)
  23. CC += -gdwarf-2 -g3
  24. CFLAGS += -DDEBUG
  25. ASFLAGS += -DDEBUG
  26. export DEBUG
  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. pal-sgx: $(addsuffix .o,$(urts-objs) $(urts-asm-objs)) $(graphene_lib)
  50. @echo [ host/Linux-SGX/$@ ]
  51. @$(CC) $(CFLAGS) -Wl,-z,relro,-z,now -pie $^ -lc -pthread -lprotobuf-c -o $@
  52. quote/aesm.pb-c.o: quote/aesm.pb-c.c quote/aesm.pb-c.h
  53. quote/aesm.pb-c.c quote/aesm.pb-c.h: quote/aesm.proto
  54. @echo [ host/Linux-SGX/quote/aesm.pb-c.c ]
  55. @echo [ host/Linux-SGX/quote/aesm.pb-c.h ]
  56. @protoc-c --c_out=. $<
  57. quote/generated-cacert.h: $(ias_cert_file)
  58. @echo "#define IAS_CA_CERT \"$(shell cat $< | tr -d '[\r\n]')\"" > $@
  59. $(ias_cert_file):
  60. @wget $(ias_cert_url) -O $@
  61. debugger/sgx_gdb.so: debugger/sgx_gdb.c debugger/sgx_gdb.h sgx_arch.h
  62. @echo [ host/Linux-SGX/$@ ]
  63. $(CC) -MD -MP -Wall -fPIC -O2 -std=c11 -c debugger/sgx_gdb.c -o debugger/sgx_gdb.o
  64. $(LD) -shared debugger/sgx_gdb.o -o debugger/sgx_gdb.so -lc
  65. enclave_entry.o sgx_entry.o: asm-offsets.h
  66. sgx-driver/isgx_version.h:
  67. $(MAKE) -C sgx-driver $(notdir $<)
  68. include $(wildcard *.d) $(wildcard debugger/*.d)
  69. include ../../../../Makefile.rules
  70. CLEAN_FILES += $(notdir $(pal_static) $(pal_lib) $(pal_loader))
  71. CLEAN_FILES += debugger/sgx_gdb.o
  72. CLEAN_FILES += quote/aesm.pb-c.c quote/aesm.pb-c.h quote/aesm.pb-c.d quote/aesm.pb-c.o
  73. CLEAN_FILES += $(ias_cert_file) quote/generated-cacert.h
  74. .PHONY: clean
  75. clean:
  76. rm -rf *.o *.e *.i *.s $(host_files) $(CLEAN_FILES) *.d debugger/*.d signer/*.pyc __pycache__ \
  77. signer/__pycache__
  78. .PHONY: test
  79. test: