diff mbox

[1/4] configure: opengl overhaul

Message ID 1421066126-25737-2-git-send-email-kraxel@redhat.com
State New
Headers show

Commit Message

Gerd Hoffmann Jan. 12, 2015, 12:35 p.m. UTC
Rename config option from "glx" to "opengl", glx will not be the only
option for opengl in near future.  Also switch over to pkg-config for
opengl support detection.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 configure                        | 39 +++++++++++++++++----------------------
 default-configs/lm32-softmmu.mak |  2 +-
 hw/display/Makefile.objs         |  2 +-
 hw/lm32/milkymist-hw.h           |  4 ++--
 include/sysemu/sysemu.h          |  1 +
 vl.c                             |  1 +
 6 files changed, 23 insertions(+), 26 deletions(-)

Comments

Paolo Bonzini Jan. 12, 2015, 12:55 p.m. UTC | #1
On 12/01/2015 13:35, Gerd Hoffmann wrote:
> Rename config option from "glx" to "opengl", glx will not be the only
> option for opengl in near future.  Also switch over to pkg-config for
> opengl support detection.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Gerd, since you're working in this area, can you pick up
http://article.gmane.org/gmane.comp.emulators.qemu/313402 as well?  I
had queued it for my next pull request, but it conflicts with your stuff.

Paolo

