Makefile 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 semaphore mutex events process object main rtld \
  8. exception misc ipc spinlock) \
  9. $(addprefix enclave_,ocalls ecalls framework pages untrusted) \
  10. $(patsubst %.c,%,$(wildcard crypto/*.c))
  11. enclave-asm-objs = enclave_entry $(patsubst %.S,%,$(wildcard crypto/*.S))
  12. urts-objs = $(addprefix sgx_,enclave framework main rtld thread process exception graphene)
  13. urts-asm-objs = sgx_entry
  14. graphene_lib = ../../.lib/graphene-lib.a
  15. headers = $(wildcard *.h) $(wildcard ../../*.h) $(wildcard ../../../lib/*.h) \
  16. $(addprefix sgx-driver/,graphene-sgx.h isgx_version.h)
  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. ../../libpal.so: ../../libpal-enclave.so
  56. ln -s libpal-enclave.so $@
  57. clean:
  58. rm -f *.o *.e $(host_files)