Makefile 2.5 KB

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