Makefile 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. .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. ifeq ($(filter %clean,$(MAKECMDGOALS)),)
  38. -include $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) $(addsuffix .s.d, $(executables))
  39. endif
  40. .PHONY: clean
  41. clean:
  42. $(RM) -r pal_loader $(target) .lib *.cached *.sig *.token *.manifest.sgx \
  43. $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) \
  44. $(addsuffix .s.d, $(executables)) \
  45. $(addsuffix .manifest.sgx.d,$(executables)) \
  46. .output.*
  47. .PHONY: distclean
  48. distclean: clean