Makefile 1.9 KB

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