From b3a89845429c77fac174387fc748b140fc282b16 Mon Sep 17 00:00:00 2001 From: Carsten Teibes Date: Sun, 18 Sep 2016 22:00:38 +0200 Subject: [PATCH] Autotools: Work around an absolute path problem Problem: `make distcheck` will perform a `./configure --prefix` call, that fails when using an absolute path for installing a file (in our case bash completion). This also happens when a user has no root rights and want to install in their /home or somewhere. Solution: bend the path to use the autotools $prefix variable. Unfortunately this has some sideeffects, because of using pkg-config directly and needing a way to disable this behaviour alltogether. This ugly (sic!) way attempts to work with either: * --with-bash-completion-dir == --with-bash-completion-dir=yes * --without-bash-completion-dir == --with-bash-completion-dir=no * --with-bash-completion-dir=/some/path While the last option will not work with --prefix installs, when given an absolute path without write permissions, it would be stupid to use one in a read-only dir anyways. --- Makefile.am | 6 +++--- configure.ac | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Makefile.am b/Makefile.am index 5493507d50..252d0ebb24 100644 --- a/Makefile.am +++ b/Makefile.am @@ -377,9 +377,9 @@ endif endif # bash completion -if HAVE_BASHCOMP -bashcompdir = @bashcompinstdir@ -dist_bashcomp_DATA = resources/unix/bash-completion/easyrpg-player +if HAVE_BASHCOMPLETION +bashcompletiondir = $(BASHCOMPLETION_DIR) +dist_bashcompletion_DATA = resources/unix/bash-completion/easyrpg-player endif # FIXME make filefinder work without external scripting diff --git a/configure.ac b/configure.ac index 977f964d99..b97252a71b 100644 --- a/configure.ac +++ b/configure.ac @@ -90,6 +90,21 @@ AS_IF([test "x$with_libspeexdsp" != "xno"],[ PKG_CHECK_MODULES([SPEEXDSP],[speexdsp],[AC_DEFINE(HAVE_LIBSPEEXDSP,[1],[Disable resampling support provided by libspeexdsp])],[auto_speexdsp=0]) ]) +# bash completion +AC_ARG_WITH([bash-completion-dir],[AS_HELP_STRING([--with-bash-completion-dir@<:@=DIR@:>@], + [Install the parameter auto-completion script for bash in DIR. @<:@default=auto@:>@])], + [],[with_bash_completion_dir=yes]) +AS_IF([test "x$with_bash_completion_dir" = "xyes"],[ + BASHCOMPLETION_DIR="`$PKG_CONFIG --silence-errors --define-variable=prefix="\${prefix}" --variable=completionsdir bash-completion`" +],[ + BASHCOMPLETION_DIR=$with_bash_completion_dir +]) +AS_IF([test "x$BASHCOMPLETION_DIR" = "x"],[ + BASHCOMPLETION_DIR="${datadir}/bash-completion/completions" +]) +AC_SUBST([BASHCOMPLETION_DIR]) +AM_CONDITIONAL([HAVE_BASHCOMPLETION], [test "x$with_bash_completion_dir" != "xno"]) + # Checks for header files. AC_CHECK_HEADERS([stdint.h stdlib.h string.h unistd.h wchar.h]) @@ -117,11 +132,6 @@ AS_IF([test x"$A2X" = "xno" && test ! -f "${srcdir}/resources/easyrpg-player.6"] AC_MSG_WARN([a2x is required to create the manual page])) AM_CONDITIONAL([HAVE_MANUAL], [test -f "${srcdir}/resources/easyrpg-player.6"]) -# bash completion -PKG_CHECK_VAR([bashcompinstdir],[bash-completion],[completionsdir]) -AM_CONDITIONAL([HAVE_BASHCOMP], [test "x$bashcompinstdir" != "x"]) -AC_SUBST(bashcompinstdir) - # Doxygen source documentation m4_include([builds/autoconf/m4/ax_prog_doxygen.m4]) DX_DOXYGEN_FEATURE(OFF)