Makefile 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. include ../src/Makefile.Host
  2. CC = gcc
  3. CFLAGS = -Wall -O2 -std=gnu99 -fgnu89-inline -fno-builtin -nostdlib \
  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. manifest_rules = \
  25. -e 's:\$$(PAL):$(abspath ../../Runtime/pal_loader):g' \
  26. -e 's:\$$(PWD):$(shell pwd)/:g' \
  27. $(extra_rules)
  28. manifest: manifest.template
  29. sed $(manifest_rules) $< >$@
  30. %.manifest: %.manifest.template
  31. sed $(manifest_rules) $< >$@
  32. (grep -q "#\!" $@ && chmod +x $@) || true
  33. ../src/user_shared_start.o ../src/user_start.o: ../src/user_start.S
  34. $(MAKE) -C ../src $(notdir $@)
  35. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  36. $(preloads): %.so: %.so.c ../src/user_shared_start.o \
  37. $(graphene_lib) $(pal_lib) ../include/pal/pal.h
  38. @echo [ $@ ]
  39. @$(CC) -shared -fPIC $(CFLAGS) $^ -o $@
  40. $(executables): %: %.c ../src/user_start.o \
  41. $(graphene_lib) $(pal_lib) $(preloads) ../include/pal/pal.h
  42. @echo [ $@ ]
  43. @$(CC) $(CFLAGS) $^ -o $@
  44. .lib/host_endian.h: ../src/host/$(PAL_HOST)/host_endian.h
  45. @mkdir -p .lib
  46. cp -f $< $@
  47. $(graphene_lib): .lib/host_endian.h
  48. $(MAKE) -C ../lib target=$(abspath .lib)/
  49. else
  50. .IGNORE: $(preloads) $(executables)
  51. $(preloads) $(executables):
  52. endif
  53. PYTHONENV = "PYTHONPATH=../../Scripts"
  54. ifeq ($(SGX_RUN),1)
  55. PYTHONENV += "TIMEOUT=5000"
  56. endif
  57. regression: $(call expand_target,$(target))
  58. @printf "\n\nBasic Bootstrapping:\n"
  59. @for f in $(wildcard 00_*.py); do env $(PYTHONENV) python $$f || exit $$?; done
  60. @printf "\n\nException Handling:\n"
  61. @for f in $(wildcard 01_*.py); do env $(PYTHONENV) python $$f || exit $$?; done
  62. @printf "\n\nSingle-Process Functionalities:\n"
  63. @for f in $(wildcard 02_*.py); do env $(PYTHONENV) python $$f || exit $$?; done
  64. @printf "\n\nProcess Creation:\n"
  65. @for f in $(wildcard 03_*.py); do env $(PYTHONENV) python $$f || exit $$?; done
  66. @printf "\n\nMulti-Process Functionalities:\n"
  67. @for f in $(wildcard 04_*.py); do env $(PYTHONENV) python $$f || exit $$?; done
  68. @printf "\n\nReference Monitor (Optional):\n"
  69. @for f in $(wildcard 05_*.py); do env $(PYTHONENV) python $$f || exit $$?; done
  70. @printf "\n\n"
  71. .PHONY: clean
  72. clean:
  73. rm -rf $(call expand_target,$(target)) $(preloads) *.tmp .lib *.cached *.sig