[Spice-devel] [spice-common v2 10/11] build-sys: Move opengl check to m4 macro

Christophe Fergeau cfergeau at redhat.com
Tue Dec 9 06:39:28 PST 2014


---
 common/Makefile.am |  1 -
 configure.ac       | 21 +--------------------
 m4/spice-deps.m4   | 31 +++++++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/common/Makefile.am b/common/Makefile.am
index c5e2e2a..5a689fe 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -92,7 +92,6 @@ endif
 AM_CPPFLAGS =				\
 	-I$(top_srcdir)			\
 	$(SPICE_COMMON_CFLAGS)		\
-	$(GL_CFLAGS)			\
 	$(PIXMAN_CFLAGS)		\
 	$(PROTOCOL_CFLAGS)		\
 	$(NULL)
diff --git a/configure.ac b/configure.ac
index d3c318a..ff0e34c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,29 +42,10 @@ AC_SUBST(PIXMAN_CFLAGS)
 SPICE_CHECK_SMARTCARD(SPICE_COMMON)
 SPICE_CHECK_CELT051(SPICE_COMMON)
 SPICE_CHECK_OPUS(SPICE_COMMON)
+SPICE_CHECK_OPENGL(SPICE_COMMON)
 AC_SUBST(SPICE_COMMON_CFLAGS)
 AC_SUBST(SPICE_COMMON_LIBS)
 
-AC_ARG_ENABLE([opengl],
-  AS_HELP_STRING([--enable-opengl=@<:@yes/no@:>@],
-                 [Enable opengl support (not recommended) @<:@default=no@:>@]),
-  [],
-  [enable_opengl="no"])
-AM_CONDITIONAL(SUPPORT_GL, test "x$enable_opengl" = "xyes")
-
-if test "x$enable_opengl" = "xyes"; then
-   AC_CHECK_LIB(GL, glBlendFunc, GL_LIBS="$GL_LIBS -lGL", enable_opengl=no)
-   AC_CHECK_LIB(GLU, gluSphere, GL_LIBS="$GL_LIBS -lGLU", enable_opengl=no)
-   AC_DEFINE([USE_OPENGL], [1], [Define to build with OpenGL support])
-   AC_DEFINE([GL_GLEXT_PROTOTYPES], [], [Enable GLExt prototypes])
-
-   if test "x$enable_opengl" = "xno"; then
-      AC_MSG_ERROR([GL libraries not available])
-   fi
-fi
-AC_SUBST(GL_CFLAGS)
-AC_SUBST(GL_LIBS)
-
 # The End!
 AC_CONFIG_FILES([
   Makefile
diff --git a/m4/spice-deps.m4 b/m4/spice-deps.m4
index 2e4c6be..80b8eb0 100644
--- a/m4/spice-deps.m4
+++ b/m4/spice-deps.m4
@@ -98,3 +98,34 @@ AC_DEFUN([SPICE_CHECK_OPUS], [
     AS_VAR_APPEND([$1_CFLAGS], [" $OPUS_CFLAGS"])
     AS_VAR_APPEND([$1_LIBS], [" $OPUS_LIBS"])
 ])
+
+
+# SPICE_CHECK_OPENGL(PREFIX)
+# --------------------------
+# Adds a --disable-opengl switch in order to enable/disable OpenGL
+# support, and checks if the needed libraries are available. If found, it will
+# set the $PREFIX_CFLAGS and $PREFIX_LIBS variables, and it will define
+# USE_OPENGL and GL_GLEXT_PROTOTYPES preprocessor symbol as well as a
+# SUPPORT_GL Makefile conditional.
+#---------------------------
+AC_DEFUN([SPICE_CHECK_OPENGL], [
+    AC_ARG_ENABLE([opengl],
+        AS_HELP_STRING([--enable-opengl=@<:@yes/no@:>@],
+                       [Enable opengl support (not recommended) @<:@default=no@:>@]),
+        [],
+        [enable_opengl="no"])
+    AM_CONDITIONAL(SUPPORT_GL, test "x$enable_opengl" = "xyes")
+
+    if test "x$enable_opengl" = "xyes"; then
+        AC_CHECK_LIB(GL, glBlendFunc, GL_LIBS="$GL_LIBS -lGL", enable_opengl=no)
+        AC_CHECK_LIB(GLU, gluSphere, GL_LIBS="$GL_LIBS -lGLU", enable_opengl=no)
+        AC_DEFINE([USE_OPENGL], [1], [Define to build with OpenGL support])
+        AC_DEFINE([GL_GLEXT_PROTOTYPES], [], [Enable GLExt prototypes])
+
+        if test "x$enable_opengl" = "xno"; then
+            AC_MSG_ERROR([GL libraries not available])
+        fi
+    fi
+    AS_VAR_APPEND([$1_CFLAGS], [" $GL_CFLAGS"])
+    AS_VAR_APPEND([$1_LIBS], [" $GL_LIBS"])
+])
-- 
2.1.0



More information about the Spice-devel mailing list