Makefile 1.8 KB

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