Allow building Epoxy without X11

Epoxy can be compiled with GLX and X11 native resources on EGL. We can
disable the former, but the latter is always built in when enabling EGL
support.

Some platforms do not support X11 at all, so we need a way to disable
X11 when configuring Epoxy.
macos/v1.5.9
Emmanuele Bassi 7 years ago
parent baa75c4a92
commit ce8cbdbe06
  1. 27
      configure.ac
  2. 9
      meson.build
  3. 4
      meson_options.txt
  4. 7
      src/dispatch_common.h
  5. 9
      test/meson.build

@ -59,6 +59,11 @@ AC_CHECK_HEADER([KHR/khrplatform.h],
# uintptr_t to a void *") by default. Kill that. # uintptr_t to a void *") by default. Kill that.
XORG_TESTSET_CFLAG(CWARNFLAGS, [-Wno-int-conversion]) XORG_TESTSET_CFLAG(CWARNFLAGS, [-Wno-int-conversion])
AC_ARG_ENABLE([x11],
[AC_HELP_STRING([--enable-x11=@<:@yes,no@:>@], [Enable X11 support @<:@default=yes@:>@])],
[enable_x11=$enableval],
[enable_x11=yes])
AC_ARG_ENABLE([glx], AC_ARG_ENABLE([glx],
[AC_HELP_STRING([--enable-glx=@<:@auto,yes,no@:>@], [Enable GLX support @<:@default=auto@:>@])], [AC_HELP_STRING([--enable-glx=@<:@auto,yes,no@:>@], [Enable GLX support @<:@default=auto@:>@])],
[enable_glx=$enableval], [enable_glx=$enableval],
@ -148,6 +153,13 @@ AS_CASE([$host_os],
AC_SUBST(EPOXY_LINK_LIBS) AC_SUBST(EPOXY_LINK_LIBS)
if test x$enable_x11 = xno; then
if test x$enable_glx = xyes; then
AC_MSG_ERROR([GLX support is explicitly enabled, but X11 was disabled])
fi
build_glx=no
fi
AM_CONDITIONAL(BUILD_EGL, test x$build_egl = xyes) AM_CONDITIONAL(BUILD_EGL, test x$build_egl = xyes)
if test x$build_egl = xyes; then if test x$build_egl = xyes; then
PKG_CHECK_MODULES(EGL, [egl]) PKG_CHECK_MODULES(EGL, [egl])
@ -214,14 +226,17 @@ AS_CASE(["$host"],
AC_SUBST([VISIBILITY_CFLAGS]) AC_SUBST([VISIBILITY_CFLAGS])
if test x$enable_x11 = xyes; then
PKG_CHECK_MODULES(X11, [x11], [x11=yes], [x11=no])
if test x$x11 = xno -a x$build_glx = xyes; then
AC_MSG_ERROR([libX11 headers (libx11-dev) are required to build with GLX support])
fi
else
x11=no
fi
if test x$build_glx = xyes; then if test x$build_glx = xyes; then
PKG_CHECK_MODULES(X11, [x11], [x11=yes], [x11=no])
if test x$x11 = xno -a x$build_glx = xyes; then
AC_MSG_ERROR([libX11 headers (libx11-dev) required to build with GLX support])
fi
AC_DEFINE(ENABLE_GLX, [1], [Whether GLX support is enabled]) AC_DEFINE(ENABLE_GLX, [1], [Whether GLX support is enabled])
else
x11=no
fi fi
AM_CONDITIONAL(HAVE_X11, test x$x11 = xyes) AM_CONDITIONAL(HAVE_X11, test x$x11 = xyes)

@ -70,6 +70,14 @@ elif enable_egl == 'no'
build_egl = false build_egl = false
endif endif
enable_x11 = get_option('x11')
if not enable_x11
if enable_glx == 'yes'
error('GLX support is explicitly enabled, but X11 was disabled')
endif
build_glx = false
endif
# The remaining platform specific API for GL/GLES are enabled # The remaining platform specific API for GL/GLES are enabled
# depending on the platform we're building for # depending on the platform we're building for
if host_system == 'windows' if host_system == 'windows'
@ -88,6 +96,7 @@ endif
conf.set10('ENABLE_GLX', build_glx) conf.set10('ENABLE_GLX', build_glx)
conf.set10('ENABLE_EGL', build_egl) conf.set10('ENABLE_EGL', build_egl)
conf.set10('ENABLE_X11', enable_x11)
# Compiler flags, taken from the Xorg macros # Compiler flags, taken from the Xorg macros
if cc.get_id() == 'msvc' if cc.get_id() == 'msvc'

@ -11,3 +11,7 @@ option('enable-egl',
choices: [ 'auto', 'yes', 'no' ], choices: [ 'auto', 'yes', 'no' ],
value: 'auto', value: 'auto',
description: 'Enable EGL support') description: 'Enable EGL support')
option('x11',
type: 'boolean',
value: true,
description: 'Enable X11 support (GLX or EGL-X11)')

@ -46,6 +46,13 @@
#include "epoxy/glx.h" #include "epoxy/glx.h"
#endif #endif
#if PLATFORM_HAS_EGL #if PLATFORM_HAS_EGL
# if !ENABLE_X11
/* Mesa uses this symbol to avoid including X11 headers when including
* EGL.h; since X11 was explicitly disabled at configuration time, we
* should do the same
*/
# define MESA_EGL_NO_X11_HEADERS 1
# endif
#include "epoxy/egl.h" #include "epoxy/egl.h"
#endif #endif
#if PLATFORM_HAS_WGL #if PLATFORM_HAS_WGL

@ -1,6 +1,6 @@
has_gles1 = gles1_dep.found() has_gles1 = gles1_dep.found()
has_gles2 = gles2_dep.found() has_gles2 = gles2_dep.found()
build_x11_tests = build_glx and x11_dep.found() build_x11_tests = enable_x11 and x11_dep.found()
test_cflags = common_cflags + [ test_cflags = common_cflags + [
'-D_XOPEN_SOURCE', '-D_XOPEN_SOURCE',
@ -39,11 +39,16 @@ if build_egl and build_x11_tests
egl_tests = [ egl_tests = [
[ 'egl_has_extension_nocontext', [], [ 'egl_has_extension_nocontext.c' ], true, ], [ 'egl_has_extension_nocontext', [], [ 'egl_has_extension_nocontext.c' ], true, ],
[ 'egl_gl', [], [ 'egl_gl.c' ], true, ],
[ 'egl_gles1_without_glx', [ '-DGLES_VERSION=1', ], [ 'egl_without_glx.c' ], has_gles1, ], [ 'egl_gles1_without_glx', [ '-DGLES_VERSION=1', ], [ 'egl_without_glx.c' ], has_gles1, ],
[ 'egl_gles2_without_glx', [ '-DGLES_VERSION=2', ], [ 'egl_without_glx.c' ], has_gles2, ], [ 'egl_gles2_without_glx', [ '-DGLES_VERSION=2', ], [ 'egl_without_glx.c' ], has_gles2, ],
] ]
if build_glx
egl_tests += [
[ 'egl_gl', [], [ 'egl_gl.c' ], true, ],
]
endif
foreach test: egl_tests foreach test: egl_tests
test_name = test[0] test_name = test[0]
test_source = test[2] test_source = test[2]

Loading…
Cancel
Save