configure: build & install shell completions when enabled

The --with-fish-functions-dir and --with-zsh-functions-dir options
currently have no effect on a normal build because the scripts/ directory
where they're used is not built. Add scripts/ to a normal build and
change the completion options to default to off to preserve the existing
behaviour.

Closes: #12906
This commit is contained in:
Dan Fandrich 2024-02-08 11:34:34 -08:00
parent dcf382453f
commit 89733e2dd2
3 changed files with 15 additions and 9 deletions

View File

@ -134,7 +134,7 @@ CLEANFILES = $(VC14_LIBVCXPROJ) $(VC14_SRCVCXPROJ) \
bin_SCRIPTS = curl-config bin_SCRIPTS = curl-config
SUBDIRS = lib src SUBDIRS = lib src scripts
DIST_SUBDIRS = $(SUBDIRS) tests packages scripts include docs DIST_SUBDIRS = $(SUBDIRS) tests packages scripts include docs
pkgconfigdir = $(libdir)/pkgconfig pkgconfigdir = $(libdir)/pkgconfig

View File

@ -3483,10 +3483,10 @@ AS_HELP_STRING([--with-zsh-functions-dir=PATH],[Install zsh completions to PATH]
AS_HELP_STRING([--without-zsh-functions-dir],[Do not install zsh completions]), AS_HELP_STRING([--without-zsh-functions-dir],[Do not install zsh completions]),
[OPT_ZSH_FPATH=$withval]) [OPT_ZSH_FPATH=$withval])
case "$OPT_ZSH_FPATH" in case "$OPT_ZSH_FPATH" in
no) default|no)
dnl --without-zsh-functions-dir option used dnl --without-zsh-functions-dir option used
;; ;;
default|yes) yes)
dnl --with-zsh-functions-dir option used without path dnl --with-zsh-functions-dir option used without path
ZSH_FUNCTIONS_DIR="$datarootdir/zsh/site-functions" ZSH_FUNCTIONS_DIR="$datarootdir/zsh/site-functions"
AC_SUBST(ZSH_FUNCTIONS_DIR) AC_SUBST(ZSH_FUNCTIONS_DIR)
@ -3497,6 +3497,7 @@ case "$OPT_ZSH_FPATH" in
AC_SUBST(ZSH_FUNCTIONS_DIR) AC_SUBST(ZSH_FUNCTIONS_DIR)
;; ;;
esac esac
AM_CONDITIONAL(USE_ZSH_COMPLETION, test x"$ZSH_FUNCTIONS_DIR" != x)
dnl ********************************************************************** dnl **********************************************************************
dnl Check for fish completion path dnl Check for fish completion path
@ -3508,10 +3509,10 @@ AS_HELP_STRING([--with-fish-functions-dir=PATH],[Install fish completions to PAT
AS_HELP_STRING([--without-fish-functions-dir],[Do not install fish completions]), AS_HELP_STRING([--without-fish-functions-dir],[Do not install fish completions]),
[OPT_FISH_FPATH=$withval]) [OPT_FISH_FPATH=$withval])
case "$OPT_FISH_FPATH" in case "$OPT_FISH_FPATH" in
no) default|no)
dnl --without-fish-functions-dir option used dnl --without-fish-functions-dir option used
;; ;;
default|yes) yes)
dnl --with-fish-functions-dir option used without path dnl --with-fish-functions-dir option used without path
CURL_CHECK_PKGCONFIG(fish) CURL_CHECK_PKGCONFIG(fish)
if test "$PKGCONFIG" != "no" ; then if test "$PKGCONFIG" != "no" ; then
@ -3527,6 +3528,7 @@ case "$OPT_FISH_FPATH" in
AC_SUBST(FISH_FUNCTIONS_DIR) AC_SUBST(FISH_FUNCTIONS_DIR)
;; ;;
esac esac
AM_CONDITIONAL(USE_FISH_COMPLETION, test x"$FISH_FUNCTIONS_DIR" != x)
dnl Now check for the very most basic headers. Then we can use these dnl Now check for the very most basic headers. Then we can use these
dnl ones as default-headers when checking for the rest! dnl ones as default-headers when checking for the rest!

View File

@ -40,7 +40,7 @@ $(ZSH_COMPLETION_FUNCTION_FILENAME): completion.pl
if CROSSCOMPILING if CROSSCOMPILING
@echo "NOTICE: we can't generate zsh completion when cross-compiling!" @echo "NOTICE: we can't generate zsh completion when cross-compiling!"
else # if not cross-compiling: else # if not cross-compiling:
@if ! test -x "$(PERL)"; then echo "No perl: can't install completion.pl"; exit 0; fi @if ! test -x "$(PERL)"; then echo "No perl: can't install completion script"; exit 0; fi
$(PERL) $(srcdir)/completion.pl --curl $(top_builddir)/src/curl$(EXEEXT) --shell zsh > $@ $(PERL) $(srcdir)/completion.pl --curl $(top_builddir)/src/curl$(EXEEXT) --shell zsh > $@
endif endif
@ -48,16 +48,20 @@ $(FISH_COMPLETION_FUNCTION_FILENAME): completion.pl
if CROSSCOMPILING if CROSSCOMPILING
@echo "NOTICE: we can't generate fish completion when cross-compiling!" @echo "NOTICE: we can't generate fish completion when cross-compiling!"
else # if not cross-compiling: else # if not cross-compiling:
@if ! test -x "$(PERL)"; then echo "No perl: can't install completion.pl"; exit 0; fi @if ! test -x "$(PERL)"; then echo "No perl: can't install completion scriptl"; exit 0; fi
$(PERL) $(srcdir)/completion.pl --curl $(top_builddir)/src/curl$(EXEEXT) --shell fish > $@ $(PERL) $(srcdir)/completion.pl --curl $(top_builddir)/src/curl$(EXEEXT) --shell fish > $@
endif endif
install-data-local: install-data-local:
if CROSSCOMPILING if CROSSCOMPILING
@echo "NOTICE: we can't install zsh completion when cross-compiling!" @echo "NOTICE: we can't install completion scripts when cross-compiling!"
else # if not cross-compiling: else # if not cross-compiling:
if USE_ZSH_COMPLETION
$(MKDIR_P) $(DESTDIR)$(ZSH_FUNCTIONS_DIR) $(MKDIR_P) $(DESTDIR)$(ZSH_FUNCTIONS_DIR)
$(MKDIR_P) $(DESTDIR)$(FISH_FUNCTIONS_DIR)
$(INSTALL_DATA) $(ZSH_COMPLETION_FUNCTION_FILENAME) $(DESTDIR)$(ZSH_FUNCTIONS_DIR)/$(ZSH_COMPLETION_FUNCTION_FILENAME) $(INSTALL_DATA) $(ZSH_COMPLETION_FUNCTION_FILENAME) $(DESTDIR)$(ZSH_FUNCTIONS_DIR)/$(ZSH_COMPLETION_FUNCTION_FILENAME)
endif
if USE_FISH_COMPLETION
$(MKDIR_P) $(DESTDIR)$(FISH_FUNCTIONS_DIR)
$(INSTALL_DATA) $(FISH_COMPLETION_FUNCTION_FILENAME) $(DESTDIR)$(FISH_FUNCTIONS_DIR)/$(FISH_COMPLETION_FUNCTION_FILENAME) $(INSTALL_DATA) $(FISH_COMPLETION_FUNCTION_FILENAME) $(DESTDIR)$(FISH_FUNCTIONS_DIR)/$(FISH_COMPLETION_FUNCTION_FILENAME)
endif endif
endif