diff --git a/meson.build b/meson.build index 91a7be5..0a56abe 100644 --- a/meson.build +++ b/meson.build @@ -16,10 +16,19 @@ gobject_dep = dependency('gobject-2.0', version: glib_ver_cmp) gtk_dep = dependency('gtk+-3.0', version: '>=3.22') libhandy_dep = dependency('libhandy-1', version: '>=1.1.90', fallback: ['libhandy', 'libhandy_dep'], default_options: ['introspection=disabled']) libnm_dep = dependency('libnm', version: '>=1.14') -phosh_plugins_dep = dependency('phosh-plugins', required: true, method: 'pkg-config') +phosh_plugins_dep = dependency('phosh-plugins') -libphosh_version = get_option('libphosh_version') != '' ? get_option('libphosh_version') : '0.44' -libphosh_dep = dependency('libphosh-' + libphosh_version, required: true, method: 'pkg-config') +# Detect libphosh API version +# Due to the unstable API, the version changes frequently, +# which makes it difficult to maintain in the package repository. +result = run_command('bash', 'scripts/detect-libphosh-api-version.sh') + +if result.returncode() != 0 + error(result.stderr()) +endif + +libphosh_version = result.stdout().strip() +libphosh_dep = dependency('libphosh-' + libphosh_version) plugin_deps = [ gobject_dep, diff --git a/scripts/detect-libphosh-api-version.sh b/scripts/detect-libphosh-api-version.sh new file mode 100644 index 0000000..7549b7e --- /dev/null +++ b/scripts/detect-libphosh-api-version.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +pc_file=$(find "/usr/lib64/pkgconfig" -maxdepth 1 -type f -name "libphosh-*.pc" | head -n 1) + +if [ -z "$pc_file" ]; then + echo "File libphosh-*.pc not found." + exit 1 +fi + +version=$(basename "$pc_file" | sed -E 's/^libphosh-([0-9.]+)\.pc$/\1/') + +if [ -z "$version" ]; then + echo "Can't detect version of $pc_file." + exit 1 +fi + +echo $version +exit 0