Makefile 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. include ../../Scripts/Makefile.configs
  2. include ../../Scripts/Makefile.rules
  3. CFLAGS += -fno-builtin -nostdlib -no-pie \
  4. -I../include/pal -I../include/lib
  5. executables = HelloWorld File Failure Thread Fork Event Process Exception \
  6. Memory Pipe Tcp Udp Yield Server Wait HandleSend Select Segment \
  7. Sleep Cpuid Pie
  8. manifests = manifest
  9. target = $(executables) $(manifests)
  10. include ../../Scripts/Makefile.manifest
  11. graphene_lib = .lib/graphene-lib.a
  12. pal_lib = ../../Runtime/libpal-$(PAL_HOST).so
  13. ifneq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  14. $(error unsupported platform. $(SYS))
  15. endif
  16. .PHONY: all
  17. all: pal_loader $(target) $(call expand_target_to_sig,$(target)) $(call expand_target_to_sgx,$(target))
  18. .PHONY: sgx-tokens
  19. sgx-tokens: $(call expand_target_to_token,$(target))
  20. pal_loader:
  21. ln -sf ../../Runtime/pal_loader
  22. .PHONY: crt_init-recurse
  23. crt_init-recurse:
  24. $(MAKE) -C ../crt_init all
  25. ../crt_init/user_start.o: crt_init-recurse
  26. @true
  27. CFLAGS-Pie = -fPIC -pie
  28. LDLIBS += $(graphene_lib) $(pal_lib) ../crt_init/user_start.o
  29. $(executables): %: %.c $(LDLIBS)
  30. $(call cmd,csingle)
  31. $(graphene_lib):
  32. $(MAKE) -C ../lib target=$(abspath .lib)/
  33. ifeq ($(filter %clean,$(MAKECMDGOALS)),)
  34. -include $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) $(addsuffix .s.d, $(executables))
  35. endif
  36. .PHONY: clean
  37. clean:
  38. $(RM) -r pal_loader $(target) .lib *.cached *.sig *.token *.manifest.sgx \
  39. $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) \
  40. $(addsuffix .s.d, $(executables)) \
  41. $(addsuffix .manifest.sgx.d,$(executables)) \
  42. .output.*
  43. .PHONY: distclean
  44. distclean: clean