Makefile.Test 2.6 KB

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