Makefile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. include Makefile.am
  2. CFLAGS += -I. -Iinclude -I../.. -I../../../include -I../../../lib
  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. all: $(host_files)
  17. ifeq ($(DEBUG),1)
  18. CC += -gdwarf-2 -g3
  19. CFLAGS += -DDEBUG
  20. export DEBUG
  21. endif
  22. ../../host_endian.h: host_endian.h
  23. $(MAKE) -C ../../ $<
  24. libpal-Linux-SGX.a: $(addsuffix .o,$(enclave-objs) $(enclave-asm-objs)) $(graphene_lib)
  25. @echo [ host/Linux-SGX/$@ ]
  26. $(AR) $(ARFLAGS) $@ $^
  27. $(addsuffix .o,$(enclave-objs)): %.o: %.c $(headers)
  28. @echo [ host/Linux-SGX/$@ ]
  29. @$(CC) $(CFLAGS) $(defs) -DIN_ENCLAVE -c $< -o $@
  30. $(addsuffix .e,$(enclave-objs)): %.e: %.c $(headers)
  31. @echo [ host/Linux-SGX/$@ ]
  32. @$(CC) $(CFLAGS) $(defs) -DIN_ENCLAVE -E $< -o $@
  33. $(addsuffix .o,$(enclave-asm-objs)): %.o: %.S $(headers)
  34. @echo [ host/Linux-SGX/$@ ]
  35. @$(AS) $(ASFLAGS) $(defs) -DIN_ENCLAVE -c $< -o $@
  36. $(addsuffix .o,$(urts-objs)): %.o: %.c $(headers)
  37. @echo [ host/Linux-SGX/$@ ]
  38. @$(CC) $(filter-out -DIN_ENCLAVE,$(CFLAGS)) $(defs) -DLOADER=$(abspath pal-sgx) -c $< -o $@
  39. $(addsuffix .e,$(urts-objs)): %.e: %.c $(headers)
  40. @echo [ host/Linux-SGX/$@ ]
  41. @$(CC) $(filter-out -DIN_ENCLAVE,$(CFLAGS)) $(defs) -DLOADER=$(abspath pal-sgx) -E $< -o $@
  42. $(addsuffix .o,$(urts-asm-objs)): %.o: %.S $(headers)
  43. @echo [ host/Linux-SGX/$@ ]
  44. @$(AS) $(filter-out -DIN_ENCLAVE,$(ASFLAGS)) $(defs) -DLOADER=$(abspath pal-sgx) -c $< -o $@
  45. pal-sgx: $(addsuffix .o,$(urts-objs) $(urts-asm-objs)) $(graphene_lib)
  46. @echo [ host/Linux-SGX/$@ ]
  47. @$(CC) $(CFLAGS) -pie $^ -lc -pthread -o $@
  48. debugger/sgx_gdb.so: debugger/sgx_gdb.c debugger/sgx_gdb.h sgx_arch.h
  49. @echo [ host/Linux-SGX/$@ ]
  50. $(CC) -Wall -fPIC -O2 -std=gnu99 -fgnu89-inline -c debugger/sgx_gdb.c -o debugger/sgx_gdb.o
  51. $(LD) -shared debugger/sgx_gdb.o -o debugger/sgx_gdb.so -lc
  52. ../../libpal.so: ../../libpal-enclave.so
  53. ln -s libpal-enclave.so $@
  54. clean:
  55. rm -f *.o *.e $(host_files)