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. default: all
  13. include ../src/Makefile.Test
  14. RUNTIME_DIR = $(CURDIR)/../../Runtime
  15. export PAL_LOADER = $(RUNTIME_DIR)/pal-$(PAL_HOST)
  16. export PAL_SEC = $(RUNTIME_DIR)/pal_sec-$(PAL_HOST)
  17. all: $(call expand_target,$(target)) $(preloads)
  18. ifeq ($(DEBUG),1)
  19. CC += -g
  20. endif
  21. export DEBUG
  22. manifest_rules = \
  23. -e 's:\$$(PAL):$(abspath ../../Runtime/pal_loader):g' \
  24. -e 's:\$$(PWD):$(shell pwd)/:g' \
  25. $(extra_rules)
  26. manifest: manifest.template
  27. sed $(manifest_rules) $< >$@
  28. %.manifest: %.manifest.template
  29. sed $(manifest_rules) $< >$@
  30. (grep -q "#\!" $@ && chmod +x $@) || true
  31. ../src/user_shared_start.o ../src/user_start.o: ../src/user_start.S
  32. $(MAKE) -C ../src $(notdir $@)
  33. ifeq ($(SYS),x86_64-linux-gnu)
  34. $(preloads): %.so: %.so.c ../src/user_shared_start.o \
  35. $(graphene_lib) $(pal_lib) ../include/pal/pal.h
  36. @echo [ $@ ]
  37. @$(CC) -shared -fPIC $(CFLAGS) $^ -o $@
  38. $(executables): %: %.c ../src/user_start.o \
  39. $(graphene_lib) $(pal_lib) $(preloads) ../include/pal/pal.h
  40. @echo [ $@ ]
  41. @$(CC) $(CFLAGS) $^ -o $@
  42. $(graphene_lib):
  43. $(MAKE) -C ../lib target=$(shell pwd)/.lib/
  44. .PHONY: pack
  45. pack: $(preloads) $(executables)
  46. @../../Scripts/pack_binaries.sh test $^
  47. else
  48. $(preloads) $(executables): .packed/test.tar.gz
  49. tar -xmozf $< $@
  50. endif
  51. PYTHONENV = "PYTHONPATH=../../Scripts"
  52. ifeq ($(SGX_RUN),1)
  53. PYTHONENV += "TIMEOUT=5000"
  54. endif
  55. regression: $(call expand_target,$(target))
  56. @printf "\n\nBasic Bootstrapping:\n"
  57. @for f in $(wildcard 00_*.py); do env $(PYTHONENV) python $$f; done
  58. @printf "\n\nException Handling:\n"
  59. @for f in $(wildcard 01_*.py); do env $(PYTHONENV) python $$f; done
  60. @printf "\n\nSingle-Process Functionalities:\n"
  61. @for f in $(wildcard 02_*.py); do env $(PYTHONENV) python $$f; done
  62. @printf "\n\nProcess Creation:\n"
  63. @for f in $(wildcard 03_*.py); do env $(PYTHONENV) python $$f; done
  64. @printf "\n\nMulti-Process Functionalities:\n"
  65. @for f in $(wildcard 04_*.py); do env $(PYTHONENV) python $$f; done
  66. @printf "\n\nReference Monitor (Optional):\n"
  67. @for f in $(wildcard 05_*.py); do env $(PYTHONENV) python $$f; done
  68. @printf "\n\n"
  69. clean:
  70. rm -rf $(call expand_target,$(target)) $(preloads) *.tmp .lib *.cached