Makefile.Test 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. SHIM_TEST_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
  2. SYS ?= $(shell gcc -dumpmachine)
  3. export SYS
  4. PALDIR = $(SHIM_TEST_DIR)/../../../Pal/src
  5. SHIMDIR = $(SHIM_TEST_DIR)/../src
  6. RUNTIME = $(SHIM_TEST_DIR)/../../../Runtime
  7. ifeq ($(SGX),1)
  8. PAL_LOADER = pal_loader SGX
  9. else
  10. PAL_LOADER = pal_loader
  11. endif
  12. CC = gcc
  13. CXX = g++
  14. CFLAGS = -Wall -std=gnu99
  15. CXXFLAGS = -Wall -std=c++14
  16. LDFLAGS =
  17. CFLAGS-libos = -I$(SHIMDIR)/../include -L$(SHIMDIR)/../../glibc-build/libos
  18. CFLAGS-libos-debug = -I$(SHIMDIR)/../include -I$(PALDIR)/../include/pal -I$(PALDIR)/../lib -fno-builtin -nostdlib
  19. CXXFLAGS-libos-debug = -I$(SHIMDIR)/../include -I$(PALDIR)/../include/pal -I$(PALDIR)/../lib -fno-builtin -nostdlib
  20. LDFLAGS-libos-debug = -L$(SHIMDIR) -L$(PALDIR)/host/$(PAL_HOST) -Wl,-rpath-link=$(abspath $(RUNTIME)) -lpal -lsysdb_debug
  21. .PHONY: default
  22. default: all
  23. include $(SHIM_TEST_DIR)/../../../Makefile.configs
  24. include $(SHIM_TEST_DIR)/../../../Makefile.rules
  25. include $(PALDIR)/Makefile.Test
  26. .PHONY: all
  27. all: pal_loader $(target) | $(call expand_target,$(exec_target))
  28. .PHONY: sgx-tokens
  29. sgx-tokens: $(call expand_target_to_token,$(exec_target))
  30. ifeq ($(DEBUG),1)
  31. CC += -g
  32. CXX += -g
  33. endif
  34. export DEBUG
  35. ifeq ($(WERROR),1)
  36. CFLAGS += -Werror
  37. endif
  38. ifeq ($(ABSPATH_IN_MANIFEST),yes)
  39. manifest_rules = \
  40. -e 's:\$$(PAL):$(abspath $(RUNTIME))/$(PAL_LOADER):g' \
  41. -e 's:\$$(PWD):$(PWD):g' \
  42. -e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
  43. -e 's:\$$(SHIMPATH):$(abspath $(RUNTIME))/libsysdb.so:g' \
  44. -e 's:\$$(LIBCDIR):$(abspath $(RUNTIME)):g' \
  45. $(extra_rules)
  46. else
  47. manifest_rules= \
  48. -e 's:\$$(PAL):$(abspath $(RUNTIME))/$(PAL_LOADER):g' \
  49. -e 's:\$$(PWD):$(PWD):g' \
  50. -e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
  51. -e 's:\$$(SHIMPATH):'$$RELDIR'$(RUNTIME)/libsysdb.so:g' \
  52. -e 's:\$$(LIBCDIR):'$$RELDIR'$(RUNTIME):g' \
  53. $(extra_rules)
  54. endif
  55. pal_loader:
  56. ln -sf $(RUNTIME)/pal_loader
  57. relative-to = $(shell python -c "import os.path; print os.path.relpath(\"$(abspath $2)\",\"$(abspath $1)\")")
  58. %.manifest: %.manifest.template
  59. @echo [ $@ ]
  60. RELDIR=$(filter-out ./,$(call relative-to,$(dir $@),$(shell pwd))/) && \
  61. sed $(manifest_rules) $< > $@
  62. (grep -q '^#!' $@ && chmod +x $@) || true
  63. manifest: manifest.template
  64. @echo [ $@ ]
  65. sed $(manifest_rules) $< > $@
  66. ifeq ($(filter clean,$(MAKECMDGOALS)),)
  67. ifeq ($(SGX),1)
  68. include $(addsuffix .manifest.sgx.d,$(patsubst %.manifest,%,$(exec_target)))
  69. endif
  70. endif
  71. .PHONY: clean
  72. clean: $(clean-extra)
  73. rm -rf pal_loader $(call expand_target,$(exec_target)) $(target) $(wildcard *.d) .output.* \
  74. *.sig *.token *.manifest.sgx