Makefile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. include ../../Scripts/Makefile.configs
  2. include ../../Scripts/Makefile.rules
  3. CFLAGS = -Wall -O2 -std=c11 -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. ifeq ($(DEBUG),1)
  20. CC += -g
  21. endif
  22. ifeq ($(WERROR),1)
  23. CFLAGS += -Werror
  24. endif
  25. pal_loader:
  26. ln -sf ../../Runtime/pal_loader
  27. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  28. .PHONY: crt_init-recurse
  29. crt_init-recurse:
  30. $(MAKE) -C ../crt_init all
  31. ../crt_init/user_start.o: crt_init-recurse
  32. @true
  33. CFLAGS-Pie = -fPIC -pie
  34. LDLIBS = $(graphene_lib) $(pal_lib) ../crt_init/user_start.o
  35. $(executables): %: %.c $(LDLIBS)
  36. $(call cmd,csingle)
  37. .lib/host_endian.h: ../src/host/$(PAL_HOST)/host_endian.h
  38. @mkdir -p .lib
  39. cp -f $< $@
  40. $(graphene_lib): .lib/host_endian.h
  41. $(MAKE) -C ../lib target=$(abspath .lib)/
  42. else
  43. .IGNORE: $(executables)
  44. $(executables):
  45. endif
  46. ifeq ($(filter %clean,$(MAKECMDGOALS)),)
  47. -include $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) $(addsuffix .s.d, $(executables))
  48. endif
  49. .PHONY: clean
  50. clean:
  51. $(RM) -r pal_loader $(target) .lib *.cached *.sig *.token *.manifest.sgx \
  52. $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) \
  53. $(addsuffix .s.d, $(executables)) \
  54. $(addsuffix .manifest.sgx.d,$(executables)) \
  55. .output.*
  56. .PHONY: distclean
  57. distclean: clean