Makefile 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 $(PALDIR)/Makefile.Test
  24. .PHONY: all
  25. all: pal_loader $(target) $(if $(level),,build-subdirs) | $(call expand_target,$(exec_target))
  26. ifeq ($(DEBUG),1)
  27. CC += -g
  28. CXX += -g
  29. endif
  30. export DEBUG
  31. ifeq ($(WERROR),1)
  32. CFLAGS += -Werror
  33. endif
  34. ifeq ($(ABSPATH_IN_MANIFEST),yes)
  35. manifest_rules = \
  36. -e 's:\$$(PAL):$(abspath $(RUNTIME))/$(PAL_LOADER):g' \
  37. -e 's:\$$(PWD):$(PWD):g' \
  38. -e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
  39. -e 's:\$$(SHIMPATH):$(abspath $(RUNTIME))/libsysdb.so:g' \
  40. -e 's:\$$(LIBCDIR):$(abspath $(RUNTIME)):g' \
  41. $(extra_rules)
  42. else
  43. manifest_rules= \
  44. -e 's:\$$(PAL):$(abspath $(RUNTIME))/$(PAL_LOADER):g' \
  45. -e 's:\$$(PWD):$(PWD):g' \
  46. -e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
  47. -e 's:\$$(SHIMPATH):'$$RELDIR'$(RUNTIME)/libsysdb.so:g' \
  48. -e 's:\$$(LIBCDIR):'$$RELDIR'$(RUNTIME):g' \
  49. $(extra_rules)
  50. endif
  51. pal_loader:
  52. ln -sf $(RUNTIME)/pal_loader
  53. relative-to = $(shell python -c "import os.path; print os.path.relpath(\"$(abspath $2)\",\"$(abspath $1)\")")
  54. %manifest: %manifest.template
  55. @echo [ $@ ]
  56. RELDIR=$(filter-out ./,$(call relative-to,$(dir $@),$(shell pwd))/) && \
  57. sed $(manifest_rules) $< > $@
  58. (grep -q '^#!' $@ && chmod +x $@) || true
  59. manifest: manifest.template
  60. @echo [ $@ ]
  61. sed $(manifest_rules) $< > $@
  62. .PHONY: clean
  63. clean: $(clean-extra) $(if $(level),,clean-subdirs)
  64. rm -rf pal_loader $(call expand_target,$(exec_target)) $(target) $(wildcard *.d)
  65. .PHONY: build-subdirs
  66. build-subdirs:
  67. for f in $(subdirs); do (cd $$f; $(MAKE); cd ..); done
  68. .PHONY: clean-subdirs
  69. clean-subdirs:
  70. for f in $(subdirs); do (cd $$f; $(MAKE) clean; cd ..); done