From patchwork Mon Mar 27 07:42:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 9645471 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C9520602BF for ; Mon, 27 Mar 2017 07:43:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAC0728334 for ; Mon, 27 Mar 2017 07:43:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF88128356; Mon, 27 Mar 2017 07:43:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D17E628334 for ; Mon, 27 Mar 2017 07:43:26 +0000 (UTC) Received: from localhost ([::1]:44880 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csPJF-0004ef-VP for patchwork-qemu-devel@patchwork.kernel.org; Mon, 27 Mar 2017 03:43:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csPIl-0004eZ-GD for qemu-devel@nongnu.org; Mon, 27 Mar 2017 03:42:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csPIh-0000je-JJ for qemu-devel@nongnu.org; Mon, 27 Mar 2017 03:42:55 -0400 Received: from mx2.suse.de ([195.135.220.15]:32950) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1csPIh-0000jX-9y for qemu-devel@nongnu.org; Mon, 27 Mar 2017 03:42:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1BCCDAD82; Mon, 27 Mar 2017 07:42:49 +0000 (UTC) From: Juergen Gross To: qemu-devel@nongnu.org, xen-devel@lists.xenproject.org Date: Mon, 27 Mar 2017 09:42:45 +0200 Message-Id: <20170327074245.3821-1-jgross@suse.com> X-Mailer: git-send-email 2.10.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 195.135.220.15 Subject: [Qemu-devel] [PATCH v2] configure: use pkg-config for obtaining xen version X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: anthony.perard@citrix.com, Juergen Gross , sstabellini@kernel.org, kraxel@redhat.com, paul.durrant@citrix.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Instead of trying to guess the Xen version to use by compiling various test programs first just ask the system via pkg-config. Only if it can't return the version fall back to the test program scheme. If configure is being called with dedicated flags for the Xen libraries use those instead of the pkg-config output. This will avoid breaking an in-tree Xen build of an old Xen version while a new Xen version is installed on the build machine: pkg-config would pick up the installed Xen config files as the Xen tree wouldn't contain any of them. Signed-off-by: Juergen Gross Tested-by: Paul Durrant Reviewed-by: Stefano Stabellini --- V2: - use pkg-config only if no Xen library paths have been specified via --extra-ldflags - keep test program for detecting Xen 4.9 --- configure | 155 ++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 86 insertions(+), 69 deletions(-) diff --git a/configure b/configure index aabf098..c34b025 100755 --- a/configure +++ b/configure @@ -1962,30 +1962,46 @@ fi # xen probe if test "$xen" != "no" ; then - xen_libs="-lxenstore -lxenctrl -lxenguest" - xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn" + # Check whether Xen library path is specified via --extra-ldflags to avoid + # overriding this setting with pkg-config output. If not, try pkg-config + # to obtain all needed flags. - # First we test whether Xen headers and libraries are available. - # If no, we are done and there is no Xen support. - # If yes, more tests are run to detect the Xen version. + if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \ + $pkg_config --exists xencontrol ; then + xen_ctrl_version="$(printf '%d%02d%02d' \ + $($pkg_config --modversion xencontrol | sed 's/\./ /g') )" + xen=yes + xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab" + xen_pc="$xen_pc xenevtchn xendevicemodel" + QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)" + libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu" + LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS" + else - # Xen (any) - cat > $TMPC < $TMPC < int main(void) { return 0; } EOF - if ! compile_prog "" "$xen_libs" ; then - # Xen not found - if test "$xen" = "yes" ; then - feature_not_found "xen" "Install xen devel" - fi - xen=no + if ! compile_prog "" "$xen_libs" ; then + # Xen not found + if test "$xen" = "yes" ; then + feature_not_found "xen" "Install xen devel" + fi + xen=no - # Xen unstable - elif - cat > $TMPC < $TMPC < @@ -1998,13 +2014,13 @@ int main(void) { return 0; } EOF - compile_prog "" "$xen_libs $xen_stable_libs -lxendevicemodel" - then - xen_stable_libs="$xen_stable_libs -lxendevicemodel" - xen_ctrl_version=40900 - xen=yes - elif - cat > $TMPC < $TMPC < $TMPC < $TMPC < $TMPC < $TMPC < #include int main(void) { @@ -2120,14 +2136,14 @@ int main(void) { return 0; } EOF - compile_prog "" "$xen_libs" - then - xen_ctrl_version=40700 - xen=yes + compile_prog "" "$xen_libs" + then + xen_ctrl_version=40700 + xen=yes - # Xen 4.6 - elif - cat > $TMPC < $TMPC < #include #include @@ -2148,14 +2164,14 @@ int main(void) { return 0; } EOF - compile_prog "" "$xen_libs" - then - xen_ctrl_version=40600 - xen=yes + compile_prog "" "$xen_libs" + then + xen_ctrl_version=40600 + xen=yes - # Xen 4.5 - elif - cat > $TMPC < $TMPC < #include #include @@ -2175,13 +2191,13 @@ int main(void) { return 0; } EOF - compile_prog "" "$xen_libs" - then - xen_ctrl_version=40500 - xen=yes + compile_prog "" "$xen_libs" + then + xen_ctrl_version=40500 + xen=yes - elif - cat > $TMPC < $TMPC < #include #include @@ -2200,24 +2216,25 @@ int main(void) { return 0; } EOF - compile_prog "" "$xen_libs" - then - xen_ctrl_version=40200 - xen=yes + compile_prog "" "$xen_libs" + then + xen_ctrl_version=40200 + xen=yes - else - if test "$xen" = "yes" ; then - feature_not_found "xen (unsupported version)" \ - "Install a supported xen (xen 4.2 or newer)" + else + if test "$xen" = "yes" ; then + feature_not_found "xen (unsupported version)" \ + "Install a supported xen (xen 4.2 or newer)" + fi + xen=no fi - xen=no - fi - if test "$xen" = yes; then - if test $xen_ctrl_version -ge 40701 ; then - libs_softmmu="$xen_stable_libs $libs_softmmu" + if test "$xen" = yes; then + if test $xen_ctrl_version -ge 40701 ; then + libs_softmmu="$xen_stable_libs $libs_softmmu" + fi + libs_softmmu="$xen_libs $libs_softmmu" fi - libs_softmmu="$xen_libs $libs_softmmu" fi fi