Makefile 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. DESTDIR =
  2. PREFIX = /usr/local
  3. override define compdir
  4. ifndef $(1)
  5. $(1) := $$(or $$(shell pkg-config --variable=completionsdir $(2) 2>/dev/null),$(3))
  6. endif
  7. endef
  8. $(eval $(call compdir,BASHDIR,bash-completion,$(PREFIX)/etc/bash_completion.d))
  9. ZSHDIR = /usr/share/zsh/vendor-completions
  10. $(eval $(call compdir,FISHDIR,fish,$(PREFIX)/share/fish/vendor_completions.d))
  11. FEATURES ?= default
  12. CARGO_OPTS := --no-default-features --features "$(FEATURES)"
  13. all: target/release/exa
  14. build: target/release/exa
  15. target/release/exa:
  16. cargo build --release $(CARGO_OPTS)
  17. install: install-exa install-man
  18. install-exa: target/release/exa
  19. install -m755 -- target/release/exa "$(DESTDIR)$(PREFIX)/bin/"
  20. install-man:
  21. install -dm755 -- "$(DESTDIR)$(PREFIX)/bin/" "$(DESTDIR)$(PREFIX)/share/man/man1/"
  22. install -m644 -- contrib/man/exa.1 "$(DESTDIR)$(PREFIX)/share/man/man1/"
  23. install-bash-completions:
  24. install -m644 -- contrib/completions.bash "$(DESTDIR)$(BASHDIR)/exa"
  25. install-zsh-completions:
  26. install -m644 -- contrib/completions.zsh "$(DESTDIR)$(ZSHDIR)/_exa"
  27. install-fish-completions:
  28. install -m644 -- contrib/completions.fish "$(DESTDIR)$(FISHDIR)/exa.fish"
  29. test: target/release/exa
  30. cargo test --release $(CARGO_OPTS)
  31. uninstall:
  32. -rm -f -- "$(DESTDIR)$(PREFIX)/share/man/man1/exa.1"
  33. -rm -f -- "$(DESTDIR)$(PREFIX)/bin/exa"
  34. -rm -f -- "$(DESTDIR)$(BASHDIR)/exa"
  35. -rm -f -- "$(DESTDIR)$(ZSHDIR)/_exa"
  36. -rm -f -- "$(DESTDIR)$(FISHDIR)/exa.fish"
  37. clean:
  38. cargo clean
  39. preview-man:
  40. man contrib/man/exa.1
  41. help:
  42. @echo 'Available make targets:'
  43. @echo ' all - build exa (default)'
  44. @echo ' build - build exa'
  45. @echo ' clean - run `cargo clean`'
  46. @echo ' install - build and install exa and manpage'
  47. @echo ' install-exa - build and install exa'
  48. @echo ' install-man - install the manpage'
  49. @echo ' test - run `cargo test`'
  50. @echo ' uninstall - uninstall fish, manpage, and completions'
  51. @echo ' preview-man - preview the manpage without installing'
  52. @echo ' help - print this help'
  53. @echo
  54. @echo ' install-bash-completions - install bash completions into $$BASHDIR'
  55. @echo ' install-zsh-completions - install zsh completions into $$ZSHDIR'
  56. @echo ' install-fish-completions - install fish completions into $$FISHDIR'
  57. @echo
  58. @echo 'Variables:'
  59. @echo ' DESTDIR - A path that'\''s prepended to installation paths (default: "")'
  60. @echo ' PREFIX - The installation prefix for everything except zsh completions (default: /usr/local)'
  61. @echo ' BASHDIR - The directory to install bash completions in (default: $$PREFIX/etc/bash_completion.d)'
  62. @echo ' ZSHDIR - The directory to install zsh completions in (default: /usr/share/zsh/vendor-completions)'
  63. @echo ' FISHDIR - The directory to install fish completions in (default: $$PREFIX/share/fish/vendor_completions.d)'
  64. @echo ' FEATURES - The cargo feature flags to use. Set to an empty string to disable git support'
  65. .PHONY: all build target/release/exa install-exa install-man preview-man \
  66. install-bash-completions install-zsh-completions install-fish-completions \
  67. clean uninstall help