Makefile 2.2 KB

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