[Spice-devel] [spice-common 07/13] build-sys: Move opengl check to m4 macro

Christophe Fergeau cfergeau at redhat.com
Wed Dec 3 09:15:22 PST 2014


---
 common/Makefile.am |  1 -
 configure.ac       | 21 +--------------------
 m4/opengl.m4       | 21 +++++++++++++++++++++
 3 files changed, 22 insertions(+), 21 deletions(-)
 create mode 100644 m4/opengl.m4

diff --git a/common/Makefile.am b/common/Makefile.am
index b06fae7..1066b1b 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -93,7 +93,6 @@ endif
 AM_CPPFLAGS =				\
 	-I$(top_srcdir)			\
 	$(SPICE_COMMON_CFLAGS)		\
-	$(GL_CFLAGS)			\
 	$(PIXMAN_CFLAGS)		\
 	$(PROTOCOL_CFLAGS)		\
 	$(VISIBILITY_HIDDEN_CFLAGS)	\
diff --git a/configure.ac b/configure.ac
index 893d01e..b8b9a5a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,29 +38,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/opengl.m4 b/m4/opengl.m4
new file mode 100644
index 0000000..ad559bc
--- /dev/null
+++ b/m4/opengl.m4
@@ -0,0 +1,21 @@
+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