From patchwork Tue Apr 25 18:35:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 754991 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wCBr22DrVz9sNL for ; Wed, 26 Apr 2017 04:41:22 +1000 (AEST) Received: from localhost ([::1]:50893 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d35Op-0003oY-MI for incoming@patchwork.ozlabs.org; Tue, 25 Apr 2017 14:41:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d35JG-0007x4-JE for qemu-devel@nongnu.org; Tue, 25 Apr 2017 14:35:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d35JF-0005mb-AI for qemu-devel@nongnu.org; Tue, 25 Apr 2017 14:35:34 -0400 Received: from mail.kernel.org ([198.145.29.136]:49844) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d35JE-0005lz-Vj for qemu-devel@nongnu.org; Tue, 25 Apr 2017 14:35:33 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D4F2C20212; Tue, 25 Apr 2017 18:35:30 +0000 (UTC) Received: from localhost.localdomain (unknown [99.165.194.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7406A201FE; Tue, 25 Apr 2017 18:35:29 +0000 (UTC) From: Stefano Stabellini To: peter.maydell@linaro.org Date: Tue, 25 Apr 2017 11:35:01 -0700 Message-Id: <1493145313-31311-9-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1493145313-31311-1-git-send-email-sstabellini@kernel.org> References: <1493145313-31311-1-git-send-email-sstabellini@kernel.org> X-Virus-Scanned: ClamAV using ClamSMTP X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 198.145.29.136 Subject: [Qemu-devel] [PATCH 09/21] 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: Juergen Gross , sstabellini@kernel.org, stefanha@gmail.com, qemu-devel@nongnu.org, stefanha@redhat.com, anthony.perard@citrix.com, xen-devel@lists.xenproject.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Juergen Gross 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 Signed-off-by: Stefano Stabellini Tested-by: Paul Durrant Reviewed-by: Stefano Stabellini --- configure | 159 ++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 88 insertions(+), 71 deletions(-) diff --git a/configure b/configure index 271bea8..3133ef8 100755 --- a/configure +++ b/configure @@ -1975,30 +1975,46 @@ fi # xen probe if test "$xen" != "no" ; then - xen_libs="-lxenstore -lxenctrl -lxenguest" - xen_stable_libs="-lxencall -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. + + 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 - # 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. + xen_libs="-lxenstore -lxenctrl -lxenguest" + xen_stable_libs="-lxencall -lxenforeignmemory -lxengnttab -lxenevtchn" - # 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 < @@ -2011,13 +2027,13 @@ int main(void) { return 0; } EOF - compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs" - then - xen_stable_libs="-lxendevicemodel $xen_stable_libs" - xen_ctrl_version=40900 - xen=yes - elif - cat > $TMPC < $TMPC < $TMPC < $TMPC < $TMPC < $TMPC < #include int main(void) { @@ -2133,14 +2149,14 @@ int main(void) { return 0; } EOF - compile_prog "" "$xen_libs" - then - xen_ctrl_version=40700 - xen=yes - - # Xen 4.6 - elif - cat > $TMPC < $TMPC < #include #include @@ -2161,14 +2177,14 @@ int main(void) { return 0; } EOF - compile_prog "" "$xen_libs" - then - xen_ctrl_version=40600 - xen=yes - - # Xen 4.5 - elif - cat > $TMPC < $TMPC < #include #include @@ -2188,13 +2204,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 @@ -2213,24 +2229,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