[PATCH 1/2] Add autoconf macro to find version of Mesa source being used

Dan Nicholson dbn.lists at gmail.com
Sat Mar 8 14:07:32 PST 2008


The XORG_MESA_SOURCE_VERSION autoconf macro will be used to find the
version specified in the Mesa source tree. It uses a simple Makefile to
print out and set the MESA_MAJOR, MESA_MINOR and MESA_TINY variables
from Mesa's configs/default.

With the Mesa source version available, we can make better decisions
about what to do with GLX and GLcore.
---
 acinclude.m4 |   43 +++++++++++++++++++++++++++++++++++++++++++
 configure.ac |    4 ++++
 2 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index f3d8734..d8c5619 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -45,3 +45,46 @@ dnl refers to ${prefix}.  Thus we have to use `eval' twice.
   test "$prefix_NONE" && prefix=NONE
   test "$exec_prefix_NONE" && exec_prefix=NONE
 ])
+
+# XORG_MESA_SOURCE_VERSION()
+# -----------------------------
+# Get the version of the Mesa source from its configs/default file.
+# This sets the variables MESA_MAJOR, MESA_MINOR, MESA_TINY and
+# MESA_VERSION. The MESA_SOURCE variable must be set before calling.
+#
+AC_DEFUN([XORG_MESA_SOURCE_VERSION],[
+  AC_MSG_CHECKING([for version of Mesa source files])
+  if test "x$MESA_SOURCE" = x; then
+    AC_MSG_ERROR([MESA_SOURCE variable must be set to find Mesa sources])
+  fi
+  if test ! -f $MESA_SOURCE/configs/default; then
+    AC_MSG_ERROR([No default config at $MESA_SOURCE/configs])
+  fi
+
+  cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+include $(MESA_SOURCE)/configs/default
+all:
+	@echo "MESA_MAJOR='$(MESA_MAJOR)';"
+	@echo "MESA_MINOR='$(MESA_MINOR)';"
+	@echo "MESA_TINY='$(MESA_TINY)';"
+_ACEOF
+
+  eval `${MAKE-make} -f conftest.make MESA_SOURCE="$MESA_SOURCE"`
+  rm -f conftest.make
+
+  # We require all three fields to be set. This might be too strict,
+  # but all the versions of Mesa I've seen meet this requirement.
+  if test "x$MESA_MAJOR" = x; then
+    AC_MSG_ERROR([Couldn't get Mesa major version from $MESA_SOURCE/configs/default])
+  fi
+  if test "x$MESA_MINOR" = x; then
+    AC_MSG_ERROR([Couldn't get Mesa minor version from $MESA_SOURCE/configs/default])
+  fi
+  if test "x$MESA_TINY" = x; then
+    AC_MSG_ERROR([Couldn't get Mesa tiny version from $MESA_SOURCE/configs/default])
+  fi
+
+  MESA_VERSION="$MESA_MAJOR.$MESA_MINOR.$MESA_TINY"
+  AC_MSG_RESULT([$MESA_VERSION])
+])
diff --git a/configure.ac b/configure.ac
index 5417bbb..f68513e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -812,6 +812,10 @@ if test "x$GLX" = xyes && ! test "x$MESA_SOURCE" = x; then
 	AC_SUBST(XLIB_CFLAGS)
 	AC_DEFINE(GLXEXT, 1, [Build GLX extension])
 	GLX_LIBS='$(top_builddir)/GL/glx/libglx.la $(top_builddir)/GL/mesa/libGLcore.la'
+
+	# Try to get the mesa versions from the source files
+	XORG_MESA_SOURCE_VERSION
+
 	test -d GL || mkdir GL
 	case $host_os in
 	  solaris*) 	
-- 
1.5.3.2




More information about the xorg mailing list