1From bb9765a926588ebfe1eb324fbbe8fc22d419eebe Mon Sep 17 00:00:00 2001
2From: Max Krummenacher <max.krummenacher@toradex.com>
3Date: Thu, 25 Jun 2020 11:27:40 +0000
4Subject: [PATCH] configure.ac: don't require eglmesaext.h
5
6E.g. the Vivante EGL implementation does not provide eglmesaext.h.
7
8The commit moves the check for header file existence outside of the
9check for existence of a egl packageconfig and makes the existence
10of eglmesaext.h optional.
11
12fixes commit fb1acfec ("Fix building against libglvnd-provided EGL headers")
13Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
14
15Upstream-Status: Submitted [https://gitlab.gnome.org/GNOME/cogl/-/merge_requests/28]
16Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
17---
18 configure.ac | 51 ++++++++++++++++++++++++++++++++-------------------
19 1 file changed, 32 insertions(+), 19 deletions(-)
20
21diff --git a/configure.ac b/configure.ac
22index b7ba95d..0d1d8de 100644
23--- a/configure.ac
24+++ b/configure.ac
25@@ -1212,22 +1212,6 @@ AS_IF([test "x$NEED_EGL" = "xyes" && test "x$EGL_CHECKED" != "xyes"],
26         PKG_CHECK_EXISTS([egl],
27           [COGL_PKG_REQUIRES="$COGL_PKG_REQUIRES egl"],
28           [
29-            AC_CHECK_HEADERS(
30-              [EGL/egl.h],
31-              [],
32-              [AC_MSG_ERROR([Unable to locate required EGL headers])])
33-            AC_CHECK_HEADERS(
34-              [EGL/eglext.h],
35-              [],
36-              [AC_MSG_ERROR([Unable to locate required EGL headers])],
37-              [#include <EGL/egl.h>])
38-            AC_CHECK_HEADERS(
39-              [EGL/eglmesaext.h],
40-              [],
41-              [AC_MSG_ERROR([Unable to locate required EGL headers])],
42-              [#include <EGL/egl.h>
43-#include <EGL/eglext.h>])
44-
45             AC_CHECK_LIB(EGL, [eglInitialize],
46               [COGL_EXTRA_LDFLAGS="$COGL_EXTRA_LDFLAGS -lEGL"],
47               [AC_MSG_ERROR([Unable to locate required EGL library])])
48@@ -1236,9 +1220,38 @@ AS_IF([test "x$NEED_EGL" = "xyes" && test "x$EGL_CHECKED" != "xyes"],
49           ]
50           )
51
52-        COGL_EGL_INCLUDES="#include <EGL/egl.h>
53-#include <EGL/eglext.h>
54-#include <EGL/eglmesaext.h>"
55+dnl Test for the existence of egl headers.
56+dnl egl*.h includes eglplatform.h which on __unix__ defaults to a X11 platform.
57+dnl In that case AC_CHECK_HEADERS failes if X11 headers are not available.
58+dnl Set the usual include guard define and, if the EGL implementation doesn't
59+dnl use that guard fall back to USE_OZONE and EGL_NO_X11 platforms which don't
60+dnl require additional headers.
61+        AC_CHECK_HEADERS(
62+          [EGL/egl.h],
63+          [COGL_EGL_INCLUDES="#include <EGL/egl.h>"],
64+          [AC_MSG_ERROR([Unable to locate required EGL headers])],
65+          [#define __egl_h_
66+ #define USE_OZONE
67+ #define EGL_NO_X11])
68+        AC_CHECK_HEADERS(
69+          [EGL/eglext.h],
70+          [COGL_EGL_INCLUDES="$COGL_EGL_INCLUDES
71+#include <EGL/eglext.h>"],
72+          [AC_MSG_ERROR([Unable to locate required EGL headers])],
73+          [#define __eglext_h_
74+ #define USE_OZONE
75+ #define EGL_NO_X11
76+$COGL_EGL_INCLUDES])
77+        AC_CHECK_HEADERS(
78+          [EGL/eglmesaext.h],
79+          [COGL_EGL_INCLUDES="$COGL_EGL_INCLUDES
80+#include <EGL/eglmesaext.h>"],
81+          [],
82+          [#define __eglmesaext_h_
83+#define USE_OZONE
84+#define EGL_NO_X11
85+$COGL_EGL_INCLUDES])
86+
87         AC_SUBST([COGL_EGL_INCLUDES])
88       ])
89
90--
912.20.1
92
93