> ---
>  configure                        | 39 +++++++++++++++++----------------------
>  default-configs/lm32-softmmu.mak |  2 +-
>  hw/display/Makefile.objs         |  2 +-
>  hw/lm32/milkymist-hw.h           |  4 ++--
>  include/sysemu/sysemu.h          |  1 +
>  vl.c                             |  1 +
>  6 files changed, 23 insertions(+), 26 deletions(-)
> 
> diff --git a/configure b/configure
> index cae588c..ee1693b 100755
> --- a/configure
> +++ b/configure
> @@ -309,7 +309,7 @@ rbd=""
>  smartcard_nss=""
>  libusb=""
>  usb_redir=""
> -glx=""
> +opengl=""
>  zlib="yes"
>  lzo=""
>  snappy=""
> @@ -1026,9 +1026,9 @@ for opt do
>    ;;
>    --enable-vhost-scsi) vhost_scsi="yes"
>    ;;
> -  --disable-glx) glx="no"
> +  --disable-opengl) opengl="no"
>    ;;
> -  --enable-glx) glx="yes"
> +  --enable-opengl) opengl="yes"
>    ;;
>    --disable-rbd) rbd="no"
>    ;;
> @@ -3056,23 +3056,18 @@ fi
>  libs_softmmu="$libs_softmmu $fdt_libs"
>  
>  ##########################################
> -# GLX probe, used by milkymist-tmu2
> -if test "$glx" != "no" ; then
> -  glx_libs="-lGL -lX11"
> -  cat > $TMPC << EOF
> -#include <X11/Xlib.h>
> -#include <GL/gl.h>
> -#include <GL/glx.h>
> -int main(void) { glBegin(0); glXQueryVersion(0,0,0); return 0; }
> -EOF
> -  if compile_prog "" "-lGL -lX11" ; then
> -    glx=yes
> +# opengl probe, used by milkymist-tmu2
> +if test "$opengl" != "no" ; then
> +  opengl_pkgs="gl"
> +  if $pkg_config $opengl_pkgs; then
> +    opengl_libs="$($pkg_config --libs $opengl_pkgs) -lX11"
> +    opengl=yes
>    else
> -    if test "$glx" = "yes" ; then
> -      feature_not_found "glx" "Install GL devel (e.g. MESA)"
> +    if test "$opengl" = "yes" ; then
> +      feature_not_found "opengl" "Install GL devel (e.g. MESA)"
>      fi
> -    glx_libs=
> -    glx=no
> +    opengl_libs=""
> +    opengl=no
>    fi
>  fi
>  
> @@ -4320,7 +4315,7 @@ echo "xfsctl support    $xfs"
>  echo "nss used          $smartcard_nss"
>  echo "libusb            $libusb"
>  echo "usb net redir     $usb_redir"
> -echo "GLX support       $glx"
> +echo "OpenGL support    $opengl"
>  echo "libiscsi support  $libiscsi"
>  echo "libnfs support    $libnfs"
>  echo "build guest agent $guest_agent"
> @@ -4682,9 +4677,9 @@ if test "$usb_redir" = "yes" ; then
>    echo "CONFIG_USB_REDIR=y" >> $config_host_mak
>  fi
>  
> -if test "$glx" = "yes" ; then
> -  echo "CONFIG_GLX=y" >> $config_host_mak
> -  echo "GLX_LIBS=$glx_libs" >> $config_host_mak
> +if test "$opengl" = "yes" ; then
> +  echo "CONFIG_OPENGL=y" >> $config_host_mak
> +  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
>  fi
>  
>  if test "$lzo" = "yes" ; then
> diff --git a/default-configs/lm32-softmmu.mak b/default-configs/lm32-softmmu.mak
> index 7df58c8..4889348 100644
> --- a/default-configs/lm32-softmmu.mak
> +++ b/default-configs/lm32-softmmu.mak
> @@ -2,7 +2,7 @@
>  
>  CONFIG_LM32=y
>  CONFIG_MILKYMIST=y
> -CONFIG_MILKYMIST_TMU2=$(CONFIG_GLX)
> +CONFIG_MILKYMIST_TMU2=$(CONFIG_OPENGL)
>  CONFIG_FRAMEBUFFER=y
>  CONFIG_PTIMER=y
>  CONFIG_PFLASH_CFI01=y
> diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs
> index 7ed76a9..e18ea57 100644
> --- a/hw/display/Makefile.objs
> +++ b/hw/display/Makefile.objs
> @@ -20,7 +20,7 @@ common-obj-$(CONFIG_ZAURUS) += tc6393xb.o
>  
>  ifeq ($(CONFIG_MILKYMIST_TMU2),y)
>  common-obj-y += milkymist-tmu2.o
> -libs_softmmu += $(GLX_LIBS)
> +libs_softmmu += $(OPENGL_LIBS)
>  endif
>  
>  obj-$(CONFIG_OMAP) += omap_dss.o
> diff --git a/hw/lm32/milkymist-hw.h b/hw/lm32/milkymist-hw.h
> index 5317ce6..8d20cac 100644
> --- a/hw/lm32/milkymist-hw.h
> +++ b/hw/lm32/milkymist-hw.h
> @@ -86,7 +86,7 @@ static inline DeviceState *milkymist_pfpu_create(hwaddr base,
>      return dev;
>  }
>  
> -#ifdef CONFIG_GLX
> +#ifdef CONFIG_OPENGL
>  #include <X11/Xlib.h>
>  #include <GL/glx.h>
>  static const int glx_fbconfig_attr[] = {
> @@ -100,7 +100,7 @@ static const int glx_fbconfig_attr[] = {
>  static inline DeviceState *milkymist_tmu2_create(hwaddr base,
>          qemu_irq irq)
>  {
> -#ifdef CONFIG_GLX
> +#ifdef CONFIG_OPENGL
>      DeviceState *dev;
>      Display *d;
>      GLXFBConfig *configs;
> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index 503e5a4..e5c91eb 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -117,6 +117,7 @@ extern int graphic_width;
>  extern int graphic_height;
>  extern int graphic_depth;
>  extern DisplayType display_type;
> +extern int display_opengl;
>  extern const char *keyboard_layout;
>  extern int win2k_install_hack;
>  extern int alt_grab;
> diff --git a/vl.c b/vl.c
> index bea9656..06e8f44 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -129,6 +129,7 @@ static int data_dir_idx;
>  const char *bios_name = NULL;
>  enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
>  DisplayType display_type = DT_DEFAULT;
> +int display_opengl;
>  static int display_remote;
>  const char* keyboard_layout = NULL;
>  ram_addr_t ram_size;
>
Gerd Hoffmann Jan. 12, 2015, 1:11 p.m. UTC | #2
On Mo, 2015-01-12 at 13:55 +0100, Paolo Bonzini wrote:
> 
> On 12/01/2015 13:35, Gerd Hoffmann wrote:
> > Rename config option from "glx" to "opengl", glx will not be the only
> > option for opengl in near future.  Also switch over to pkg-config for
> > opengl support detection.
> > 
> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> 
> Gerd, since you're working in this area, can you pick up
> http://article.gmane.org/gmane.comp.emulators.qemu/313402 as well?  I
> had queued it for my next pull request, but it conflicts with your stuff.

Yep, the gl bits conflict, I'll pick it up and handle the conflicts.

cheers,
  Gerd
Max Reitz Jan. 15, 2015, 7:55 p.m. UTC | #3
On 2015-01-12 at 07:35, Gerd Hoffmann wrote:
> Rename config option from "glx" to "opengl", glx will not be the only
> option for opengl in near future.  Also switch over to pkg-config for
> opengl support detection.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>   configure                        | 39 +++++++++++++++++----------------------
>   default-configs/lm32-softmmu.mak |  2 +-
>   hw/display/Makefile.objs         |  2 +-
>   hw/lm32/milkymist-hw.h           |  4 ++--
>   include/sysemu/sysemu.h          |  1 +
>   vl.c                             |  1 +
>   6 files changed, 23 insertions(+), 26 deletions(-)
>
> diff --git a/configure b/configure
> index cae588c..ee1693b 100755
> --- a/configure
> +++ b/configure
> @@ -309,7 +309,7 @@ rbd=""
>   smartcard_nss=""
>   libusb=""
>   usb_redir=""
> -glx=""
> +opengl=""
>   zlib="yes"
>   lzo=""
>   snappy=""
> @@ -1026,9 +1026,9 @@ for opt do
>     ;;
>     --enable-vhost-scsi) vhost_scsi="yes"
>     ;;
> -  --disable-glx) glx="no"
> +  --disable-opengl) opengl="no"
>     ;;
> -  --enable-glx) glx="yes"
> +  --enable-opengl) opengl="yes"
>     ;;
>     --disable-rbd) rbd="no"
>     ;;
> @@ -3056,23 +3056,18 @@ fi
>   libs_softmmu="$libs_softmmu $fdt_libs"
>   
>   ##########################################
> -# GLX probe, used by milkymist-tmu2
> -if test "$glx" != "no" ; then
> -  glx_libs="-lGL -lX11"
> -  cat > $TMPC << EOF
> -#include <X11/Xlib.h>
> -#include <GL/gl.h>
> -#include <GL/glx.h>
> -int main(void) { glBegin(0); glXQueryVersion(0,0,0); return 0; }
> -EOF
> -  if compile_prog "" "-lGL -lX11" ; then
> -    glx=yes
> +# opengl probe, used by milkymist-tmu2

Maybe remove this part of the comment about milkymist?

> +if test "$opengl" != "no" ; then
> +  opengl_pkgs="gl"
> +  if $pkg_config $opengl_pkgs; then
> +    opengl_libs="$($pkg_config --libs $opengl_pkgs) -lX11"
> +    opengl=yes

`pkg-config gl` might be successful even without X11 available. In this 
case, $opengl will be set to 'yes', but linking will probably fail.

Maybe we should keep GLX separated from OpenGL; for SDL we don't need 
X11, but for milkymist-tmu2 we apparently do.

Max

>     else
> -    if test "$glx" = "yes" ; then
> -      feature_not_found "glx" "Install GL devel (e.g. MESA)"
> +    if test "$opengl" = "yes" ; then
> +      feature_not_found "opengl" "Install GL devel (e.g. MESA)"
>       fi
> -    glx_libs=
> -    glx=no
> +    opengl_libs=""
> +    opengl=no
>     fi
>   fi
>   
> @@ -4320,7 +4315,7 @@ echo "xfsctl support    $xfs"
>   echo "nss used          $smartcard_nss"
>   echo "libusb            $libusb"
>   echo "usb net redir     $usb_redir"
> -echo "GLX support       $glx"
> +echo "OpenGL support    $opengl"
>   echo "libiscsi support  $libiscsi"
>   echo "libnfs support    $libnfs"
>   echo "build guest agent $guest_agent"
> @@ -4682,9 +4677,9 @@ if test "$usb_redir" = "yes" ; then
>     echo "CONFIG_USB_REDIR=y" >> $config_host_mak
>   fi
>   
> -if test "$glx" = "yes" ; then
> -  echo "CONFIG_GLX=y" >> $config_host_mak
> -  echo "GLX_LIBS=$glx_libs" >> $config_host_mak
> +if test "$opengl" = "yes" ; then
> +  echo "CONFIG_OPENGL=y" >> $config_host_mak
> +  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
>   fi
>   
>   if test "$lzo" = "yes" ; then
> diff --git a/default-configs/lm32-softmmu.mak b/default-configs/lm32-softmmu.mak
> index 7df58c8..4889348 100644
> --- a/default-configs/lm32-softmmu.mak
> +++ b/default-configs/lm32-softmmu.mak
> @@ -2,7 +2,7 @@
>   
>   CONFIG_LM32=y
>   CONFIG_MILKYMIST=y
> -CONFIG_MILKYMIST_TMU2=$(CONFIG_GLX)
> +CONFIG_MILKYMIST_TMU2=$(CONFIG_OPENGL)
>   CONFIG_FRAMEBUFFER=y
>   CONFIG_PTIMER=y
>   CONFIG_PFLASH_CFI01=y
> diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs
> index 7ed76a9..e18ea57 100644
> --- a/hw/display/Makefile.objs
> +++ b/hw/display/Makefile.objs
> @@ -20,7 +20,7 @@ common-obj-$(CONFIG_ZAURUS) += tc6393xb.o
>   
>   ifeq ($(CONFIG_MILKYMIST_TMU2),y)
>   common-obj-y += milkymist-tmu2.o
> -libs_softmmu += $(GLX_LIBS)
> +libs_softmmu += $(OPENGL_LIBS)
>   endif
>   
>   obj-$(CONFIG_OMAP) += omap_dss.o
> diff --git a/hw/lm32/milkymist-hw.h b/hw/lm32/milkymist-hw.h
> index 5317ce6..8d20cac 100644
> --- a/hw/lm32/milkymist-hw.h
> +++ b/hw/lm32/milkymist-hw.h
> @@ -86,7 +86,7 @@ static inline DeviceState *milkymist_pfpu_create(hwaddr base,
>       return dev;
>   }
>   
> -#ifdef CONFIG_GLX
> +#ifdef CONFIG_OPENGL
>   #include <X11/Xlib.h>
>   #include <GL/glx.h>
>   static const int glx_fbconfig_attr[] = {
> @@ -100,7 +100,7 @@ static const int glx_fbconfig_attr[] = {
>   static inline DeviceState *milkymist_tmu2_create(hwaddr base,
>           qemu_irq irq)
>   {
> -#ifdef CONFIG_GLX
> +#ifdef CONFIG_OPENGL
>       DeviceState *dev;
>       Display *d;
>       GLXFBConfig *configs;
> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index 503e5a4..e5c91eb 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -117,6 +117,7 @@ extern int graphic_width;
>   extern int graphic_height;
>   extern int graphic_depth;
>   extern DisplayType display_type;
> +extern int display_opengl;
>   extern const char *keyboard_layout;
>   extern int win2k_install_hack;
>   extern int alt_grab;
> diff --git a/vl.c b/vl.c
> index bea9656..06e8f44 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -129,6 +129,7 @@ static int data_dir_idx;
>   const char *bios_name = NULL;
>   enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
>   DisplayType display_type = DT_DEFAULT;
> +int display_opengl;
>   static int display_remote;
>   const char* keyboard_layout = NULL;
>   ram_addr_t ram_size;
Gerd Hoffmann Jan. 16, 2015, 9:11 a.m. UTC | #4
Hi,

> > +# opengl probe, used by milkymist-tmu2
> 
> Maybe remove this part of the comment about milkymist?

Will do.

> > +if test "$opengl" != "no" ; then
> > +  opengl_pkgs="gl"
> > +  if $pkg_config $opengl_pkgs; then
> > +    opengl_libs="$($pkg_config --libs $opengl_pkgs) -lX11"
> > +    opengl=yes
> 
> `pkg-config gl` might be successful even without X11 available. In this 
> case, $opengl will be set to 'yes', but linking will probably fail.

Indeed.

> Maybe we should keep GLX separated from OpenGL; for SDL we don't need 
> X11, but for milkymist-tmu2 we apparently do.

That should be only temporary.  There will be infrastructure for device
emulations to ask the UI for a opengl context.  Once this is in place we
should be able to switch over milkymist-tmu2 to that so it doesn't has
to initialize opengl on its own.

cheers,
  Gerd
diff mbox

Patch

diff --git a/configure b/configure
index cae588c..ee1693b 100755
--- a/configure
+++ b/configure
@@ -309,7 +309,7 @@  rbd=""
 smartcard_nss=""
 libusb=""
 usb_redir=""
-glx=""
+opengl=""
 zlib="yes"
 lzo=""
 snappy=""
@@ -1026,9 +1026,9 @@  for opt do
   ;;
   --enable-vhost-scsi) vhost_scsi="yes"
   ;;
-  --disable-glx) glx="no"
+  --disable-opengl) opengl="no"
   ;;
-  --enable-glx) glx="yes"
+  --enable-opengl) opengl="yes"
   ;;
   --disable-rbd) rbd="no"
   ;;
@@ -3056,23 +3056,18 @@  fi
 libs_softmmu="$libs_softmmu $fdt_libs"
 
 ##########################################
-# GLX probe, used by milkymist-tmu2
-if test "$glx" != "no" ; then
-  glx_libs="-lGL -lX11"
-  cat > $TMPC << EOF
-#include <X11/Xlib.h>
-#include <GL/gl.h>
-#include <GL/glx.h>
-int main(void) { glBegin(0); glXQueryVersion(0,0,0); return 0; }
-EOF
-  if compile_prog "" "-lGL -lX11" ; then
-    glx=yes
+# opengl probe, used by milkymist-tmu2
+if test "$opengl" != "no" ; then
+  opengl_pkgs="gl"
+  if $pkg_config $opengl_pkgs; then
+    opengl_libs="$($pkg_config --libs $opengl_pkgs) -lX11"
+    opengl=yes
   else
-    if test "$glx" = "yes" ; then
-      feature_not_found "glx" "Install GL devel (e.g. MESA)"
+    if test "$opengl" = "yes" ; then
+      feature_not_found "opengl" "Install GL devel (e.g. MESA)"
     fi
-    glx_libs=
-    glx=no
+    opengl_libs=""
+    opengl=no
   fi
 fi
 
@@ -4320,7 +4315,7 @@  echo "xfsctl support    $xfs"
 echo "nss used          $smartcard_nss"
 echo "libusb            $libusb"
 echo "usb net redir     $usb_redir"
-echo "GLX support       $glx"
+echo "OpenGL support    $opengl"
 echo "libiscsi support  $libiscsi"
 echo "libnfs support    $libnfs"
 echo "build guest agent $guest_agent"
@@ -4682,9 +4677,9 @@  if test "$usb_redir" = "yes" ; then
   echo "CONFIG_USB_REDIR=y" >> $config_host_mak
 fi
 
-if test "$glx" = "yes" ; then
-  echo "CONFIG_GLX=y" >> $config_host_mak
-  echo "GLX_LIBS=$glx_libs" >> $config_host_mak
+if test "$opengl" = "yes" ; then
+  echo "CONFIG_OPENGL=y" >> $config_host_mak
+  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
 fi
 
 if test "$lzo" = "yes" ; then
diff --git a/default-configs/lm32-softmmu.mak b/default-configs/lm32-softmmu.mak
index 7df58c8..4889348 100644
--- a/default-configs/lm32-softmmu.mak
+++ b/default-configs/lm32-softmmu.mak
@@ -2,7 +2,7 @@ 
 
 CONFIG_LM32=y
 CONFIG_MILKYMIST=y
-CONFIG_MILKYMIST_TMU2=$(CONFIG_GLX)
+CONFIG_MILKYMIST_TMU2=$(CONFIG_OPENGL)
 CONFIG_FRAMEBUFFER=y
 CONFIG_PTIMER=y
 CONFIG_PFLASH_CFI01=y
diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs
index 7ed76a9..e18ea57 100644
--- a/hw/display/Makefile.objs
+++ b/hw/display/Makefile.objs
@@ -20,7 +20,7 @@  common-obj-$(CONFIG_ZAURUS) += tc6393xb.o
 
 ifeq ($(CONFIG_MILKYMIST_TMU2),y)
 common-obj-y += milkymist-tmu2.o
-libs_softmmu += $(GLX_LIBS)
+libs_softmmu += $(OPENGL_LIBS)
 endif
 
 obj-$(CONFIG_OMAP) += omap_dss.o
diff --git a/hw/lm32/milkymist-hw.h b/hw/lm32/milkymist-hw.h
index 5317ce6..8d20cac 100644
--- a/hw/lm32/milkymist-hw.h
+++ b/hw/lm32/milkymist-hw.h
@@ -86,7 +86,7 @@  static inline DeviceState *milkymist_pfpu_create(hwaddr base,
     return dev;
 }
 
-#ifdef CONFIG_GLX
+#ifdef CONFIG_OPENGL
 #include <X11/Xlib.h>
 #include <GL/glx.h>
 static const int glx_fbconfig_attr[] = {
@@ -100,7 +100,7 @@  static const int glx_fbconfig_attr[] = {
 static inline DeviceState *milkymist_tmu2_create(hwaddr base,
         qemu_irq irq)
 {
-#ifdef CONFIG_GLX
+#ifdef CONFIG_OPENGL
     DeviceState *dev;
     Display *d;
     GLXFBConfig *configs;
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 503e5a4..e5c91eb 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -117,6 +117,7 @@  extern int graphic_width;
 extern int graphic_height;
 extern int graphic_depth;
 extern DisplayType display_type;
+extern int display_opengl;
 extern const char *keyboard_layout;
 extern int win2k_install_hack;
 extern int alt_grab;
diff --git a/vl.c b/vl.c
index bea9656..06e8f44 100644
--- a/vl.c
+++ b/vl.c
@@ -129,6 +129,7 @@  static int data_dir_idx;
 const char *bios_name = NULL;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
 DisplayType display_type = DT_DEFAULT;
+int display_opengl;
 static int display_remote;
 const char* keyboard_layout = NULL;
 ram_addr_t ram_size;