diff --git a/completion/meson.build b/completion/meson.build index cdcfa968a..db279d1dc 100644 --- a/completion/meson.build +++ b/completion/meson.build @@ -1,28 +1,28 @@ generate_completions_program = find_program('generate_completions.py') -if bash_completion_dep.found() - bashcompletionsdir = bash_completion_dep.get_variable(pkgconfig: 'completionsdir') -else - bashcompletionsdir = get_option('datadir') / 'bash-completion' / 'completions' - message('bash-completion not found: using', get_option('prefix') / bashcompletionsdir, 'as a falback install directory') -endif - -if fish_dep.found() - fishcompletionsdir = fish_dep.get_variable(pkgconfig: 'completionsdir') -else - fishcompletionsdir = get_option('datadir') / 'fish' / 'completions' - message('fish not found: using', get_option('prefix') / fishcompletionsdir, 'as a fallback install directory') +if bashcompletionsdir != '' + custom_target( + 'bash-completion', + capture: true, + command: [generate_completions_program, meson.global_source_root() / 'src', 'bash'], + depends: [toolbox_go], + install: true, + install_dir: bashcompletionsdir, + output: 'toolbox' +) endif -custom_target( - 'bash-completion', - capture: true, - command: [generate_completions_program, meson.global_source_root() / 'src', 'bash'], - depends: [toolbox_go], - install: true, - install_dir: bashcompletionsdir, - output: 'toolbox' +if fishcompletionsdir != '' + custom_target( + 'fish-completion', + capture: true, + command: [generate_completions_program, meson.global_source_root() / 'src', 'fish'], + depends: [toolbox_go], + install: true, + install_dir: fishcompletionsdir, + output: 'toolbox.fish' ) +endif custom_target( 'zsh-completion', @@ -30,16 +30,6 @@ custom_target( command: [generate_completions_program, meson.global_source_root() / 'src', 'zsh'], depends: [toolbox_go], install: true, - install_dir: get_option('datadir') / 'zsh' / 'site-functions', + install_dir: zshcompletionsdir, output: '_toolbox' ) - -custom_target( - 'fish-completion', - capture: true, - command: [generate_completions_program, meson.global_source_root() / 'src', 'fish'], - depends: [toolbox_go], - install: true, - install_dir: fishcompletionsdir, - output: 'toolbox.fish' -) diff --git a/meson.build b/meson.build index 1a373801f..7c3b3b8af 100644 --- a/meson.build +++ b/meson.build @@ -18,8 +18,21 @@ go_md2man = find_program('go-md2man') shellcheck = find_program('shellcheck', required: false) skopeo = find_program('skopeo', required: false) -bash_completion_dep = dependency('bash-completion', required: false) -fish_dep = dependency('fish', required: false) +bashcompletionsdir = get_option('bash_completions_dir') +if bashcompletionsdir == '' + bash_completion_dep = dependency('bash-completion', required: false) + if bash_completion_dep.found() + bashcompletionsdir = bash_completion_dep.get_variable(pkgconfig: 'completionsdir') + endif +endif + +fishcompletionsdir = get_option('fish_completions_dir') +if fishcompletionsdir == '' + fish_completion_dep = dependency('fish', required: false) + if fish_completion_dep.found() + fishcompletionsdir = fish_completion_dep.get_variable(pkgconfig: 'completionsdir') + endif +endif migration_path_for_coreos_toolbox = get_option('migration_path_for_coreos_toolbox') profiledir = get_option('profile_dir') @@ -33,6 +46,11 @@ if tmpfilesdir == '' or not fs.exists('/run/.containerenv') endif endif +zshcompletionsdir = get_option('zsh_completions_dir') +if zshcompletionsdir == '' + zshcompletionsdir = join_paths(get_option('datadir'), 'zsh', 'site-functions') +endif + toolbox_sh = files('toolbox') if shellcheck.found() diff --git a/meson_options.txt b/meson_options.txt index 9afcc7b9c..b463d65eb 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,3 +1,15 @@ +option( + 'bash_completions_dir', + description: 'Directory for Bash completion scripts', + type: 'string', +) + +option( + 'fish_completions_dir', + description: 'Directory for fish completion scripts', + type: 'string', +) + option( 'migration_path_for_coreos_toolbox', description: 'Offer a migration path to users of github.com/coreos/toolbox', @@ -17,3 +29,9 @@ option( description: 'Directory for system-wide tmpfiles.d(5) files', type: 'string', ) + +option( + 'zsh_completions_dir', + description: 'Directory for Z shell completion scripts (default=$datadir/zsh/site-functions)', + type: 'string', +)