Makefile 2.4 KB

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