Makefile 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 .o,$(enclave-asm-objs)): %.o: %.S $(headers)
  35. @echo [ host/Linux-SGX/$@ ]
  36. @$(AS) $(ASFLAGS) $(defs) -DIN_ENCLAVE -c $< -o $@
  37. $(addsuffix .o,$(urts-objs)): %.o: %.c $(headers)
  38. @echo [ host/Linux-SGX/$@ ]
  39. @$(CC) $(filter-out -DIN_ENCLAVE,$(CFLAGS)) $(defs) -c $< -o $@
  40. $(addsuffix .e,$(urts-objs)): %.e: %.c $(headers)
  41. @echo [ host/Linux-SGX/$@ ]
  42. @$(CC) $(filter-out -DIN_ENCLAVE,$(CFLAGS)) $(defs) -E $< -o $@
  43. $(addsuffix .o,$(urts-asm-objs)): %.o: %.S $(headers)
  44. @echo [ host/Linux-SGX/$@ ]
  45. @$(AS) $(filter-out -DIN_ENCLAVE,$(ASFLAGS)) $(defs) -c $< -o $@
  46. pal-sgx: $(addsuffix .o,$(urts-objs) $(urts-asm-objs)) $(graphene_lib)
  47. @echo [ host/Linux-SGX/$@ ]
  48. @$(CC) $(CFLAGS) -pie $^ -lc -pthread -o $@
  49. debugger/sgx_gdb.so: debugger/sgx_gdb.c debugger/sgx_gdb.h sgx_arch.h
  50. @echo [ host/Linux-SGX/$@ ]
  51. $(CC) -Wall -fPIC -O2 -std=gnu99 -fgnu89-inline -c debugger/sgx_gdb.c -o debugger/sgx_gdb.o
  52. $(LD) -shared debugger/sgx_gdb.o -o debugger/sgx_gdb.so -lc
  53. sgx-driver/isgx_version.h:
  54. cd sgx-driver && make isgx_version.h
  55. .PHONY: clean
  56. clean:
  57. rm -f *.o *.e $(host_files)