Makefile 2.1 KB

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