summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIñigo Martínez <inigomartinez@gmail.com>2021-07-26 10:22:41 +0200
committerIñigo Martínez <inigomartinez@gmail.com>2021-07-26 12:37:46 +0200
commitd67e369f95f142a170a6c525c3d1140d1f18e33f (patch)
treef8283eaea10d6bebd44a2b87d5dc7fba2cd6b289
parent53a35e1e6fc76b010751d2b134d48f9d44ce8cd3 (diff)
downloadlibmbim-d67e369f95f142a170a6c525c3d1140d1f18e33f.tar.gz
build,meson: make bash-completion file install optional
`mbimcli` provides a bash-completion file. To install this file `bash-completion`'s pkg-file is checked to set the proper installation directory. This has been made optional.
-rw-r--r--meson.build14
-rw-r--r--meson_options.txt2
-rw-r--r--meson_post_install.py9
-rw-r--r--src/mbimcli/meson.build10
4 files changed, 26 insertions, 9 deletions
diff --git a/meson.build b/meson.build
index 26a6714..53a7d9d 100644
--- a/meson.build
+++ b/meson.build
@@ -21,6 +21,7 @@ mbim_micro_version = version_array[2].to_int()
mbim_prefix = get_option('prefix')
mbim_bindir = get_option('bindir')
+mbim_datadir = get_option('datadir')
mbim_includedir = get_option('includedir')
mbim_libexecdir = get_option('libexecdir')
mbim_mandir = get_option('mandir')
@@ -138,7 +139,15 @@ glib_deps = declare_dependency(
compile_args: c_flags,
)
-bash_completion_completionsdir = dependency('bash-completion').get_pkgconfig_variable('completionsdir', define_variable: ['prefix', mbim_prefix])
+enable_bash_completion = get_option('bash_completion')
+if enable_bash_completion
+ bash_completion_dep = dependency('bash-completion')
+ bash_completion_completionsdir = bash_completion_dep.get_pkgconfig_variable(
+ 'completionsdir',
+ # bash-completion 2.10 changed the substitutions
+ define_variable: bash_completion_dep.version().version_compare('>= 2.10') ? ['datadir', mbim_datadir] : ['prefix', mbim_prefix],
+ )
+endif
glib_prefix = glib_dep.get_pkgconfig_variable('prefix')
@@ -191,7 +200,7 @@ configure_file(
meson.add_install_script(
'meson_post_install.py',
get_option('bindir'),
- bash_completion_completionsdir,
+ enable_bash_completion ? bash_completion_completionsdir : '',
)
output = '\n' + meson.project_name() + ' ' + meson.project_version() + '\n\n'
@@ -199,6 +208,7 @@ output += ' Build\n'
output += ' compiler: ' + cc.get_id() + '\n'
output += ' cflags: ' + ' '.join(cc_flags) + '\n'
output += ' Documentation: ' + enable_gtk_doc.to_string() + '\n'
+output += ' bash completion: ' + enable_bash_completion.to_string() + '\n'
output += ' gobject introspection: ' + enable_gir.to_string() + '\n\n'
output += ' System paths\n'
output += ' prefix: ' + mbim_prefix + '\n'
diff --git a/meson_options.txt b/meson_options.txt
index db87a7f..462c638 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -4,3 +4,5 @@ option('udevdir', type: 'string', value: '', description: 'where udev base direc
option('introspection', type: 'boolean', value: true, description: 'build introspection support')
option('gtk_doc', type: 'boolean', value: false, description: 'use gtk-doc to build documentation')
+
+option('bash_completion', type: 'boolean', value: true, description: 'install bash completion files')
diff --git a/meson_post_install.py b/meson_post_install.py
index fbf40fa..a130623 100644
--- a/meson_post_install.py
+++ b/meson_post_install.py
@@ -9,6 +9,9 @@ prefix = os.environ['MESON_INSTALL_DESTDIR_PREFIX']
bindir = os.path.join(prefix, sys.argv[1])
subprocess.check_call(['chmod', '755', os.path.join(bindir, 'mbim-network')])
-bash_completion_completionsdir = os.path.join(prefix, sys.argv[2])
-os.rename(os.path.join(bash_completion_completionsdir, 'mbimcli-completion'),
- os.path.join(bash_completion_completionsdir, 'mbimcli'))
+bash_completion_completionsdir = sys.argv[2]
+if bash_completion_completionsdir:
+ if not os.path.isabs(bash_completion_completionsdir):
+ bash_completion_completionsdir = os.path.join(prefix, bash_completion_completionsdir)
+ os.rename(os.path.join(bash_completion_completionsdir, 'mbimcli-completion'),
+ os.path.join(bash_completion_completionsdir, 'mbimcli'))
diff --git a/src/mbimcli/meson.build b/src/mbimcli/meson.build
index df42c96..672c87b 100644
--- a/src/mbimcli/meson.build
+++ b/src/mbimcli/meson.build
@@ -32,7 +32,9 @@ mbimcli = executable(
install: true,
)
-install_data(
- 'mbimcli-completion',
- install_dir: bash_completion_completionsdir,
-)
+if enable_bash_completion
+ install_data(
+ 'mbimcli-completion',
+ install_dir: bash_completion_completionsdir,
+ )
+endif