Makefile 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. headers = $(wildcard *.h) $(wildcard ../../*.h) $(wildcard ../../../lib/*.h) \
  18. $(addprefix sgx-driver/,graphene-sgx.h isgx_version.h)
  19. .PHONY: all
  20. all: $(host_files)
  21. ifeq ($(DEBUG),1)
  22. CC += -gdwarf-2 -g3
  23. CFLAGS += -DDEBUG
  24. ASFLAGS += -DDEBUG
  25. export DEBUG
  26. endif
  27. ../../host_endian.h: host_endian.h
  28. $(MAKE) -C ../../ $<
  29. libpal-Linux-SGX.a: $(addsuffix .o,$(enclave-objs) $(enclave-asm-objs))
  30. $(call cmd,ar_a_o)
  31. $(addsuffix .o,$(enclave-objs)): CFLAGS += -DIN_ENCLAVE
  32. $(addsuffix .o,$(enclave-objs)): %.o: %.c $(headers)
  33. $(call cmd,cc_o_c)
  34. $(addsuffix .i,$(enclave-objs)): CFLAGS += -DIN_ENCLAVE
  35. $(addsuffix .i,$(enclave-objs)): %.i: %.c $(headers)
  36. $(call cmd,cpp_i_c)
  37. $(addsuffix .s,$(enclave-objs)): CFLAGS += -DIN_ENCLAVE
  38. $(addsuffix .s,$(enclave-objs)): %.s: %.c $(headers)
  39. $(call cmd,cc_s_c)
  40. $(addsuffix .o,$(enclave-asm-objs)): ASFLAGS += -DIN_ENCLAVE
  41. $(addsuffix .o,$(enclave-asm-objs)): %.o: %.S $(headers)
  42. $(call cmd,as_o_S)
  43. $(addsuffix .s,$(enclave-asm-objs)): ASFLAGS += -DIN_ENCLAVE
  44. $(addsuffix .s,$(enclave-asm-objs)): %.s: %.S $(headers)
  45. $(call cmd,cpp_s_S)
  46. $(addsuffix .o,$(urts-objs)): %.o: %.c $(headers)
  47. $(call cmd,cc_o_c)
  48. $(addsuffix .i,$(urts-objs)): %.i: %.c $(headers)
  49. $(call cmd,cpp_i_c)
  50. $(addsuffix .s,$(urts-objs)): %.s: %.c $(headers)
  51. $(call cmd,cc_s_c)
  52. $(addsuffix .s,$(urts-asm-objs)): %.s: %.S $(headers)
  53. $(call cmd,cpp_s_S)
  54. $(addsuffix .o,$(urts-asm-objs)): %.o: %.S $(headers)
  55. $(call cmd,as_o_S)
  56. pal-sgx: $(addsuffix .o,$(urts-objs) $(urts-asm-objs)) $(graphene_lib)
  57. @echo [ host/Linux-SGX/$@ ]
  58. @$(CC) $(CFLAGS) -Wl,-z,relro,-z,now -pie $^ -lc -pthread -o $@
  59. debugger/sgx_gdb.so: debugger/sgx_gdb.c debugger/sgx_gdb.h sgx_arch.h
  60. @echo [ host/Linux-SGX/$@ ]
  61. $(CC) -Wall -fPIC -O2 -std=c11 -c debugger/sgx_gdb.c -o debugger/sgx_gdb.o
  62. $(LD) -shared debugger/sgx_gdb.o -o debugger/sgx_gdb.so -lc
  63. enclave_entry.o sgx_entry.o: asm-offsets.h
  64. sgx-driver/isgx_version.h:
  65. $(MAKE) -C sgx-driver $(notdir $<)
  66. include ../../../../Makefile.rules
  67. CLEAN_FILES += $(notdir $(pal_static) $(pal_lib) $(pal_loader))
  68. CLEAN_FILES += debugger/sgx_gdb.o
  69. .PHONY: clean
  70. clean:
  71. rm -f *.o *.e *.i *.s $(host_files) $(CLEAN_FILES)