Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. CC = gcc
  2. AS = gcc
  3. AR = ar rcs
  4. LD = ld
  5. include Makefile.am
  6. CFLAGS = -Wall -fPIC -O2 -std=gnu99 -fgnu89-inline -U_FORTIFY_SOURCE \
  7. -fno-omit-frame-pointer -maes \
  8. -fno-stack-protector -fno-builtin \
  9. -I. -Iinclude -I../.. -I../../../include -I../../../lib
  10. ASFLAGS = -DPIC -DSHARED -fPIC -DASSEMBLER -Wa,--noexecstack \
  11. -x assembler-with-cpp \
  12. -I. -I../.. -I../../../include
  13. ARFLAGS =
  14. LDFLAGS = -shared -nostdlib -z combreloc -z defs
  15. host_target = libpal-Linux-SGX.a pal-sgx debugger/sgx_gdb.so
  16. defs = -DIN_PAL -DPAL_DIR=$(PAL_DIR)
  17. enclave-objs = $(addprefix db_,files devices pipes sockets streams memory \
  18. threading semaphore mutex events process object main rtld \
  19. exception misc ipc spinlock) \
  20. $(addprefix enclave_,ocalls ecalls framework pages untrusted) \
  21. $(patsubst %.c,%,$(wildcard crypto/*.c))
  22. enclave-asm-objs = enclave_entry $(patsubst %.S,%,$(wildcard crypto/*.S))
  23. urts-objs = $(addprefix sgx_,enclave framework main rtld thread process exception graphene)
  24. urts-asm-objs = sgx_entry
  25. graphene_lib = ../../.lib/graphene-lib.a
  26. headers = $(wildcard *.h) $(wildcard ../../*.h) $(wildcard ../../../lib/*.h)
  27. all: $(host_target)
  28. ifeq ($(DEBUG),1)
  29. CC += -gdwarf-2 -g3
  30. CFLAGS += -DDEBUG
  31. export DEBUG
  32. endif
  33. ../../host_endian.h: host_endian.h
  34. $(MAKE) -C ../../ $<
  35. libpal-Linux-SGX.a: $(addsuffix .o,$(enclave-objs) $(enclave-asm-objs)) $(graphene_lib)
  36. @echo [ host/Linux-SGX/$@ ]
  37. $(AR) $(ARFLAGS) $@ $^
  38. $(addsuffix .o,$(enclave-objs)): %.o: %.c $(headers)
  39. @echo [ host/Linux-SGX/$@ ]
  40. @$(CC) $(CFLAGS) $(defs) -DIN_ENCLAVE -c $< -o $@
  41. $(addsuffix .e,$(enclave-objs)): %.e: %.c $(headers)
  42. @echo [ host/Linux-SGX/$@ ]
  43. @$(CC) $(CFLAGS) $(defs) -DIN_ENCLAVE -E $< -o $@
  44. $(addsuffix .o,$(enclave-asm-objs)): %.o: %.S $(headers)
  45. @echo [ host/Linux-SGX/$@ ]
  46. @$(AS) $(ASFLAGS) $(defs) -DIN_ENCLAVE -c $< -o $@
  47. $(addsuffix .o,$(urts-objs)): %.o: %.c $(headers)
  48. @echo [ host/Linux-SGX/$@ ]
  49. @$(CC) $(CFLAGS) $(defs) -DLOADER=$(abspath pal-sgx) -c $< -o $@
  50. $(addsuffix .e,$(urts-objs)): %.e: %.c $(headers)
  51. @echo [ host/Linux-SGX/$@ ]
  52. @$(CC) $(CFLAGS) $(defs) -DLOADER=$(abspath pal-sgx) -E $< -o $@
  53. $(addsuffix .o,$(urts-asm-objs)): %.o: %.S $(headers)
  54. @echo [ host/Linux-SGX/$@ ]
  55. @$(AS) $(ASFLAGS) $(defs) -DLOADER=$(abspath pal-sgx) -c $< -o $@
  56. pal-sgx: $(addsuffix .o,$(urts-objs) $(urts-asm-objs)) $(graphene_lib)
  57. @echo [ host/Linux-SGX/$@ ]
  58. @$(CC) $(CFLAGS) -pie $^ -lc -pthread -o $@
  59. debugger/sgx_gdb.so: debugger/sgx_gdb.c debugger/sgx_gdb.h sgx_arch.h
  60. @echo [ host/Linux-SGX/$@ ]
  61. $(CC) -Wall -fPIC -O2 -std=gnu99 -fgnu89-inline -c debugger/sgx_gdb.c -o debugger/sgx_gdb.o
  62. $(LD) -shared debugger/sgx_gdb.o -o debugger/sgx_gdb.so -lc
  63. ../../libpal.so: ../../libpal-enclave.so
  64. ln -s libpal-enclave.so $@
  65. clean:
  66. rm -f *.o *.e $(host_target)