Makefile 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. include ../../Scripts/Makefile.configs
  2. include ../../Scripts/Makefile.rules
  3. CFLAGS = -Wall -O2 -std=c11 -fno-builtin -nostdlib -no-pie \
  4. -I../include/pal -I../lib
  5. .PHONY: default
  6. default: all
  7. executables = HelloWorld File Failure Thread Fork Event Process Exception \
  8. Memory Pipe Tcp Udp Yield Server Wait HandleSend Select Segment \
  9. Sleep Cpuid Pie
  10. manifests = manifest
  11. target = $(executables) $(manifests)
  12. include ../../Scripts/Makefile.manifest
  13. graphene_lib = .lib/graphene-lib.a
  14. pal_lib = ../../Runtime/libpal-$(PAL_HOST).so
  15. .PHONY: all
  16. all: pal_loader $(target) $(call expand_target_to_sig,$(target)) $(call expand_target_to_sgx,$(target))
  17. .PHONY: sgx-tokens
  18. sgx-tokens: $(call expand_target_to_token,$(target))
  19. ifeq ($(DEBUG),1)
  20. CC += -g
  21. endif
  22. ifeq ($(WERROR),1)
  23. CFLAGS += -Werror
  24. endif
  25. pal_loader:
  26. ln -sf ../../Runtime/pal_loader
  27. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  28. CFLAGS-Pie = -fPIC -pie
  29. LDLIBS = $(graphene_lib) $(pal_lib) ../src/user_start.o
  30. $(executables): %: %.c $(LDLIBS)
  31. $(call cmd,csingle)
  32. .lib/host_endian.h: ../src/host/$(PAL_HOST)/host_endian.h
  33. @mkdir -p .lib
  34. cp -f $< $@
  35. $(graphene_lib): .lib/host_endian.h
  36. $(MAKE) -C ../lib target=$(abspath .lib)/
  37. else
  38. .IGNORE: $(executables)
  39. $(executables):
  40. endif
  41. ifeq ($(filter %clean,$(MAKECMDGOALS)),)
  42. -include $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) $(addsuffix .s.d, $(executables))
  43. endif
  44. .PHONY: clean
  45. clean:
  46. $(RM) -r pal_loader $(target) .lib *.cached *.sig *.token *.manifest.sgx \
  47. $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) \
  48. $(addsuffix .s.d, $(executables)) \
  49. $(addsuffix .manifest.sgx.d,$(executables)) \
  50. .output.*
  51. .PHONY: distclean
  52. distclean: clean