Makefile 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. $(executables): %: %.c $(graphene_lib) $(pal_lib) ../src/user_start.o
  34. @echo [ $@ ]
  35. @$(CC) -MD -MP $(CFLAGS) $(if $(filter Pie,$@),-fPIC -pie,) $^ -o $@
  36. .lib/host_endian.h: ../src/host/$(PAL_HOST)/host_endian.h
  37. @mkdir -p .lib
  38. cp -f $< $@
  39. $(graphene_lib): .lib/host_endian.h
  40. $(MAKE) -C ../lib target=$(abspath .lib)/
  41. ifeq ($(SGX), 1)
  42. include $(addsuffix .manifest.sgx.d,$(executables))
  43. endif
  44. else
  45. .IGNORE: $(executables)
  46. $(executables):
  47. endif
  48. -include $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) $(addsuffix .s.d, $(executables))
  49. .PHONY: clean
  50. clean:
  51. rm -rf pal_loader $(call expand_target,$(target)) .lib *.cached \
  52. $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) \
  53. $(addsuffix .s.d, $(executables)) \
  54. $(addsuffix .manifest.sgx.d,$(executables))