Makefile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. include ../src/Makefile.Host
  2. CC = gcc
  3. CFLAGS = -Wall -O2 -std=c11 -fno-builtin -nostdlib -mavx \
  4. -I../include/pal -I../lib
  5. preloads = $(patsubst %.c,%,$(wildcard *.so.c))
  6. executables = $(filter-out $(preloads),$(patsubst %.c,%,$(wildcard *.c))) ..Bootstrap
  7. manifests = manifest $(patsubst %.manifest.template,%.manifest,$(wildcard *.manifest.template))
  8. target = $(executables) $(manifests)
  9. graphene_lib = .lib/graphene-lib.a
  10. pal_lib = ../../Runtime/libpal-$(PAL_HOST).so
  11. headers = $(wildcard ../include/pal/*.h)
  12. .PHONY: default
  13. default: all
  14. include ../src/Makefile.Test
  15. RUNTIME_DIR = $(CURDIR)/../../Runtime
  16. export PAL_LOADER = $(RUNTIME_DIR)/pal-$(PAL_HOST)
  17. export PAL_SEC = $(RUNTIME_DIR)/pal_sec-$(PAL_HOST)
  18. .PHONY: all
  19. all: $(call expand_target,$(target)) $(preloads)
  20. ifeq ($(DEBUG),1)
  21. CC += -g
  22. endif
  23. export DEBUG
  24. ifeq ($(WERROR),1)
  25. CFLAGS += -Werror
  26. endif
  27. manifest_rules = \
  28. -e 's:\$$(PAL):$(abspath ../../Runtime/pal_loader):g' \
  29. -e 's:\$$(PWD):$(shell pwd)/:g' \
  30. $(extra_rules)
  31. manifest: manifest.template
  32. sed $(manifest_rules) $< >$@
  33. %.manifest: %.manifest.template
  34. sed $(manifest_rules) $< >$@
  35. (grep -q "#\!" $@ && chmod +x $@) || true
  36. ../src/user_shared_start.o ../src/user_start.o: ../src/user_start.S
  37. $(MAKE) -C ../src $(notdir $@)
  38. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  39. $(preloads): %.so: %.so.c ../src/user_shared_start.o \
  40. $(graphene_lib) $(pal_lib) ../include/pal/pal.h
  41. @echo [ $@ ]
  42. @$(CC) -shared -fPIC $(CFLAGS) $^ -o $@
  43. $(executables): %: %.c ../src/user_start.o \
  44. $(graphene_lib) $(pal_lib) $(preloads) ../include/pal/pal.h
  45. @echo [ $@ ]
  46. @$(CC) $(CFLAGS) $^ -o $@
  47. .lib/host_endian.h: ../src/host/$(PAL_HOST)/host_endian.h
  48. @mkdir -p .lib
  49. cp -f $< $@
  50. $(graphene_lib): .lib/host_endian.h
  51. $(MAKE) -C ../lib target=$(abspath .lib)/
  52. else
  53. .IGNORE: $(preloads) $(executables)
  54. $(preloads) $(executables):
  55. endif
  56. PYTHONENV = "PYTHONPATH=../../Scripts"
  57. ifeq ($(SGX_RUN),1)
  58. PYTHONENV += "TIMEOUT=5000"
  59. endif
  60. regression: $(call expand_target,$(target))
  61. @printf "\n\nBasic Bootstrapping:\n"
  62. @for f in $(wildcard 00_*.py); do env $(PYTHONENV) python3 $$f || exit $$?; done
  63. @printf "\n\nException Handling:\n"
  64. @for f in $(wildcard 01_*.py); do env $(PYTHONENV) python3 $$f || exit $$?; done
  65. @printf "\n\nSingle-Process Functionalities:\n"
  66. @for f in $(wildcard 02_*.py); do env $(PYTHONENV) python3 $$f || exit $$?; done
  67. @printf "\n\nProcess Creation:\n"
  68. @for f in $(wildcard 03_*.py); do env $(PYTHONENV) python3 $$f || exit $$?; done
  69. @printf "\n\nMulti-Process Functionalities:\n"
  70. @for f in $(wildcard 04_*.py); do env $(PYTHONENV) python3 $$f || exit $$?; done
  71. @printf "\n\nReference Monitor (Optional):\n"
  72. @for f in $(wildcard 05_*.py); do env $(PYTHONENV) python3 $$f || exit $$?; done
  73. @printf "\n\n"
  74. .PHONY: clean
  75. clean:
  76. rm -rf $(call expand_target,$(target)) $(preloads) *.tmp .lib *.cached *.sig