Makefile 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. SYS ?= $(shell gcc -dumpmachine)
  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 = ../src/libpal.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 ($(SYS),x86_64-linux-gnu)
  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. $(graphene_lib):
  45. $(MAKE) -C ../lib target=$(shell pwd)/.lib/
  46. else
  47. .IGNORE: $(preloads) $(executables)
  48. $(preloads) $(executables):
  49. endif
  50. PYTHONENV = "PYTHONPATH=../../Scripts"
  51. ifeq ($(SGX_RUN),1)
  52. PYTHONENV += "TIMEOUT=5000"
  53. endif
  54. regression: $(call expand_target,$(target))
  55. @printf "\n\nBasic Bootstrapping:\n"
  56. @for f in $(wildcard 00_*.py); do env $(PYTHONENV) python $$f || exit $$?; done
  57. @printf "\n\nException Handling:\n"
  58. @for f in $(wildcard 01_*.py); do env $(PYTHONENV) python $$f || exit $$?; done
  59. @printf "\n\nSingle-Process Functionalities:\n"
  60. @for f in $(wildcard 02_*.py); do env $(PYTHONENV) python $$f || exit $$?; done
  61. @printf "\n\nProcess Creation:\n"
  62. @for f in $(wildcard 03_*.py); do env $(PYTHONENV) python $$f || exit $$?; done
  63. @printf "\n\nMulti-Process Functionalities:\n"
  64. @for f in $(wildcard 04_*.py); do env $(PYTHONENV) python $$f || exit $$?; done
  65. @printf "\n\nReference Monitor (Optional):\n"
  66. @for f in $(wildcard 05_*.py); do env $(PYTHONENV) python $$f || exit $$?; done
  67. @printf "\n\n"
  68. .PHONY: clean
  69. clean:
  70. rm -rf $(call expand_target,$(target)) $(preloads) *.tmp .lib *.cached *.sig