Makefile.Test 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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):$(RUNTIME)/libsysdb.so:g' \
  53. -e 's:\$$(LIBCDIR):$(RUNTIME):g' \
  54. $(extra_rules)
  55. endif
  56. pal_loader:
  57. ln -sf $(RUNTIME)/pal_loader
  58. %.manifest: %.manifest.template
  59. $(call cmd,manifest,$(manifest_rules))
  60. manifest: manifest.template
  61. $(call cmd,manifest,$(manifest_rules))
  62. ifeq ($(filter %clean,$(MAKECMDGOALS)),)
  63. ifeq ($(SGX),1)
  64. include $(addsuffix .manifest.sgx.d,$(patsubst %.manifest,%,$(exec_target)))
  65. endif
  66. endif
  67. .PHONY: clean
  68. clean: $(clean-extra)
  69. rm -rf pal_loader $(call expand_target,$(exec_target)) $(target) $(wildcard *.d) .output.* \
  70. *.sig *.token *.manifest.sgx
  71. .PHONY: distclean
  72. distclean: clean