Makefile 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. include ../../Scripts/Makefile.configs
  2. include ../../Scripts/Makefile.rules
  3. CFLAGS += -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. pal_loader:
  20. ln -sf ../../Runtime/pal_loader
  21. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  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. .lib/host_endian.h: ../src/host/$(PAL_HOST)/host_endian.h
  32. @mkdir -p .lib
  33. cp -f $< $@
  34. $(graphene_lib): .lib/host_endian.h
  35. $(MAKE) -C ../lib target=$(abspath .lib)/
  36. else
  37. .IGNORE: $(executables)
  38. $(executables):
  39. endif
  40. ifeq ($(filter %clean,$(MAKECMDGOALS)),)
  41. -include $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) $(addsuffix .s.d, $(executables))
  42. endif
  43. .PHONY: clean
  44. clean:
  45. $(RM) -r pal_loader $(target) .lib *.cached *.sig *.token *.manifest.sgx \
  46. $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) \
  47. $(addsuffix .s.d, $(executables)) \
  48. $(addsuffix .manifest.sgx.d,$(executables)) \
  49. .output.*
  50. .PHONY: distclean
  51. distclean: clean