Makefile 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. subdirs = native
  2. SYS ?= $(shell gcc -dumpmachine)
  3. export SYS
  4. PALDIR = $(level)../../../Pal/src
  5. SHIMDIR = $(level)../src
  6. LIBCDIR = $(level)../../glibc-build
  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:\$$(PALDIR):'$$RELDIR'$(PALDIR):g' \
  25. -e 's:\$$(PWD):$(PWD):g' \
  26. -e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
  27. -e 's:\$$(SHIMDIR):'$$RELDIR'$(SHIMDIR):g' \
  28. -e 's:\$$(SHIMPATH):'$$RELDIR'$(SHIMDIR)/libsysdb.so:g' \
  29. -e 's:\$$(LIBCDIR):'$$RELDIR'$(LIBCDIR):g' \
  30. $(extra_rules)
  31. relative-to = $(shell python -c "import os.path; print os.path.relpath(\"$(abspath $2)\",\"$(abspath $1)\")")
  32. %manifest: %manifest.template
  33. @echo [ $@ ]
  34. RELDIR=$(filter-out ./,$(call relative-to,$(dir $@),$(shell pwd))/) && \
  35. sed $(manifest_rules) $< > $@
  36. (grep -q '^#!' $@ && chmod +x $@) || true
  37. manifest: manifest.template
  38. @echo [ $@ ]
  39. sed $(manifest_rules) $< > $@
  40. pal pal_sec:
  41. ln -sf $(level)../../../Pal/src/$@ $@
  42. .PHONY: test clean
  43. clean: $(clean-extra) $(if $(level),,clean-subdirs)
  44. rm -rf $(call expand_target,$(exec_target)) $(target)
  45. build-subdirs:
  46. for f in $(subdirs); do (cd $$f; $(MAKE); cd ..); done
  47. ifeq ($(SYS),x86_64-linux-gnu)
  48. ifeq ($(level),)
  49. .PHONY: pack
  50. pack:
  51. for f in $(subdirs); do (cd $$f; $(MAKE) pack; cd ..); done
  52. endif
  53. endif
  54. clean-subdirs:
  55. for f in $(subdirs); do (cd $$f; $(MAKE) clean; cd ..); done