Makefile 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. include ../src/Makefile.Host
  2. CC = gcc
  3. CFLAGS = -Wall -O2 -std=c11 -fno-builtin -nostdlib -mavx \
  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 = ../../Runtime/libpal-$(PAL_HOST).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. .PHONY: all
  18. all: $(call expand_target,$(target)) $(preloads)
  19. ifeq ($(DEBUG),1)
  20. CC += -g
  21. endif
  22. export DEBUG
  23. ifeq ($(WERROR),1)
  24. CFLAGS += -Werror
  25. endif
  26. manifest_rules = \
  27. -e 's:\$$(PAL):$(abspath ../../Runtime/pal_loader):g' \
  28. -e 's:\$$(PWD):$(shell pwd)/:g' \
  29. $(extra_rules)
  30. manifest: manifest.template
  31. sed $(manifest_rules) $< >$@
  32. %.manifest: %.manifest.template $(executables) $(pal_lib)
  33. sed $(manifest_rules) $< >$@
  34. (grep -q "#\!" $@ && chmod +x $@) || true
  35. ../src/user_shared_start.o ../src/user_start.o: ../src/user_start.S
  36. $(MAKE) -C ../src $(notdir $@)
  37. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  38. $(preloads): %.so: %.so.c ../src/user_shared_start.o \
  39. $(graphene_lib) $(pal_lib) ../include/pal/pal.h
  40. @echo [ $@ ]
  41. @$(CC) -shared -fPIC $(CFLAGS) $^ -o $@
  42. $(executables): %: %.c ../src/user_start.o \
  43. $(graphene_lib) $(pal_lib) $(preloads) ../include/pal/pal.h
  44. @echo [ $@ ]
  45. @$(CC) $(CFLAGS) $^ -o $@
  46. .lib/host_endian.h: ../src/host/$(PAL_HOST)/host_endian.h
  47. @mkdir -p .lib
  48. cp -f $< $@
  49. $(graphene_lib): .lib/host_endian.h
  50. $(MAKE) -C ../lib target=$(abspath .lib)/
  51. Process2.manifest.sgx: Bootstrap.manifest.sgx
  52. else
  53. .IGNORE: $(preloads) $(executables)
  54. $(preloads) $(executables):
  55. endif
  56. export PYTHONPATH=../../Scripts
  57. .PHONY: regression
  58. regression:
  59. $(RM) pal-regression.xml
  60. $(MAKE) pal-regression.xml
  61. pal-regression.xml: test_pal.py $(call expand_target,$(target))
  62. python3 -m pytest --junit-xml $@ -v test_pal.py
  63. .PHONY: clean
  64. clean:
  65. rm -rf $(call expand_target,$(target)) $(preloads) *.tmp .lib *.cached *.sig