Makefile 2.1 KB

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