diff --git a/Makefile.am b/Makefile.am index 8a933e1..0b4dc7e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,7 +8,7 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = doc examples include src tests +SUBDIRS = completions doc examples include src tests pkgconfig_DATA = arif.pc diff --git a/completions/Makefile.am b/completions/Makefile.am new file mode 100644 index 0000000..8418230 --- /dev/null +++ b/completions/Makefile.am @@ -0,0 +1,23 @@ +# +# Copyright (C) 2023 CismonX +# +# 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. +# + +dist_bashcompletion_DATA = +dist_zshcompletion_DATA = + + +if INSTALL_BASH_COMPLETION + + dist_bashcompletion_DATA += bash/arify + +endif # INSTALL_BASH_COMPLETION + +if INSTALL_ZSH_COMPLETION + + dist_zshcompletion_DATA += zsh/_arify + +endif # INSTALL_ZSH_COMPLETION diff --git a/completions/bash/arify b/completions/bash/arify new file mode 100644 index 0000000..677b348 --- /dev/null +++ b/completions/bash/arify @@ -0,0 +1,5 @@ +_arify() +{ +} + +complete -F _arify arify diff --git a/completions/zsh/_arify b/completions/zsh/_arify new file mode 100644 index 0000000..cfe03dc --- /dev/null +++ b/completions/zsh/_arify @@ -0,0 +1 @@ +#compdef arify diff --git a/configure.ac b/configure.ac index 4819c88..1bb8bb0 100644 --- a/configure.ac +++ b/configure.ac @@ -68,6 +68,22 @@ ARIF_ARG_ENABLE([arify], [yes], [the arify command line tool], [], [ ]) AM_CONDITIONAL([BUILD_ARIFY], [test x${enable_arify} != xno]) +ARIF_ARG_WITHDIR([bashcompletion], + ['$(datadir)/bash-completion/completions'], [bash completion], +[ + AS_VAR_SET([with_bashcompletiondir], [no]) +]) +AM_CONDITIONAL([INSTALL_BASH_COMPLETION], + [test x${with_bashcompletiondir} != xno]) + +ARIF_ARG_WITHDIR([zshcompletion], + ['$(datadir)/zsh/site-functions'], [zsh completion], +[ + AS_VAR_SET([with_zshcompletiondir], [no]) +]) +AM_CONDITIONAL([INSTALL_ZSH_COMPLETION], + [test x${with_zshcompletiondir} != xno]) + # -- Checks for compiler builtins and attributes -- ARIF_TRY_APPLY([AX_GCC_BUILTIN], [__builtin_unreachable]) @@ -95,6 +111,7 @@ AC_CHECK_FUNCS([atexit memchr strcasecmp]) PKG_INSTALLDIR() AC_CONFIG_FILES([ Makefile + completions/Makefile doc/Makefile examples/Makefile include/Makefile diff --git a/m4/arif_ac.m4 b/m4/arif_ac.m4 index 8425f42..7c15a5d 100644 --- a/m4/arif_ac.m4 +++ b/m4/arif_ac.m4 @@ -33,6 +33,38 @@ AC_DEFUN([ARIF_ARG_ENABLE], [ m4_popdef([enable_var_]) ]) +dnl +dnl ARIF_ARG_WITHDIR(name, default-value, description, [action-if-not-given], +dnl [action-if-with], [action-if-without]) +dnl +dnl Provides an option to specify a custom non-standard directory where some +dnl objects can be installed to. +dnl +AC_DEFUN([ARIF_ARG_WITHDIR], [ + m4_pushdef([withdir_var_], [with_]m4_translit([$1], [-+.], [___])[dir]) + AC_MSG_CHECKING(m4_normalize([for $3 directory])) + AC_ARG_WITH([$1dir], m4_normalize([ + AS_HELP_STRING([--with-$1dir[[=$2]]], [$3 directory]) + ]), [ + AS_VAR_IF(withdir_var_, [yes], [ + AS_VAR_SET(withdir_var_, [$2]) + ]) + ], [ + $4 + AS_VAR_IF(withdir_var_, [yes], [ + AS_VAR_SET(withdir_var_, [$2]) + ]) + ]) + AS_VAR_IF(withdir_var_, [no], [ + AC_MSG_RESULT([no]) + $5 + ], [ + AC_SUBST([$1dir], "${withdir_var_}") + AC_MSG_RESULT(${withdir_var_}) + $6 + ]) + m4_popdef([withdir_var_]) +]) dnl dnl ARIF_CHECK_PKG(package, version, package-name, [action-if-not-given],