Makefile 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. include ../../../../Makefile.configs
  2. include Makefile.am
  3. CFLAGS += -I. -Iinclude -I../.. -I../../../include -I../../../lib -Isgx-driver
  4. ASFLAGS += -I. -I../.. -I../../../include
  5. host_files = libpal-Linux-SGX.a pal-sgx debugger/sgx_gdb.so generated_offsets.py
  6. defs = -DIN_PAL -DPAL_DIR=$(PAL_DIR) -DRUNTIME_DIR=$(RUNTIME_DIR)
  7. CFLAGS += $(defs)
  8. ASFLAGS += $(defs)
  9. enclave-objs = $(addprefix db_,files devices pipes sockets streams memory \
  10. threading mutex events process object main rtld \
  11. exception misc ipc spinlock) \
  12. $(addprefix enclave_,ocalls ecalls framework pages untrusted)
  13. enclave-asm-objs = enclave_entry
  14. urts-objs = $(addprefix sgx_,enclave framework main rtld thread process exception graphene)
  15. urts-asm-objs = sgx_entry
  16. graphene_lib = .lib/graphene-lib.a
  17. .PHONY: all
  18. all: $(host_files)
  19. ifeq ($(DEBUG),1)
  20. CC += -gdwarf-2 -g3
  21. CFLAGS += -DDEBUG
  22. ASFLAGS += -DDEBUG
  23. export DEBUG
  24. endif
  25. ../../host_endian.h: host_endian.h
  26. $(MAKE) -C ../../ $<
  27. libpal-Linux-SGX.a: $(addsuffix .o,$(enclave-objs) $(enclave-asm-objs))
  28. $(call cmd,ar_a_o)
  29. $(addsuffix .o,$(enclave-objs)): CFLAGS += -DIN_ENCLAVE
  30. $(addsuffix .o,$(enclave-objs)): %.o: %.c
  31. $(call cmd,cc_o_c)
  32. $(addsuffix .i,$(enclave-objs)): CFLAGS += -DIN_ENCLAVE
  33. $(addsuffix .i,$(enclave-objs)): %.i: %.c
  34. $(call cmd,cpp_i_c)
  35. $(addsuffix .s,$(enclave-objs)): CFLAGS += -DIN_ENCLAVE
  36. $(addsuffix .s,$(enclave-objs)): %.s: %.c
  37. $(call cmd,cc_s_c)
  38. $(addsuffix .o,$(enclave-asm-objs)): ASFLAGS += -DIN_ENCLAVE
  39. $(addsuffix .o,$(enclave-asm-objs)): %.o: %.S
  40. $(call cmd,as_o_S)
  41. $(addsuffix .s,$(enclave-asm-objs)): ASFLAGS += -DIN_ENCLAVE
  42. $(addsuffix .s,$(enclave-asm-objs)): %.s: %.S
  43. $(call cmd,cpp_s_S)
  44. $(addsuffix .o,$(urts-objs)): %.o: %.c
  45. $(call cmd,cc_o_c)
  46. $(addsuffix .i,$(urts-objs)): %.i: %.c
  47. $(call cmd,cpp_i_c)
  48. $(addsuffix .s,$(urts-objs)): %.s: %.c
  49. $(call cmd,cc_s_c)
  50. $(addsuffix .s,$(urts-asm-objs)): %.s: %.S
  51. $(call cmd,cpp_s_S)
  52. $(addsuffix .o,$(urts-asm-objs)): %.o: %.S
  53. $(call cmd,as_o_S)
  54. pal-sgx: $(addsuffix .o,$(urts-objs) $(urts-asm-objs)) $(graphene_lib)
  55. @echo [ host/Linux-SGX/$@ ]
  56. @$(CC) $(CFLAGS) -Wl,-z,relro,-z,now -pie $^ -lc -pthread -o $@
  57. debugger/sgx_gdb.so: debugger/sgx_gdb.c debugger/sgx_gdb.h sgx_arch.h
  58. @echo [ host/Linux-SGX/$@ ]
  59. $(CC) -MD -MP -Wall -fPIC -O2 -std=c11 -c debugger/sgx_gdb.c -o debugger/sgx_gdb.o
  60. $(LD) -shared debugger/sgx_gdb.o -o debugger/sgx_gdb.so -lc
  61. enclave_entry.o sgx_entry.o: asm-offsets.h
  62. sgx-driver/isgx_version.h:
  63. $(MAKE) -C sgx-driver $(notdir $<)
  64. include $(wildcard *.d) $(wildcard debugger/*.d)
  65. include ../../../../Makefile.rules
  66. CLEAN_FILES += $(notdir $(pal_static) $(pal_lib) $(pal_loader))
  67. CLEAN_FILES += debugger/sgx_gdb.o
  68. .PHONY: clean
  69. clean:
  70. rm -f *.o *.e *.i *.s $(host_files) $(CLEAN_FILES) *.d debugger/*.d
  71. .PHONY: test
  72. test: