diff mbox series

[v2,6/9] configure: Link test before auto-enabling OpenGL libraries

Message ID 20190614100718.14019-7-philmd@redhat.com
State New
Headers show
Series configure: Fix softmmu --static linking | expand

Commit Message

Philippe Mathieu-Daudé June 14, 2019, 10:07 a.m. UTC
Similarly to commit a73e82ef912, test the libraries link correctly
before considering them as usable.

This fixes using ./configure --static on Ubuntu 18.04:

  $ make subdir-lm32-softmmu
  [...]
  LINK    lm32-softmmu/qemu-system-lm32
  /usr/bin/ld: cannot find -lepoxy
  /usr/bin/ld: cannot find -lgbm
  collect2: error: ld returned 1 exit status
  Makefile:204: recipe for target 'qemu-system-lm32' failed
  make[1]: *** [qemu-system-lm32] Error 1

  $ fgrep epoxy config-host.mak
  OPENGL_LIBS=-lepoxy -ldl -lgbm -ldl

  $ lsb_release -cri
  Distributor ID: Ubuntu
  Release:        18.04
  Codename:       bionic

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 configure | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/configure b/configure
index 449dbd69ce..a3da5adf80 100755
--- a/configure
+++ b/configure
@@ -4133,11 +4133,21 @@  if test "$opengl" != "no" ; then
   if $pkg_config $opengl_pkgs; then
     opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
     opengl_libs="$($pkg_config --libs $opengl_pkgs)"
-    opengl=yes
-    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
-        gtk_gl="yes"
+    # Packaging for the static libraries is not always correct.
+    # At least ubuntu 18.04 ships only shared libraries.
+    write_c_skeleton
+    if ! compile_prog "$opengl_cflags" "$opengl_libs" ; then
+        if test "$opengl" = "yes" ; then
+          error_exit "opengl check failed."
+        fi
+        opengl=no
+    else
+        opengl=yes
+        if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
+            gtk_gl="yes"
+        fi
+        QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
     fi
-    QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
   else
     if test "$opengl" = "yes" ; then
       feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"