Makefile 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. subdirs = native
  2. SYS ?= $(shell gcc -dumpmachine)
  3. export SYS
  4. PALDIR = $(level)../../../Pal/src
  5. SHIMDIR = $(level)../src
  6. LIBCDIR = $(level)../../../Runtime
  7. CC = gcc
  8. CXX = g++
  9. CFLAGS = -std=gnu99
  10. CFLAGS-debug = $(CFLAGS) -I$(SHIMDIR)/../include -I$(PALDIR)/../include/pal -I$(PALDIR)/../lib
  11. LDFLAGS =
  12. LDFLAGS-debug = $(LDFLAGS) -L$(SHIMDIR) -L$(PALDIR) \
  13. -Wl,-rpath-link=$(abspath $(SHIMDIR)) \
  14. -Wl,-rpath-link=$(abspath $(PALDIR))
  15. default: all
  16. include $(PALDIR)/Makefile.Test
  17. all: $(target) $(if $(level),,build-subdirs) | $(call expand_target,$(exec_target))
  18. ifeq ($(DEBUG),1)
  19. CC += -g
  20. CXX += -g
  21. endif
  22. export DEBUG
  23. manifest_rules = \
  24. -e 's:\$$(PAL):$(abspath $(level)pal_loader):g' \
  25. -e 's:\$$(PALDIR):'$$RELDIR'$(PALDIR):g' \
  26. -e 's:\$$(PWD):$(PWD):g' \
  27. -e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
  28. -e 's:\$$(SHIMDIR):'$$RELDIR'$(SHIMDIR):g' \
  29. -e 's:\$$(SHIMPATH):'$$RELDIR'$(SHIMDIR)/libsysdb.so:g' \
  30. -e 's:\$$(LIBCDIR):'$$RELDIR'$(LIBCDIR):g' \
  31. $(extra_rules)
  32. relative-to = $(shell python -c "import os.path; print os.path.relpath(\"$(abspath $2)\",\"$(abspath $1)\")")
  33. %manifest: %manifest.template
  34. @echo [ $@ ]
  35. RELDIR=$(filter-out ./,$(call relative-to,$(dir $@),$(shell pwd))/) && \
  36. sed $(manifest_rules) $< > $@
  37. (grep -q '^#!' $@ && chmod +x $@) || true
  38. manifest: manifest.template
  39. @echo [ $@ ]
  40. sed $(manifest_rules) $< > $@
  41. .PHONY: test clean
  42. clean: $(clean-extra) $(if $(level),,clean-subdirs)
  43. rm -rf $(call expand_target,$(exec_target)) $(target)
  44. build-subdirs:
  45. for f in $(subdirs); do (cd $$f; $(MAKE); cd ..); done
  46. ifeq ($(SYS),x86_64-linux-gnu)
  47. ifeq ($(level),)
  48. .PHONY: pack
  49. pack:
  50. for f in $(subdirs); do (cd $$f; $(MAKE) pack; cd ..); done
  51. endif
  52. endif
  53. clean-subdirs:
  54. for f in $(subdirs); do (cd $$f; $(MAKE) clean; cd ..); done