Makefile 1.7 KB

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