Skip to content

Commit

Permalink
Add ./configure switch to enable bash-completion
Browse files Browse the repository at this point in the history
This commit adds configure-time support for installing the included
bash-completion script. It is disabled by default, to avoid disrupting
existing assumptions about it.

The user can optionally specify the bash-completion directory. If not
specified, configure will use pkg-config to determine it from the
bash-completions package itself.

Closes #15.
  • Loading branch information
davidpolverari committed Apr 29, 2023
1 parent e53b4de commit 055d425
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@

AUTOMAKE_OPTIONS = foreign no-dependencies

if ENABLE_BASH_COMPLETION
bashcompletiondir = $(BASH_COMPLETION_DIR)
dist_bashcompletion_DATA = doc/dcfldd-bash_completion
endif

SUBDIRS = src

man_MANS = man/dcfldd.1
Expand Down
20 changes: 20 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ AM_INIT_AUTOMAKE
AC_CONFIG_HEADERS([config.h])
AC_CANONICAL_HOST

PKG_PROG_PKG_CONFIG

AC_PROG_CC
AC_PROG_CPP
AC_PROG_GCC_TRADITIONAL
Expand All @@ -46,12 +48,30 @@ AC_ARG_ENABLE([runtime-endian-check],
AC_HELP_STRING([--disable-runtime-endian-check], [disable runtime checks for endianness])
)

AC_ARG_WITH([bash-completion],
AS_HELP_STRING([--with-bash-completion[=PATH]],
[Install the bash auto-completion script in this directory. @<:@default=no@:>@]),
[],
[with_bash_completion=no]
)

AS_IF([test "x$enable_runtime_endian_check" != "xno"], [
dnl Do the stuff needed for enabling the feature
AC_DEFINE([RUNTIME_ENDIAN], 1, [Define whether to check for endianness during runtime])
])

if test "x$with_bash_completion" == "xyes"; then
PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0],
[BASH_COMPLETION_DIR="`$PKG_CONFIG --variable=completionsdir bash-completion`"],
[BASH_COMPLETION_DIR="$datadir/bash-completion/completions"])
else
BASH_COMPLETION_DIR="$with_bash_completion"
fi

AC_CHECK_DECLS([strtol, strtoul, strtoumax, strndup])

AC_SUBST([BASH_COMPLETION_DIR])
AM_CONDITIONAL([ENABLE_BASH_COMPLETION],[test "x$with_bash_completion" != "xno"])

AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT

0 comments on commit 055d425

Please sign in to comment.