[PATCH 2/3] configure: Look for Khronos OpenGL spec files using pkg-config

Jon TURNEY jon.turney at dronecode.org.uk
Thu Apr 14 05:46:50 PDT 2011


Look for Khronos OpenGL spec files using pkg-config, rather than downloading them

Also add a --with-khronos-spec-dir=PATH configure option so XWin can be directed
where to find these files without using the khronos-spec-files package

XWin with AIGLX requires OpenGL spec files in order to generate wrapper code which:
(1) thunks from the glapi dispatch table which uses the default cdecl calling convention
to native GL functions using the stdcall calling convention.
(2) performs function address lookup for OpenGL 1.2+ functions, which are treated
as extensions and so not directly linkable.

Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
---
 configure.ac            |   13 +++++++++++++
 hw/xwin/glx/.gitignore  |    4 ----
 hw/xwin/glx/Makefile.am |   26 ++++++--------------------
 3 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/configure.ac b/configure.ac
index 729fb96..824bfd6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -599,6 +599,9 @@ AC_ARG_ENABLE(glx-tls,        AS_HELP_STRING([--enable-glx-tls], [Build GLX with
                                    GLX_USE_TLS=yes
                                  fi])
 AC_SUBST(GLX_TLS, ${GLX_USE_TLS})
+AC_ARG_WITH(khronos-spec-dir, AS_HELP_STRING([--with-khronos-spec-dir=PATH], [Path to Khronos OpenGL registry database files (default: auto)]),
+				[KHRONOS_SPEC_DIR="${withval}"],
+				[KHRONOS_SPEC_DIR=auto])
 
 dnl Extensions.
 AC_ARG_ENABLE(registry,       AS_HELP_STRING([--disable-registry], [Build string registry module (default: enabled)]), [XREGISTRY=$enableval], [XREGISTRY=yes])
@@ -1852,6 +1855,16 @@ if test "x$XWIN" = xyes; then
 
 	AC_DEFINE(DDXOSVERRORF, 1, [Use OsVendorVErrorF])
 	AC_DEFINE(DDXBEFORERESET, 1, [Use ddxBeforeReset ])
+
+dnl XWin with AIGLX requires OpenGL spec files in order to generate wrapper code for native GL functions
+	if [test "x$XWIN" = xyes && test "x$AIGLX" = xyes] ; then
+           if test "x$KHRONOS_SPEC_DIR" = "xauto" ; then
+		PKG_CHECK_MODULES([KHRONOS_OPENGL_REGISTRY], [khronos-opengl-registry])
+		KHRONOS_SPEC_DIR=`pkg-config khronos-opengl-registry --variable=specdir`
+           fi
+           AC_SUBST(KHRONOS_SPEC_DIR)
+	fi
+
 fi
 AM_CONDITIONAL(XWIN, [test "x$XWIN" = xyes])
 AM_CONDITIONAL(XWIN_MULTIWINDOW, [test "x$XWIN" = xyes])
diff --git a/hw/xwin/glx/.gitignore b/hw/xwin/glx/.gitignore
index e7c7617..20d1c1e 100644
--- a/hw/xwin/glx/.gitignore
+++ b/hw/xwin/glx/.gitignore
@@ -1,8 +1,4 @@
 # ignore downloaded and generated files
 generated_gl_wrappers.c
 generated_wgl_wrappers.c
-gl.spec
-gl.tm
-wgl.tm
-wglext.spec
 wglext.h
diff --git a/hw/xwin/glx/Makefile.am b/hw/xwin/glx/Makefile.am
index 303ff53..fce1aad 100644
--- a/hw/xwin/glx/Makefile.am
+++ b/hw/xwin/glx/Makefile.am
@@ -30,31 +30,17 @@ wgl_ext_api.c: generated_wgl_wrappers.c wglext.h
 wgl_ext_api.h: wglext.h
 indirect.c: wgl_ext_api.h
 
-SPEC_FILES = gl.spec gl.tm wglext.spec wgl.tm
+generated_gl_wrappers.c: gen_gl_wrappers.py $(KHRONOS_SPEC_DIR)/gl.spec $(KHRONOS_SPEC_DIR)/gl.tm
+	$(srcdir)/gen_gl_wrappers.py --spec=$(KHRONOS_SPEC_DIR)/gl.spec --typemap=$(KHRONOS_SPEC_DIR)/gl.tm --dispatch-header=$(top_srcdir)/glx/dispatch.h --staticwrappers >generated_gl_wrappers.c
 
-gl.spec:
-	wget http://www.opengl.org/registry/api/gl.spec
-
-gl.tm:
-	wget http://www.opengl.org/registry/api/gl.tm
-
-wglext.spec:
-	wget http://www.opengl.org/registry/api/wglext.spec
-
-wgl.tm:
-	wget http://www.opengl.org/registry/api/wgl.tm
-
-generated_gl_wrappers.c: gen_gl_wrappers.py gl.spec gl.tm
-	$(srcdir)/gen_gl_wrappers.py --spec=`test -e gl.spec || echo $(srcdir)/`gl.spec --typemap=`test -e gl.tm || echo $(srcdir)/`gl.tm --dispatch-header=$(top_srcdir)/glx/dispatch.h --staticwrappers >generated_gl_wrappers.c
-
-generated_wgl_wrappers.c: gen_gl_wrappers.py wglext.spec wgl.tm
-	$(srcdir)/gen_gl_wrappers.py --spec=`test -e wglext.spec || echo $(srcdir)/`wglext.spec --typemap=`test -e wgl.tm || echo $(srcdir)/`wgl.tm --prefix=wgl --preresolve >generated_wgl_wrappers.c
+generated_wgl_wrappers.c: gen_gl_wrappers.py $(KHRONOS_SPEC_DIR)/wglext.spec $(KHRONOS_SPEC_DIR)/wgl.tm
+	$(srcdir)/gen_gl_wrappers.py --spec=$(KHRONOS_SPEC_DIR)/wglext.spec --typemap=$(KHRONOS_SPEC_DIR)/wgl.tm --prefix=wgl --preresolve >generated_wgl_wrappers.c
 
 wglext.h:
 	wget http://www.opengl.org/registry/api/wglext.h
 
 BUILT_SOURCES = generated_gl_wrappers.c generated_wgl_wrappers.c
 CLEANFILES = $(BUILT_SOURCES)
-DISTCLEANFILES = $(SPEC_FILES) wglext.h
+DISTCLEANFILES = wglext.h
 
-EXTRA_DIST = gen_gl_wrappers.py $(SPEC_FILES) wglext.h
+EXTRA_DIST = gen_gl_wrappers.py wglext.h
-- 
1.7.4



More information about the xorg-devel mailing list