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../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. .PHONY: all
  14. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  15. all: pal_loader $(target) $(call expand_target_to_sig,$(target)) $(call expand_target_to_sgx,$(target))
  16. else
  17. all:
  18. endif
  19. .PHONY: sgx-tokens
  20. sgx-tokens: $(call expand_target_to_token,$(target))
  21. pal_loader:
  22. ln -sf ../../Runtime/pal_loader
  23. .PHONY: crt_init-recurse
  24. crt_init-recurse:
  25. $(MAKE) -C ../crt_init all
  26. ../crt_init/user_start.o: crt_init-recurse
  27. @true
  28. CFLAGS-Pie = -fPIC -pie
  29. LDLIBS += $(graphene_lib) $(pal_lib) ../crt_init/user_start.o
  30. $(executables): %: %.c $(LDLIBS)
  31. $(call cmd,csingle)
  32. $(graphene_lib):
  33. $(MAKE) -C ../lib target=$(abspath .lib)/
  34. ifeq ($(filter %clean,$(MAKECMDGOALS)),)
  35. -include $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) $(addsuffix .s.d, $(executables))
  36. endif
  37. .PHONY: clean
  38. clean:
  39. $(RM) -r pal_loader $(target) .lib *.cached *.sig *.token *.manifest.sgx \
  40. $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) \
  41. $(addsuffix .s.d, $(executables)) \
  42. $(addsuffix .manifest.sgx.d,$(executables)) \
  43. .output.*
  44. .PHONY: distclean
  45. distclean: clean