Makefile 2.5 KB

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