From 012b92b115ed96cc66818adbd31557765078be65 Mon Sep 17 00:00:00 2001 From: Mart Raudsepp Date: Fri, 22 Feb 2019 22:06:18 +0200 Subject: [PATCH] build: Allow passing bash-completion dir and have a generic fallback With autotools the installation path was just hardcoded to the usual location. In meson it was made to always check the path from bash-completion.pc, but some downstream might want to install the file without a bash-completion build-dep. Allow installing the completion file to a passed directory, and add back the fallback path if an explicit directory isn't passed and bash-completion package isn't found. This is also what the tracker project does. --- meson.build | 20 ++++++++++++++++---- meson_options.txt | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index aa87823..a74d5c7 100644 --- a/meson.build +++ b/meson.build @@ -48,10 +48,22 @@ glib_dep = dependency('glib-2.0', version: '>= 2.44.0') gio_module_dir = gio_dep.get_pkgconfig_variable('giomoduledir', define_variable: ['libdir', dconf_libdir]) dbus_session_service_dir = dependency('dbus-1').get_pkgconfig_variable('session_bus_services_dir', define_variable: ['datadir', dconf_datadir]) -enable_bash_completion = get_option('bash_completion') -if enable_bash_completion - # FIXME: the `.pc` file is wrong because `completionsdir` should be relative to `datadir`, not `prefix` - completions_dir = dependency('bash-completion').get_pkgconfig_variable('completionsdir', define_variable: ['prefix', dconf_prefix]) +enable_bash_completion = false +if get_option('bash_completion_dir') == 'yes' or get_option('bash_completion_dir') == 'auto' + bash_completion_package = dependency('bash-completion', required: false) + if bash_completion_package.found() + # FIXME: the `.pc` file is wrong because `completionsdir` should be relative to `datadir`, not `prefix` + completions_dir = bash_completion_package.get_pkgconfig_variable('completionsdir', + define_variable: [ 'prefix', dconf_prefix ]) + else + completions_dir = join_paths(dconf_datadir, 'bash-completion', 'completions') + endif + enable_bash_completion = true +elif get_option('bash_completion_dir') == 'no' or get_option('bash_completion_dir') == '' + enable_bash_completion = false +else + enable_bash_completion = true + completions_dir = get_option('bash_completion_dir') endif configure_file( diff --git a/meson_options.txt b/meson_options.txt index a2794ce..3ac4ede 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,4 +1,4 @@ -option('bash_completion', type: 'boolean', value: true, description: 'install bash completion files') +option('bash_completion_dir', type: 'string', value: 'yes', description: 'directory to install Bash completion files (or "yes" for default directory, "no" to disable installation)') option('man', type: 'boolean', value: true, description: 'generate man pages') option('gtk_doc', type: 'boolean', value: false, description: 'use gtk-doc to build documentation') option('vapi', type: 'boolean', value: true, description: 'install dconf client vapi') -- 2.17.0