Makefile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. include ../src/Makefile.Host
  2. CC = gcc
  3. CFLAGS = -Wall -O2 -std=c11 -fno-builtin -nostdlib \
  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 ../../Makefile.configs
  14. include ../../Makefile.rules
  15. include ../src/Makefile.Test
  16. RUNTIME_DIR = $(CURDIR)/../../Runtime
  17. export PAL_LOADER = $(RUNTIME_DIR)/pal-$(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. CFLAGS-AvxDisable += -mavx
  39. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  40. LDLIBS-preloads = ../src/user_shared_start.o $(graphene_lib) $(pal_lib)
  41. $(preloads): CFLAGS += -shared -fPIC
  42. $(preloads): LDLIBS = $(LDLIBS-preloads)
  43. $(preloads): %.so: %.so.c $(LDLIBS-preloads)
  44. $(call cmd,csingle)
  45. LDLIBS-executables = ../src/user_start.o $(graphene_lib) $(pal_lib) $(preloads)
  46. $(executables): CFLAGS += -no-pie
  47. $(executables): LDLIBS = $(LDLIBS-executables)
  48. $(executables): %: %.c $(LDLIBS-executables)
  49. $(call cmd,csingle)
  50. include $(wildcard *.d)
  51. ifeq ($(filter clean,$(MAKECMDGOALS)),)
  52. ifeq ($(SGX), 1)
  53. include $(addsuffix .manifest.sgx.d,$(executables))
  54. endif
  55. endif
  56. .lib/host_endian.h: ../src/host/$(PAL_HOST)/host_endian.h
  57. @mkdir -p .lib
  58. cp -f $< $@
  59. $(graphene_lib): .lib/host_endian.h
  60. $(MAKE) -C ../lib target=$(abspath .lib)/
  61. Process2.manifest.sgx: Bootstrap.manifest.sgx
  62. else
  63. .IGNORE: $(preloads) $(executables)
  64. $(preloads) $(executables):
  65. endif
  66. export PYTHONPATH=../../Scripts
  67. .PHONY: regression
  68. regression:
  69. $(RM) pal-regression.xml
  70. $(MAKE) pal-regression.xml
  71. pal-regression.xml: test_pal.py $(call expand_target,$(target))
  72. python3 -m pytest --junit-xml $@ -v test_pal.py
  73. .PHONY: clean
  74. clean:
  75. rm -rf $(call expand_target,$(target)) $(preloads) *.tmp .lib *.cached *.sig *.d