Makefile.Test 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ifeq ($(SYS),)
  2. $(error include Makefile.config before $(lastword $(MAKEFILE_LIST)))
  3. endif
  4. ifeq ($(MAKEFILE_MANIFEST_DIR),)
  5. $(error include Makefile.manifest before $(lastword $(MAKEFILE_LIST)))
  6. endif
  7. SCRIPTS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
  8. SHIM_TEST_DIR = $(SCRIPTS_DIR)/../LibOS/shim/test
  9. PALDIR = $(abspath $(SCRIPTS_DIR)/../Pal/src)
  10. SHIMDIR = $(abspath $(SCRIPTS_DIR)/../LibOS/shim)
  11. RUNTIME = $(abspath $(SCRIPTS_DIR)/../Runtime)
  12. include $(SCRIPTS_DIR)/Makefile.rules
  13. CFLAGS += -std=gnu99
  14. # TODO: enable -Wunused-result
  15. CFLAGS += -Wno-unused-result
  16. CFLAGS-libos = -I$(SHIMDIR)/include -L$(SHIMDIR)/../glibc-build/libos
  17. CFLAGS-libos-debug = -I$(SHIMDIR)/include -I$(PALDIR)/../include/pal -I$(PALDIR)/../include/lib -fno-builtin -nostdlib
  18. CXXFLAGS-libos-debug = -I$(SHIMDIR)/include -I$(PALDIR)/../include/pal -I$(PALDIR)/../include/lib -fno-builtin -nostdlib
  19. LDFLAGS-libos-debug = -L$(SHIMDIR)/src -L$(PALDIR)/host/$(PAL_HOST) -Wl,-rpath-link=$(abspath $(RUNTIME)) -lpal -lsysdb_debug
  20. .PHONY: all
  21. ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
  22. all: pal_loader $(target) | $(exec_target) $(call expand_target_to_sgx,$(exec_target)) $(call expand_target_to_sig,$(exec_target))
  23. else
  24. all: pal_loader
  25. endif
  26. .PHONY: sgx-tokens
  27. sgx-tokens: $(call expand_target_to_token,$(exec_target))
  28. ifeq ($(ABSPATH_IN_MANIFEST),yes)
  29. manifest_rules = \
  30. -e 's:\$$(PAL):$(abspath $(RUNTIME))/pal_loader:g' \
  31. -e 's:\$$(PWD):$(PWD):g' \
  32. -e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
  33. -e 's:\$$(SHIMPATH):$(abspath $(RUNTIME))/libsysdb.so:g' \
  34. -e 's:\$$(LIBCDIR):$(abspath $(RUNTIME)):g' \
  35. $(extra_rules)
  36. else
  37. manifest_rules= \
  38. -e 's:\$$(PAL):$(abspath $(RUNTIME))/pal_loader:g' \
  39. -e 's:\$$(PWD):$(PWD):g' \
  40. -e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
  41. -e 's:\$$(SHIMPATH):$(RUNTIME)/libsysdb.so:g' \
  42. -e 's:\$$(LIBCDIR):$(RUNTIME):g' \
  43. $(extra_rules)
  44. endif
  45. pal_loader:
  46. ln -sf $(RUNTIME)/pal_loader
  47. ifeq ($(filter %clean,$(MAKECMDGOALS)),)
  48. include $(wildcard *.d)
  49. ifeq ($(SGX),1)
  50. include $(addsuffix .manifest.sgx.d,$(patsubst %.manifest,%,$(exec_target)))
  51. endif
  52. endif
  53. .PHONY: clean
  54. clean: $(clean-extra)
  55. $(RM) -r pal_loader $(exec_target) $(target) $(wildcard *.d) .output.* \
  56. *.sig *.token *.manifest.sgx
  57. .PHONY: distclean
  58. distclean: clean