Makefile 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. prefix ?= usr/local
  2. BINARY = $(prefix)/bin/ion
  3. RELEASE = debug
  4. TOOLCHAIN ?= 1.53.0
  5. GIT_REVISION=git_revision.txt
  6. SRC=Cargo.toml Cargo.lock $(shell find src members -type f -wholename '*src/*.rs')
  7. VENDOR=.cargo/config vendor.tar.xz
  8. DEBUG ?= 0
  9. ifeq ($(DEBUG),0)
  10. ARGS += --release
  11. RELEASE = release
  12. endif
  13. VENDORED ?= 0
  14. ifeq ($(VENDORED),1)
  15. ARGSV += --frozen
  16. endif
  17. REDOX ?= 0
  18. ifeq ($(REDOX),1)
  19. undefine ARGSV
  20. ARGS += --target x86_64-unknown-redox
  21. TOOLCHAIN = nightly
  22. endif
  23. RUSTUP ?= 1
  24. ifeq ($(RUSTUP),1)
  25. TOOLCHAIN_ARG = +$(TOOLCHAIN)
  26. endif
  27. .PHONY: tests all clean distclean install uninstall manual
  28. all: $(SRC) $(GIT_REVISION)
  29. ifeq ($(REDOX),1)
  30. mkdir -p .cargo
  31. grep redox .cargo/config || cat redox_linker >> .cargo/config
  32. endif
  33. ifeq ($(VENDORED),1)
  34. tar pxf vendor.tar.xz
  35. endif
  36. cargo $(TOOLCHAIN_ARG) build $(ARGS) $(ARGSV)
  37. manual:
  38. rm -rf manual/builtins
  39. mkdir manual/builtins
  40. cargo build --features man
  41. echo -n "# Builtin commands" > manual/src/builtins.md
  42. for man in manual/builtins/*; do \
  43. echo -n "\n\n## " >> manual/src/builtins.md; \
  44. cat $$man >> manual/src/builtins.md; \
  45. done
  46. clean:
  47. cargo clean
  48. distclean: clean
  49. rm -rf vendor vendor.tar.xz .cargo git_revision.txt
  50. format:
  51. cargo +nightly fmt --all
  52. tests:
  53. cargo $(TOOLCHAIN_ARG) test $(ARGSV)
  54. TOOLCHAIN=$(TOOLCHAIN) bash tests/run_examples.sh
  55. for crate in members/*; do \
  56. cargo $(TOOLCHAIN_ARG) test $(ARGSV) --manifest-path $$crate/Cargo.toml || exit 1; \
  57. done
  58. install:
  59. install -Dm0755 target/$(RELEASE)/ion $(DESTDIR)/$(BINARY)
  60. uninstall:
  61. rm $(DESTDIR)/$(BINARY)
  62. vendor: $(VENDOR)
  63. version: $(GIT_REVISION)
  64. $(GIT_REVISION):
  65. git rev-parse HEAD > git_revision.txt
  66. $(VENDOR):
  67. rm -rf .cargo vendor vendor.tar.xz
  68. mkdir -p .cargo
  69. cargo vendor | head -n -1 > .cargo/config
  70. echo 'directory = "vendor"' >> .cargo/config
  71. tar pcfJ vendor.tar.xz vendor
  72. rm -rf vendor
  73. update-shells:
  74. if ! grep ion /etc/shells >/dev/null; then \
  75. echo $(BINARY) >> /etc/shells; \
  76. else \
  77. shell=$(shell grep ion /etc/shells); \
  78. if [ $$shell != $(BINARY) ]; then \
  79. sed -i -e "s#$$shell#$(BINARY)#g" /etc/shells; \
  80. fi \
  81. fi