Makefile 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. include ../../Scripts/Makefile.configs
  2. include ../src/Makefile.Host
  3. include ../../Scripts/Makefile.rules
  4. include ../src/Makefile.Test
  5. CFLAGS = -Wall -O2 -std=c11 -fno-builtin -nostdlib -no-pie \
  6. -I../include/pal -I../lib
  7. .PHONY: default
  8. default: all
  9. executables = HelloWorld File Failure Thread Fork Event Process Exception \
  10. Memory Pipe Tcp Udp Yield Server Wait HandleSend Select Segment \
  11. Sleep Cpuid Pie
  12. manifests = manifest
  13. target = $(executables) $(manifests)
  14. graphene_lib = .lib/graphene-lib.a
  15. pal_lib = ../../Runtime/libpal-$(PAL_HOST).so
  16. .PHONY: all
  17. all: pal_loader $(call expand_target,$(target))
  18. .PHONY: sgx-tokens
  19. sgx-tokens: $(call expand_target_to_token,$(target))
  20. ifeq ($(DEBUG),1)
  21. CC += -g
  22. endif
  23. export DEBUG
  24. ifeq ($(WERROR),1)
  25. CFLAGS += -Werror
  26. endif
  27. pal_loader:
  28. ln -sf ../../Runtime/pal_loader
  29. manifest: manifest.template
  30. $(call cmd,manifest)
  31. %.manifest: %.manifest.template
  32. $(call cmd,manifest)
  33. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  34. CFLAGS-Pie = -fPIC -pie
  35. LDLIBS = $(graphene_lib) $(pal_lib) ../src/user_start.o
  36. $(executables): %: %.c $(LDLIBS)
  37. $(call cmd,csingle)
  38. .lib/host_endian.h: ../src/host/$(PAL_HOST)/host_endian.h
  39. @mkdir -p .lib
  40. cp -f $< $@
  41. $(graphene_lib): .lib/host_endian.h
  42. $(MAKE) -C ../lib target=$(abspath .lib)/
  43. ifeq ($(filter %clean,$(MAKECMDGOALS)),)
  44. ifeq ($(SGX), 1)
  45. include $(addsuffix .manifest.sgx.d,$(executables))
  46. endif
  47. endif
  48. else
  49. .IGNORE: $(executables)
  50. $(executables):
  51. endif
  52. ifeq ($(filter %clean,$(MAKECMDGOALS)),)
  53. -include $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) $(addsuffix .s.d, $(executables))
  54. endif
  55. .PHONY: clean
  56. clean:
  57. rm -rf pal_loader $(call expand_target,$(target)) .lib *.cached *.sig *.token \
  58. $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) \
  59. $(addsuffix .s.d, $(executables)) \
  60. $(addsuffix .manifest.sgx.d,$(executables)) \
  61. .output.*
  62. .PHONY: distclean
  63. distclean: clean