Makefile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 pal.map 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 .i,$(enclave-objs)): CFLAGS += -DIN_ENCLAVE
  31. $(addsuffix .s,$(enclave-objs)): CFLAGS += -DIN_ENCLAVE
  32. $(addsuffix .o,$(enclave-asm-objs)): ASFLAGS += -DIN_ENCLAVE
  33. $(addsuffix .s,$(enclave-asm-objs)): ASFLAGS += -DIN_ENCLAVE
  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. pal-sgx: $(addsuffix .o,$(urts-objs) $(urts-asm-objs)) $(graphene_lib)
  45. @echo [ host/Linux-SGX/$@ ]
  46. @$(CC) $(CFLAGS) -Wl,-z,relro,-z,now -pie $^ -lc -pthread -o $@
  47. debugger/sgx_gdb.so: debugger/sgx_gdb.c debugger/sgx_gdb.h sgx_arch.h
  48. @echo [ host/Linux-SGX/$@ ]
  49. $(CC) -MD -MP -Wall -fPIC -O2 -std=c11 -c debugger/sgx_gdb.c -o debugger/sgx_gdb.o
  50. $(LD) -shared debugger/sgx_gdb.o -o debugger/sgx_gdb.so -lc
  51. enclave_entry.o sgx_entry.o: asm-offsets.h
  52. sgx-driver/isgx_version.h:
  53. $(MAKE) -C sgx-driver $(notdir $<)
  54. include $(wildcard *.d) $(wildcard debugger/*.d)
  55. include ../../../../Makefile.rules
  56. CLEAN_FILES += $(notdir $(pal_static) $(pal_lib) $(pal_loader))
  57. CLEAN_FILES += debugger/sgx_gdb.o
  58. .PHONY: clean
  59. clean:
  60. rm -f *.o *.e *.i *.s $(host_files) $(CLEAN_FILES) *.d debugger/*.d
  61. .PHONY: test
  62. test: