Makefile 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. SYS ?= $(shell gcc -dumpmachine)
  2. CC = gcc -g
  3. CFLAGS = -Wall -O2 -std=gnu99 -fgnu89-inline -fno-builtin -nostdlib \
  4. -I../include/pal -I../lib
  5. target = $(patsubst %.c,%,$(wildcard *.c)) \
  6. manifest $(patsubst %.manifest.template,%.manifest,$(wildcard *.manifest.template))
  7. preloads = $(patsubst %.c,%,$(wildcard *.so.c))
  8. executables = $(filter-out $(preloads),$(patsubst %.c,%,$(wildcard *.c)))
  9. manifests = manifest $(patsubst %.manifest.template,%.manifest,$(wildcard *.manifest.template))
  10. target = $(executables) $(preloads) $(manifests)
  11. graphene_lib = ../lib/graphene-lib.a
  12. pal_lib = ../src/libpal.so
  13. headers = $(wildcard ../include/pal/*.h)
  14. all: $(target)
  15. manifest_rules = \
  16. -e 's:\$$(PAL):$(abspath $(PWD)/../src/pal):g' \
  17. -e 's:\$$(PWD):$(PWD)/:g' \
  18. $(extra_rules)
  19. manifest: manifest.template
  20. rm -f $@
  21. sed $(manifest_rules) $< >$@
  22. chmod +x $@
  23. %.manifest: %.manifest.template
  24. rm -f $@
  25. sed $(manifest_rules) $< >$@
  26. chmod +x $@
  27. ../src/user_shared_start.o ../src/user_start.o: ../src/user_start.S
  28. make -C ../src $(notdir $@)
  29. ifeq ($(SYS),x86_64-linux-gnu)
  30. $(preloads): %.so: %.so.c ../src/user_shared_start.o \
  31. $(graphene_lib) $(pal_lib) ../include/pal/pal.h
  32. @echo [ $@ ]
  33. @$(CC) -shared -fPIC $(CFLAGS) $^ -o $@
  34. $(executables): %: %.c ../src/user_start.o \
  35. $(graphene_lib) $(pal_lib) $(preloads) ../include/pal/pal.h
  36. @echo [ $@ ]
  37. @$(CC) $(CFLAGS) $^ -o $@
  38. .PHONY: pack
  39. pack: $(preloads) $(executables)
  40. tar -czf .packed/test.tar.gz $^
  41. else
  42. $(preloads) $(executables): .packed/test.tar.gz
  43. tar -xmozf $<
  44. endif
  45. PYTHONENV = "PYTHONPATH=../../Scripts"
  46. regression: $(target)
  47. @echo "\n\nBasic Bootstrapping:"
  48. @for f in $(wildcard 00_*.py); do env $(PYTHONENV) python $$f; done
  49. @echo "\n\nException Handling:"
  50. @for f in $(wildcard 01_*.py); do env $(PYTHONENV) python $$f; done
  51. @echo "\n\nSingle-Process Functionalities:"
  52. @for f in $(wildcard 02_*.py); do env $(PYTHONENV) python $$f; done
  53. @echo "\n\nProcess Creation:"
  54. @for f in $(wildcard 03_*.py); do env $(PYTHONENV) python $$f; done
  55. @echo "\n\nMulti-Process Functionalities:"
  56. @for f in $(wildcard 04_*.py); do env $(PYTHONENV) python $$f; done
  57. @echo "\n\nReference Monitor (Optional):"
  58. @for f in $(wildcard 05_*.py); do env $(PYTHONENV) python $$f; done
  59. @echo "\n\n"
  60. clean:
  61. rm -rf $(target) *.tmp