Makefile 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 Ipc 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. ifeq ($(DEBUG),1)
  20. CC += -g
  21. endif
  22. export DEBUG
  23. ifeq ($(WERROR),1)
  24. CFLAGS += -Werror
  25. endif
  26. pal_loader:
  27. ln -sf ../../Runtime/pal_loader
  28. manifest: manifest.template
  29. cp -f $< $@
  30. %.manifest: %.manifest.template
  31. cp -f $< $@
  32. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  33. CFLAGS-Pie = -fPIC -pie
  34. LDLIBS = $(graphene_lib) $(pal_lib) ../src/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. ifeq ($(filter clean,$(MAKECMDGOALS)),)
  43. ifeq ($(SGX), 1)
  44. include $(addsuffix .manifest.sgx.d,$(executables))
  45. endif
  46. endif
  47. else
  48. .IGNORE: $(executables)
  49. $(executables):
  50. endif
  51. -include $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) $(addsuffix .s.d, $(executables))
  52. .PHONY: clean
  53. clean:
  54. rm -rf pal_loader $(call expand_target,$(target)) .lib *.cached \
  55. $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) \
  56. $(addsuffix .s.d, $(executables)) \
  57. $(addsuffix .manifest.sgx.d,$(executables))