1From 779438770bedf3d53e6ad8f7cd6889b7f50daf3b Mon Sep 17 00:00:00 2001
2From: Martin Jansa <Martin.Jansa@gmail.com>
3Date: Wed, 9 Jul 2014 14:23:41 +0200
4Subject: [PATCH] configure: Allow to disable demos which require GLEW or GLU
5
6* in some systems without X11 support we don't have GLEW, but
7  mesa-demos are still useful
8
9This isn't currently appropriate for upstream submission as glew has
10been replaced with glad there; glu situation would need to be re-assesed
11when upstream makes a new release, requested here:
12https://gitlab.freedesktop.org/mesa/demos/-/issues/22
13
14Upstream-Status: Inappropriate [see above]
15
16Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
17
18Port to 8.3.0
19Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
20---
21 configure.ac                  | 49 ++++++++++++++++++++---------
22 src/Makefile.am               | 18 ++++++++---
23 src/demos/Makefile.am         | 73 ++++++++++++++++++++++++-------------------
24 src/egl/Makefile.am           |  8 +++--
25 src/egl/opengles1/Makefile.am | 10 ++++--
26 src/egl/opengles2/Makefile.am | 29 ++++++++---------
27 6 files changed, 117 insertions(+), 70 deletions(-)
28
29diff --git a/configure.ac b/configure.ac
30index 0525b09..28834cd 100644
31--- a/configure.ac
32+++ b/configure.ac
33@@ -93,25 +93,44 @@ AC_EGREP_HEADER([glutInitContextProfile],
34 		[AC_DEFINE(HAVE_FREEGLUT)],
35 		[])
36
37-dnl Check for GLEW
38-PKG_CHECK_MODULES(GLEW, [glew >= 1.5.4])
39-DEMO_CFLAGS="$DEMO_CFLAGS $GLEW_CFLAGS"
40-DEMO_LIBS="$DEMO_LIBS $GLEW_LIBS"
41+AC_ARG_ENABLE([glew],
42+    [AS_HELP_STRING([--enable-glew],
43+        [build demos which require glew @<:@default=yes@:>@])],
44+    [enable_glew="$enableval"],
45+    [enable_glew=yes]
46+)
47+
48+if test "x$enable_glew" = xyes; then
49+    dnl Check for GLEW
50+    PKG_CHECK_MODULES(GLEW, [glew >= 1.5.4], [glew_enabled=yes], [glew_enabled=no])
51+    DEMO_CFLAGS="$DEMO_CFLAGS $GLEW_CFLAGS"
52+    DEMO_LIBS="$DEMO_LIBS $GLEW_LIBS"
53+fi
54
55 # LIBS was set by AC_CHECK_LIB above
56 LIBS=""
57
58-PKG_CHECK_MODULES(GLU, [glu], [],
59-		  [AC_CHECK_HEADER([GL/glu.h],
60-				   [],
61-		  		   AC_MSG_ERROR([GLU not found]))
62-		   AC_CHECK_LIB([GLU],
63-				[gluBeginCurve],
64-				[GLU_LIBS=-lGLU],
65-				AC_MSG_ERROR([GLU required])) ])
66+AC_ARG_ENABLE([glu],
67+    [AS_HELP_STRING([--enable-glu],
68+        [build demos which require glu @<:@default=yes@:>@])],
69+    [enable_glu="$enableval"],
70+    [enable_glu=yes]
71+)
72
73-DEMO_CFLAGS="$DEMO_CFLAGS $GLU_CFLAGS"
74-DEMO_LIBS="$DEMO_LIBS $GLU_LIBS"
75+if test "x$enable_glu" = xyes; then
76+    PKG_CHECK_MODULES(GLU, [glu], [glu_enabled=yes],
77+                     [AC_CHECK_HEADER([GL/glu.h],
78+                                      [],
79+                                      AC_MSG_ERROR([GLU not found]))
80+                      AC_CHECK_LIB([GLU],
81+                                   [gluBeginCurve],
82+                                   [GLU_LIBS=-lGLU
83+				    glu_enabled=yes],
84+                                   AC_MSG_ERROR([GLU required])) ])
85+
86+    DEMO_CFLAGS="$DEMO_CFLAGS $GLU_CFLAGS"
87+    DEMO_LIBS="$DEMO_LIBS $GLU_LIBS"
88+fi
89
90 AC_ARG_ENABLE([egl],
91     [AS_HELP_STRING([--enable-egl],
92@@ -304,6 +323,8 @@ AC_SUBST([WAYLAND_CFLAGS])
93 AC_SUBST([WAYLAND_LIBS])
94
95
96+AM_CONDITIONAL(HAVE_GLU, test "x$glu_enabled" = "xyes")
97+AM_CONDITIONAL(HAVE_GLEW, test "x$glew_enabled" = "xyes")
98 AM_CONDITIONAL(HAVE_EGL, test "x$egl_enabled" = "xyes")
99 AM_CONDITIONAL(HAVE_GLESV1, test "x$glesv1_enabled" = "xyes")
100 AM_CONDITIONAL(HAVE_GLESV2, test "x$glesv2_enabled" = "xyes")
101diff --git a/src/Makefile.am b/src/Makefile.am
102index 1647d64..8b89dee 100644
103--- a/src/Makefile.am
104+++ b/src/Makefile.am
105@@ -22,15 +22,19 @@
106 # Authors:
107 #    Eric Anholt <eric@anholt.net>
108
109+if HAVE_GLEW
110+UTIL = util
111+endif
112+
113 SUBDIRS = \
114-	util \
115+	$(UTIL) \
116 	data \
117 	demos \
118 	egl \
119 	fp \
120 	fpglsl \
121 	glsl \
122-        gs \
123+	gs \
124 	objviewer \
125 	osdemos \
126 	perf \
127@@ -40,8 +44,12 @@ SUBDIRS = \
128 	slang \
129 	tests \
130 	tools \
131-	trivial \
132-	vp \
133-	vpglsl \
134 	wgl \
135 	xdemos
136+
137+if HAVE_GLEW
138+SUBDIRS += \
139+	vp \
140+	vpglsl \
141+	trivial
142+endif
143diff --git a/src/demos/Makefile.am b/src/demos/Makefile.am
144index 41603fa..ab1e3ab 100644
145--- a/src/demos/Makefile.am
146+++ b/src/demos/Makefile.am
147@@ -30,91 +30,100 @@ AM_LDFLAGS = \
148 	$(DEMO_LIBS) \
149 	$(GLUT_LIBS)
150
151+bin_PROGRAMS =
152+
153 if HAVE_GLUT
154-bin_PROGRAMS = \
155+if HAVE_GLEW
156+bin_PROGRAMS += \
157 	arbfplight \
158 	arbfslight \
159 	arbocclude \
160 	arbocclude2 \
161-	bounce \
162-	clearspd \
163 	copypix \
164 	cubemap \
165 	cuberender \
166 	dinoshade \
167-	dissolve \
168-	drawpix \
169 	engine \
170 	fbo_firecube \
171 	fbotexture \
172-	fire \
173 	fogcoord \
174 	fplight \
175 	fslight \
176+	gloss \
177+	isosurf \
178+	multiarb \
179+	paltex \
180+	pointblast \
181+	projtex \
182+	shadowtex \
183+	spriteblast \
184+	stex3d \
185+	textures \
186+	vao_demo \
187+	winpos
188+
189+copypix_LDADD = ../util/libutil.la
190+cubemap_LDADD = ../util/libutil.la
191+cuberender_LDADD = ../util/libutil.la
192+engine_LDADD = ../util/libutil.la
193+fbo_firecube_LDADD = ../util/libutil.la
194+gloss_LDADD = ../util/libutil.la
195+isosurf_LDADD = ../util/libutil.la
196+multiarb_LDADD = ../util/libutil.la
197+projtex_LDADD = ../util/libutil.la
198+textures_LDADD = ../util/libutil.la
199+winpos_LDADD = ../util/libutil.la
200+endif
201+
202+if HAVE_GLU
203+bin_PROGRAMS += \
204+	bounce \
205+	clearspd \
206+	dissolve \
207+	drawpix \
208+	fire \
209 	gamma \
210 	gearbox \
211 	gears \
212 	geartrain \
213 	glinfo \
214-	gloss \
215 	gltestperf \
216 	ipers \
217-	isosurf \
218 	lodbias \
219 	morph3d \
220-	multiarb \
221-	paltex \
222 	pixeltest \
223-	pointblast \
224-	projtex \
225 	ray \
226 	readpix \
227 	reflect \
228 	renormal \
229-	shadowtex \
230 	singlebuffer \
231 	spectex \
232-	spriteblast \
233-	stex3d \
234 	teapot \
235 	terrain \
236 	tessdemo \
237 	texcyl \
238 	texenv \
239-	textures \
240 	trispd \
241 	tunnel2 \
242-	tunnel \
243-	vao_demo \
244-	winpos
245-endif
246+	tunnel
247
248 tunnel_SOURCES = \
249 	tunnel.c \
250 	tunneldat.h
251
252-copypix_LDADD = ../util/libutil.la
253-cubemap_LDADD = ../util/libutil.la
254-cuberender_LDADD = ../util/libutil.la
255-drawpix_LDADD = ../util/libutil.la
256 dissolve_LDADD = ../util/libutil.la
257-engine_LDADD = ../util/libutil.la
258-fbo_firecube_LDADD = ../util/libutil.la
259+drawpix_LDADD = ../util/libutil.la
260 fire_LDADD = ../util/libutil.la
261-gloss_LDADD = ../util/libutil.la
262 ipers_LDADD = ../util/libutil.la
263-isosurf_LDADD = ../util/libutil.la
264 lodbias_LDADD = ../util/libutil.la
265-multiarb_LDADD = ../util/libutil.la
266-projtex_LDADD = ../util/libutil.la
267 readpix_LDADD = ../util/libutil.la
268 reflect_LDADD = ../util/libutil.la
269 teapot_LDADD = ../util/libutil.la
270 texcyl_LDADD = ../util/libutil.la
271-textures_LDADD = ../util/libutil.la
272 tunnel_LDADD = ../util/libutil.la
273 tunnel2_LDADD = ../util/libutil.la
274-winpos_LDADD = ../util/libutil.la
275+endif
276+endif
277
278 EXTRA_DIST = \
279 	README
280diff --git a/src/egl/Makefile.am b/src/egl/Makefile.am
281index d64a49e..4fe1ca8 100644
282--- a/src/egl/Makefile.am
283+++ b/src/egl/Makefile.am
284@@ -24,8 +24,12 @@
285
286 SUBDIRS = \
287 	eglut \
288-	opengl \
289-	openvg \
290 	opengles1 \
291 	opengles2 \
292 	oes_vg
293+
294+if HAVE_GLU
295+SUBDIRS += \
296+	opengl \
297+	openvg
298+endif
299diff --git a/src/egl/opengles1/Makefile.am b/src/egl/opengles1/Makefile.am
300index fa397c2..21853e8 100644
301--- a/src/egl/opengles1/Makefile.am
302+++ b/src/egl/opengles1/Makefile.am
303@@ -36,9 +36,12 @@ AM_LDFLAGS = \
304 	$(EGL_LIBS) \
305 	-lm
306
307+noinst_PROGRAMS =
308+
309 if HAVE_EGL
310 if HAVE_GLESV1
311-noinst_PROGRAMS = \
312+if HAVE_X11
313+bin_PROGRAMS = \
314 	bindtex \
315 	clear \
316 	drawtex_x11 \
317@@ -52,8 +55,6 @@ noinst_PROGRAMS = \
318 	torus_x11 \
319 	tri_x11 \
320 	two_win
321-endif
322-endif
323
324 bindtex_LDADD = $(X11_LIBS)
325 es1_info_LDADD = $(X11_LIBS)
326@@ -76,3 +77,6 @@ drawtex_x11_LDADD = ../eglut/libeglut_x11.la
327 gears_x11_LDADD = ../eglut/libeglut_x11.la
328 torus_x11_LDADD = ../eglut/libeglut_x11.la
329 tri_x11_LDADD = ../eglut/libeglut_x11.la
330+endif
331+endif
332+endif
333diff --git a/src/egl/opengles2/Makefile.am b/src/egl/opengles2/Makefile.am
334index b80ba50..17f8d49 100644
335--- a/src/egl/opengles2/Makefile.am
336+++ b/src/egl/opengles2/Makefile.am
337@@ -33,27 +33,28 @@ AM_LDFLAGS = \
338 	$(EGL_LIBS) \
339 	-lm
340
341+bin_PROGRAMS =
342+
343 if HAVE_EGL
344 if HAVE_GLESV2
345-bin_PROGRAMS =
346-if HAVE_X11
347-bin_PROGRAMS += \
348-	es2_info \
349-	es2gears_x11 \
350-	es2tri
351-endif
352 if HAVE_WAYLAND
353 bin_PROGRAMS += es2gears_wayland
354-endif
355-endif
356+
357+es2gears_wayland_SOURCES = es2gears.c
358+es2gears_wayland_LDADD = ../eglut/libeglut_wayland.la
359 endif
360
361-es2_info_LDADD = $(X11_LIBS)
362-es2tri_LDADD = $(X11_LIBS)
363+if HAVE_X11
364+bin_PROGRAMS += \
365+	es2tri \
366+	es2_info \
367+	es2gears_x11
368
369+es2_info_LDADD = $(X11_LIBS)
370 es2gears_x11_SOURCES = es2gears.c
371-
372 es2gears_x11_LDADD = ../eglut/libeglut_x11.la
373+es2tri_LDADD = $(X11_LIBS)
374+endif
375+endif
376+endif
377
378-es2gears_wayland_SOURCES = es2gears.c
379-es2gears_wayland_LDADD = ../eglut/libeglut_wayland.la
380--
3812.1.4
382
383