Makefile 1.7 KB

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