diff options
Diffstat (limited to 'mk')
-rw-r--r-- | mk/all.mk | 1 | ||||
-rw-r--r-- | mk/configure | 9 | ||||
-rw-r--r-- | mk/dist.mk | 4 | ||||
-rw-r--r-- | mk/shell.mk | 223 | ||||
-rw-r--r-- | mk/tools.mk | 3 |
5 files changed, 238 insertions, 2 deletions
@@ -25,6 +25,7 @@ include $(v)mk/lang-c.mk include $(v)mk/texinfo.mk include $(v)mk/man.mk include $(v)mk/i18n.mk +include $(v)mk/shell.mk include $(v)mk/clean.mk include $(v)mk/dist.mk include $(v)mk/tags.mk diff --git a/mk/configure b/mk/configure index 61f73e6..6351380 100644 --- a/mk/configure +++ b/mk/configure @@ -220,12 +220,14 @@ for option; do feature="WITH_${feature}" echo "${feature}" = yes >&20 export "${feature}"=yes + option="${option}=x" ;; (--without-*) feature="WITHOUT_${feature}" echo "${feature}" = yes >&20 export "${feature}"=yes + option="${option}=x" ;; (--enable-*=*) @@ -245,12 +247,14 @@ for option; do feature="DISABLE_${feature}" echo "${feature}" = yes >&20 export "${feature}"=yes + option="${option}=x" ;; (--disable-*) feature="DISABLE_${feature}" echo "${feature}" = yes >&20 export "${feature}"=yes + option="${option}=x" ;; # unrecognised @@ -711,7 +715,10 @@ test_enable () # # Enabled features, see ${0} for more infomation: # -# Internationalisation $(test_with GETTEXT yes) +# Internationalisation $(test_with GETTEXT yes) +# GNU Bash tab-completion $(test_with BASH yes) +# Fish tab-completion $(test_with FISH yes) +# Z shell tab-completion $(test_with ZSH yes) # # You can now run 'make && make install'. # @@ -38,12 +38,14 @@ GPG_KEY ?= __EVERYTHING_COMMON = $(_COPYING) $(_LICENSE) README __EVERYTHING_SRC = $(foreach F,$(_SRC),src/$(F)) __EVERYTHING_LOCALE = $(foreach L,$(LOCALES),po/$(L).po) +__EVERYTHING_SHELL = $(foreach F,$(_AUTO_COMPLETE),src/$(F).auto-completion) \ + $(foreach F,$(_AUTO_COMPLETE),$(foreac F,$(_SHELL_LOCALES),src/$(F).$(L),auto-completion)) __EVERYTHING_MK_ = all clean copy dist empty i18n lang-c lowerpath man path prologue tags texinfo tools __EVERYTHING_MK = $(foreach F,$(__EVERYTHING_MK_),mk/$(F).mk) mk/configure mk/README configure Makefile.in __EVERYTHING_MAN = $(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach P,$(_MAN_$(S)),doc/man/$(P).$(S))) \ $(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach L,$(MAN_LOCALES),$(foreach P,$(_MAN_$(L)_$(S)),doc/man/$(P).$(L).$(S)))) __EVERYTHING_ALL_COMMON = $(__EVERYTHING_COMMON) $(__EVERYTHING_MK) $(__EVERYTHING_MAN) \ - $(__EVERYTHING_LOCALE) $(__EVERYTHING_SRC) + $(__EVERYTHING_LOCALE) $(__EVERYTHING_SRC) $(__EVERYTHING_SHELL) # This one (__todo) if you have a todo file, but do not want it to be greped. __TO__ = TO __DO__ = DO diff --git a/mk/shell.mk b/mk/shell.mk new file mode 100644 index 0000000..49b50b7 --- /dev/null +++ b/mk/shell.mk @@ -0,0 +1,223 @@ +# Copyright (C) 2015 Mattias Andrée <maandree@member.fsf.org> +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. + + +#=== These rules are used for shell tab-completion using auto-auto-complete. ===# + + +# Enables the rules: +# shell Build tab-completion for all supported shells +# bash Build GNU Bash tab-completion +# fish Build fish tab-completion +# zhs Build Z shell tab-completion +# install-shell Install tab-completion for all supported shells +# install-bash Install GNU Bash tab-completion +# install-fish Install fish tab-completion +# install-zsh Install Z shell tab-completion +# +# This file is ignored unless +# _AUTO_COMPLETE is defined. +# +# _AUTO_COMPLETE shall list all commands that +# have an auto-auto-complete. These should be +# named src/$(COMMAND).auto-completion, where +# $(COMMAND) is the command with the script. +# If all auto-auto-complete scripts translations +# named src/$(COMMAND).$(LOCALE).auto-completion, +# SHELL_LOCALE can be set to install exactly +# on translation in place of the non-translated +# versions. +# +# Although not used by this file, you should +# define _SHELL_LOCALES that lists all available +# translations. (it is used by dist.mk.) +# +# You should also define _WITH_SHELL if you +# want shell tab-completion unless the user +# specifies otherwise. If you want it for +# just some shells, define _WITH_$(SHELL) +# for those shells instead of _WITH_SHELL. + + +ifdef _AUTO_COMPLETE + + +# HELP VARIABLES: + +# Include all that were not explicitly excluded? +ifdef _WITH_SHELL +_WITH_BASH = 1 +_WITH_FISH = 1 +_WITH_ZSH = 1 +endif + +# Include for GNU Bash? +ifdef WITH_BASH +__WITH_BASH = 1 +endif +ifndef WITH_BASH +ifndef WITHOUT_BASH +ifdef _WITH_BASH +__WITH_BASH = 1 +endif +endif +endif + +# Include for fish? +ifdef WITH_FISH +__WITH_FISH = 1 +endif +ifndef WITH_FISH +ifndef WITHOUT_FISH +ifdef _WITH_FISH +__WITH_FISH = 1 +endif +endif +endif + +# Include for Z Shell? +ifdef WITH_ZSH +__WITH_ZSH = 1 +endif +ifndef WITH_ZSH +ifndef WITHOUT_ZSH +ifdef _WITH_ZSH +__WITH_ZSH = 1 +endif +endif +endif + +# WHEN TO BUILD, INSTALL, AND UNINSTALL: + +all: shell +everything: shell +install: install-shell +install-doc: install-info install-dvi install-pdf install-ps install-html +uninstall: uninstall-shell + +shell: +install-shell: + +ifdef __WITH_BASH +shell: bash +install-shell: install-bash +endif +ifdef __WITH_FISH +shell: fish +install-shell: install-fish +endif +ifdef __WITH_ZSH +shell: zsh +install-shell: install-zsh +endif + + +# HELP VARIABLES: + +# Affixes on the source files. +ifdef SHELL_LOCALE +__AAC_L = .$(SHELL_LOCALE) +endif +__AAC = $(__AAC_L).auto-completion + +# Customised command name. +ifdef COMMAND +ifeq ($(shell $(PRINTF) '%s\n' $(COMMAND) | $(WC) -l),1) +ifeq ($(shell $(PRINTF) '%s\n' $(_AUTO_COMPLETE) | $(WC) -l),1) +__SHELL_COMMAND = "command=$(COMMAND)" +endif +endif +endif + + +# BUILD RULES: + +.PHONY: bash +bash: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).bash-completion) + +.PHONY: fish +fish: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).fish-completion) + +.PHONY: zsh +zsh: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).zsh-completion) + +bin/%.bash-completion: $(v)src/%$(__AAC) + @$(PRINTF_INFO) '\e[00;01;31mAUTO-AUTO-COMPLETE\e[34m %s\e[00m$A\n' "$@" + @$(MKDIR) -p bin + $(Q)$(AUTO_AUTO_COMPLETE) bash -o $@ -s $< $(__SHELL_COMMAND) #$Z + @$(ECHO_EMPTY) + +bin/%.fish-completion: $(v)src/%$(__AAC) + @$(PRINTF_INFO) '\e[00;01;31mAUTO-AUTO-COMPLETE\e[34m %s\e[00m$A\n' "$@" + @$(MKDIR) -p bin + $(Q)$(AUTO_AUTO_COMPLETE) fish -o $@ -s $< $(__SHELL_COMMAND) #$Z + @$(ECHO_EMPTY) + +bin/%.zsh-completion: $(v)src/%$(__AAC) + @$(PRINTF_INFO) '\e[00;01;31mAUTO-AUTO-COMPLETE\e[34m %s\e[00m$A\n' "$@" + @$(MKDIR) -p bin + $(Q)$(AUTO_AUTO_COMPLETE) zsh -o $@ -s $< $(__SHELL_COMMAND) #$Z + @$(ECHO_EMPTY) + + +# INSTALL RULES: + +.PHONY: install-bash +install-bash: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).bash-completion) + @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@" + $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(DATADIR)/bash-completion/completions" +ifndef __SHELL_COMMAND + $(Q)$(foreach F,$(_AUTO_COMPLETE),$(INSTALL_DATA) bin/$(F).bash-completion -- "$(DESTDIR)$(DATADIR)/bash-completion/completions/$(F)" &&) $(TRUE) +endif +ifdef __SHELL_COMMAND + $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(DATADIR)/bash-completion/completions/$(COMMAND)" +endif + @$(ECHO_EMPTY) + +.PHONY: install-fish +install-fish: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).fish-completion) + @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@" + $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(DATADIR)/fish/completions" +ifndef __SHELL_COMMAND + $(Q)$(foreach F,$(_AUTO_COMPLETE),$(INSTALL_DATA) bin/$(F).fish-completion -- "$(DESTDIR)$(DATADIR)/fish/completions/$(F).fish" &&) $(TRUE) +endif +ifdef __SHELL_COMMAND + $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(DATADIR)/fish/completions/$(COMMAND).fish" +endif + @$(ECHO_EMPTY) + +.PHONY: install-zsh +install-zsh: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).zsh-completion) + @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@" + $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(DATADIR)/zsh/site-functions" +ifndef __SHELL_COMMAND + $(Q)$(foreach F,$(_AUTO_COMPLETE),$(INSTALL_DATA) bin/$(F).zsh-completion -- "$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(F)" &&) $(TRUE) +endif +ifdef __SHELL_COMMAND + $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(COMMAND)" +endif + @$(ECHO_EMPTY) + + +# UNINSTALL RULES: + +.PHONY: uninstall-shell +uninstall-shell: +ifndef __SHELL_COMMAND + -$(Q)$(RM) -- $(foreach F,$(_AUTO_COMPLETE),"$(DESTDIR)$(DATADIR)/bash-completion/completions/$(F)") + -$(Q)$(RM) -- $(foreach F,$(_AUTO_COMPLETE),"$(DESTDIR)$(DATADIR)/fish/completions/$(F).fish") + -$(Q)$(RM) -- $(foreach F,$(_AUTO_COMPLETE),"$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(F)") +endif +ifdef __SHELL_COMMAND + -$(Q)$(RM) -- "$(DESTDIR)$(DATADIR)/bash-completion/completions/$(COMMAND)" + -$(Q)$(RM) -- "$(DESTDIR)$(DATADIR)/fish/completions/$(COMMAND).fish" + -$(Q)$(RM) -- "$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(COMMAND)" +endif + + +endif + diff --git a/mk/tools.mk b/mk/tools.mk index 5801d4f..63d6d66 100644 --- a/mk/tools.mk +++ b/mk/tools.mk @@ -147,6 +147,9 @@ BZIP2_COMPRESS ?= $(BZIP2) -k9 XZ ?= xz XZ_COMPRESS ?= $(XZ) -ke9 +# Part of auto-auto-complete: +AUTO_AUTO_COMPLETE ?= auto-auto-complete + # Change to $(TRUE) to suppress the bold red and blue output. ifndef PRINTF_INFO |