From 8b0a26f06db0331fedd50dc0edf47f18917bca81 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Sun, 7 Feb 2016 17:27:42 +0200 Subject: [PATCH] build: support for alternative versions of libsystemd pkgconfig While pkgconfig is supposed to be a distribution and version neutral way of detecting packages, it doesn't always work this way. The sd_notify() manual page documents that sd_notify is available via the libsystemd package, but on centos 7.0 it is only available via the libsystemd-daemon package (on centos 7.1+ it works as expected). Fix by allowing for alternate version of package names, testing each one until a match is found. Fixes #879. Message-Id: <1454858862-5239-1-git-send-email-avi@scylladb.com> --- configure.py | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/configure.py b/configure.py index 09119e2f75..4f462a65cd 100755 --- a/configure.py +++ b/configure.py @@ -558,16 +558,31 @@ else: args.pie = '' args.fpie = '' -optional_packages = ['libsystemd'] +# a list element means a list of alternative packages to consider +# the first element becomes the HAVE_pkg define +# a string element is a package name with no alternatives +optional_packages = [['libsystemd', 'libsystemd-daemon']] pkgs = [] -for pkg in optional_packages: - if have_pkg(pkg): - pkgs.append(pkg) - upkg = pkg.upper().replace('-', '_') - defines.append('HAVE_{}=1'.format(upkg)) - else: - print('Missing optional package {pkg}'.format(**locals())) +def setup_first_pkg_of_list(pkglist): + # The HAVE_pkg symbol is taken from the first alternative + upkg = pkglist[0].upper().replace('-', '_') + for pkg in pkglist: + if have_pkg(pkg): + pkgs.append(pkg) + defines.append('HAVE_{}=1'.format(upkg)) + return True + return False + +for pkglist in optional_packages: + if isinstance(pkglist, str): + pkglist = [pkglist] + if not setup_first_pkg_of_list(pkglist): + if len(pkglist) == 1: + print('Missing optional package {pkglist[0]}'.format(**locals())) + else: + alternatives = ':'.join(pkglist[1:]) + print('Missing optional package {pkglist[0]} (or alteratives {alternatives})'.format(**locals())) defines = ' '.join(['-D' + d for d in defines])