Makefile 3.4 KB

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