Makefile 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. .PHONY: pack
  47. pack: $(preloads) $(executables)
  48. @../../Scripts/pack_binaries.sh test $^
  49. else
  50. $(preloads) $(executables): .packed/test.tar.gz
  51. tar -xmozf $< $@
  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