From 7b52d33d86b23d663adb585a32a411e658d5a4c9 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 6 Feb 2017 14:49:21 +0000 Subject: [PATCH] Encode Epoxy capabilities into the pkg-config file Since Epoxy can be built with different platform-specific API, having a way for dependent projects to discover those capabilities without necessarily crashing the minute they attempt to use them is a good feature to have. We strongly direct library and application developers to use pkg-config in order to use Epoxy, so it makes sense to add variables to the epoxy.pc file that can be easily extracted at configuration time. --- configure.ac | 9 +++++++++ epoxy.pc.in | 4 ++++ meson.build | 3 +++ 3 files changed, 16 insertions(+) diff --git a/configure.ac b/configure.ac index 283e8c2..51c8ea4 100644 --- a/configure.ac +++ b/configure.ac @@ -205,6 +205,15 @@ AM_CONDITIONAL(HAVE_X11, test x$x11 = xyes) PKG_CHECK_MODULES(GL, [gl], [gl=yes], [gl=no]) +# Variables for the pkg-config file; AC_SUBST does not do `test` substitutions, +# so we need to specify the boolean values here +AS_IF([test x$build_glx = xyes], [epoxy_has_glx=1], [epoxy_has_glx=0]) +AS_IF([test x$build_egl = xyes], [epoxy_has_egl=1], [epoxy_has_egl=0]) +AS_IF([test x$build_wgl = xyes], [epoxy_has_wgl=1], [epoxy_has_wgl=0]) +AC_SUBST(epoxy_has_glx) +AC_SUBST(epoxy_has_egl) +AC_SUBST(epoxy_has_wgl) + AC_CONFIG_FILES([ epoxy.pc Makefile diff --git a/epoxy.pc.in b/epoxy.pc.in index 8c85a33..7828a77 100644 --- a/epoxy.pc.in +++ b/epoxy.pc.in @@ -3,6 +3,10 @@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ +epoxy_has_glx=@epoxy_has_glx@ +epoxy_has_egl=@epoxy_has_egl@ +epoxy_has_wgl=@epoxy_has_wgl@ + Name: epoxy Description: epoxy GL dispatch Library Version: @PACKAGE_VERSION@ diff --git a/meson.build b/meson.build index 9c44d3c..ac0c913 100644 --- a/meson.build +++ b/meson.build @@ -160,6 +160,9 @@ pkgconf.set('prefix', epoxy_prefix) pkgconf.set('exec_prefix', epoxy_prefix) pkgconf.set('libdir', epoxy_libdir) pkgconf.set('includedir', epoxy_includedir) +pkgconf.set10('epoxy_has_glx', build_glx) +pkgconf.set10('epoxy_has_egl', build_egl) +pkgconf.set10('epoxy_has_wgl', build_wgl) pkgconf.set('PACKAGE_VERSION', meson.project_version()) if dl_dep.found() pkgconf.set('DLOPEN_LIBS', '-ldl')