Makefile 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. include ../src/Makefile.Host
  2. CC = gcc
  3. CFLAGS = -Wall -O2 -std=c11 -fno-builtin -nostdlib -mavx -no-pie \
  4. -I../include/pal -I../lib -I../src
  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. .PHONY: default
  12. default: all
  13. include ../src/Makefile.Test
  14. RUNTIME_DIR = $(CURDIR)/../../Runtime
  15. export PAL_LOADER = $(RUNTIME_DIR)/pal-$(PAL_HOST)
  16. .PHONY: all
  17. all: $(call expand_target,$(target)) $(preloads)
  18. ifeq ($(DEBUG),1)
  19. CC += -g
  20. endif
  21. export DEBUG
  22. ifeq ($(WERROR),1)
  23. CFLAGS += -Werror
  24. endif
  25. manifest_rules = \
  26. -e 's:\$$(PAL):$(abspath ../../Runtime/pal_loader):g' \
  27. -e 's:\$$(PWD):$(shell pwd)/:g' \
  28. $(extra_rules)
  29. manifest: manifest.template
  30. sed $(manifest_rules) $< >$@
  31. %.manifest: %.manifest.template $(executables) $(pal_lib)
  32. sed $(manifest_rules) $< >$@
  33. (grep -q "#\!" $@ && chmod +x $@) || true
  34. ../src/user_shared_start.o ../src/user_start.o: ../src/user_start.S
  35. $(MAKE) -C ../src $(notdir $@)
  36. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  37. $(preloads): %.so: %.so.c ../src/user_shared_start.o \
  38. $(graphene_lib) $(pal_lib)
  39. @echo [ $@ ]
  40. @$(CC) -MD -MP -shared -fPIC $(filter-out -no-pie,$(CFLAGS)) $(filter-out %.h,$^) -o $@
  41. $(executables): %: %.c ../src/user_start.o \
  42. $(graphene_lib) $(pal_lib) $(preloads)
  43. @echo [ $@ ]
  44. @$(CC) -MD -MP $(CFLAGS) $(filter-out %.h,$^) -o $@
  45. include $(wildcard *.d)
  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 *.d