gl: don't install the viv-fb window header file
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-base / gst-libs / gst / gl / meson.build
1 gstgl_dep = dependency('', required : false)
2 gstglproto_dep = dependency('', required : false)
3 gstglx11_dep = dependency('', required : false)
4 gstglwayland_dep = dependency('', required : false)
5 gstglegl_dep = dependency('', required : false)
6
7 if get_option('gl').disabled()
8   message('GStreamer OpenGL integration disabled via options.')
9   build_gstgl = false
10   subdir_done()
11 endif
12
13 gl_sources = files([
14   'gstglapi.c',
15   'gstglbasefilter.c',
16   'gstglbasememory.c',
17   'gstglbasesrc.c',
18   'gstglcolorconvert.c',
19   'gstglbuffer.c',
20   'gstglbufferpool.c',
21   'gstglcontext.c',
22   'gstglcontextconfig.c',
23   'gstglcontextquirks.c',
24   'gstgldebug.c',
25   'gstgldisplay.c',
26   'gstglfeature.c',
27   'gstglfilter.c',
28   'gstglformat.c',
29   'gstglframebuffer.c',
30   'gstglmemory.c',
31   'gstglmemorypbo.c',
32   'gstgloverlaycompositor.c',
33   'gstglquery.c',
34   'gstglrenderbuffer.c',
35   'gstglshader.c',
36   'gstglshaderstrings.c',
37   'gstglsl.c',
38   'gstglslstage.c',
39   'gstglsyncmeta.c',
40   'gstglupload.c',
41   'gstglutils.c',
42   'gstglviewconvert.c',
43   'gstglwindow.c',
44 ])
45
46 gl_priv_sources = []
47
48 gir_gl_headers = files([
49   'gl.h',
50   'gl-prelude.h',
51   'gstgl_enums.h',
52   'gstgl_fwd.h',
53   'gstglapi.h',
54   'gstglbasefilter.h',
55   'gstglbasememory.h',
56   'gstglbasesrc.h',
57   'gstglbuffer.h',
58   'gstglbufferpool.h',
59   'gstglcolorconvert.h',
60   'gstglcontext.h',
61   'gstglcontextconfig.h',
62   'gstgldebug.h',
63   'gstgldisplay.h',
64   'gstglfeature.h',
65   'gstglfilter.h',
66   'gstglformat.h',
67   'gstglframebuffer.h',
68   'gstglmemory.h',
69   'gstglmemorypbo.h',
70   'gstgloverlaycompositor.h',
71   'gstglquery.h',
72   'gstglrenderbuffer.h',
73   'gstglshader.h',
74   'gstglshaderstrings.h',
75   'gstglsl.h',
76   'gstglslstage.h',
77   'gstglsyncmeta.h',
78   'gstglupload.h',
79   'gstglutils.h',
80   'gstglviewconvert.h',
81   'gstglwindow.h',
82 ])
83
84 gl_headers = gir_gl_headers + files([
85   'gstglfuncs.h',
86 ])
87
88 gl_prototype_headers = files([
89   'glprototypes/all_functions.h',
90   'glprototypes/base.h',
91   'glprototypes/buffer_storage.h',
92   'glprototypes/blending.h',
93   'glprototypes/buffers.h',
94   'glprototypes/debug.h',
95   'glprototypes/eglimage.h',
96   'glprototypes/fbo.h',
97   'glprototypes/fixedfunction.h',
98   'glprototypes/gles.h',
99   'glprototypes/gstgl_compat.h',
100   'glprototypes/gstgl_gles2compat.h',
101   'glprototypes/opengl.h',
102   'glprototypes/query.h',
103   'glprototypes/shaders.h',
104   'glprototypes/sync.h',
105   'glprototypes/vao.h',
106 ])
107
108 gl_x11_sources = []
109 gl_x11_headers = []
110 gl_wayland_sources = []
111 gl_wayland_headers = []
112 gl_egl_sources = []
113 gl_egl_headers = []
114
115 glconf = configuration_data()
116 glconf_options = [
117     'GST_GL_HAVE_OPENGL',
118     'GST_GL_HAVE_GLES2',
119     'GST_GL_HAVE_GLES3',
120     'GST_GL_HAVE_GLES3EXT3_H',
121
122     'GST_GL_HAVE_WINDOW_X11',
123     'GST_GL_HAVE_WINDOW_COCOA',
124     'GST_GL_HAVE_WINDOW_WIN32',
125     'GST_GL_HAVE_WINDOW_WINRT',
126     'GST_GL_HAVE_WINDOW_WAYLAND',
127     'GST_GL_HAVE_WINDOW_ANDROID',
128     'GST_GL_HAVE_WINDOW_DISPMANX',
129     'GST_GL_HAVE_WINDOW_EAGL',
130     'GST_GL_HAVE_WINDOW_VIV_FB',
131     'GST_GL_HAVE_WINDOW_GBM',
132
133     'GST_GL_HAVE_PLATFORM_EGL',
134     'GST_GL_HAVE_PLATFORM_GLX',
135     'GST_GL_HAVE_PLATFORM_WGL',
136     'GST_GL_HAVE_PLATFORM_CGL',
137     'GST_GL_HAVE_PLATFORM_EAGL',
138
139     'GST_GL_HAVE_DMABUF',
140     'GST_GL_HAVE_VIV_DIRECTVIV',
141
142     'GST_GL_HAVE_GLEGLIMAGEOES',
143     'GST_GL_HAVE_GLCHAR',
144     'GST_GL_HAVE_GLSIZEIPTR',
145     'GST_GL_HAVE_GLINTPTR',
146     'GST_GL_HAVE_GLSYNC',
147     'GST_GL_HAVE_GLUINT64',
148     'GST_GL_HAVE_GLINT64',
149     'GST_GL_HAVE_EGLATTRIB',
150     'GST_GL_HAVE_EGLUINT64KHR',
151 ]
152
153 foreach option : glconf_options
154   glconf.set(option, 0)
155 endforeach
156
157 unneeded_dep = dependency('', required : false)
158 if unneeded_dep.found()
159   error ('Found unfindable dependency')
160 endif
161
162 # OpenGL/GLES2 libraries
163 gl_lib_deps = []
164 # GL platform - EGL, GLX, CGL, WGL, etc
165 gl_platform_deps = []
166 # GL winsys - wayland, X11, Cocoa, win32, etc
167 gl_winsys_deps = []
168 # other things we need.
169 gl_misc_deps = []
170 # Other preprocessor arguments
171 gl_cpp_args = []
172 gl_includes = []
173 gl_objc_args = []
174
175 enabled_gl_apis = []
176 enabled_gl_platforms = []
177 enabled_gl_winsys = []
178
179 # parse provided options
180 libegl_module_name = get_option('egl_module_name')
181 if libegl_module_name != ''
182   gl_cpp_args += ['-DGST_GL_LIBEGL_MODULE_NAME="@0@"'.format(libegl_module_name)]
183 endif
184 libgles2_module_name = get_option('gles2_module_name')
185 if libgles2_module_name != ''
186   gl_cpp_args += ['-DGST_GL_LIBGLESV2_MODULE_NAME="@0@"'.format(libgles2_module_name)]
187 endif
188 libgl_module_name = get_option('opengl_module_name')
189 if libgl_module_name != ''
190   gl_cpp_args += ['-DGST_GL_LIBGL_MODULE_NAME="@0@"'.format(libgl_module_name)]
191 endif
192
193 gl_apis = get_option('gl_api')
194 if gl_apis.contains('auto')
195   need_api_opengl = 'auto'
196   need_api_gles2 = 'auto'
197 else
198   need_api_opengl = 'no'
199   need_api_gles2 = 'no'
200   foreach api : gl_apis
201     if api == 'opengl'
202       need_api_opengl = 'yes'
203     elif api == 'gles2'
204       need_api_gles2 = 'yes'
205     else
206       error('Unsupported GL api provided ' + api)
207     endif
208   endforeach
209 endif
210
211 gl_platforms = get_option('gl_platform')
212 if gl_platforms.contains('auto')
213   need_platform_egl = 'auto'
214   need_platform_glx = 'auto'
215   need_platform_cgl = 'auto'
216   need_platform_wgl = 'auto'
217   need_platform_eagl = 'auto'
218 else
219   need_platform_egl = 'no'
220   need_platform_glx = 'no'
221   need_platform_cgl = 'no'
222   need_platform_wgl = 'no'
223   need_platform_eagl = 'no'
224   foreach platform : gl_platforms
225     if platform == 'egl'
226       need_platform_egl = 'yes'
227     elif platform == 'glx'
228       need_platform_glx = 'yes'
229     elif platform == 'cgl'
230       need_platform_cgl = 'yes'
231     elif platform == 'wgl'
232       need_platform_wgl = 'yes'
233     elif platform == 'eagl'
234       need_platform_eagl = 'yes'
235     else
236       error('Unsupported GL platform provided ' + platform)
237     endif
238   endforeach
239 endif
240
241 gl_winsys = get_option('gl_winsys')
242 if gl_winsys.contains('auto')
243   need_win_x11 = 'auto'
244   need_win_wayland = 'auto'
245   need_win_win32 = 'auto'
246   need_win_winrt = 'auto'
247   need_win_cocoa = 'auto'
248   need_win_egl = 'auto'
249   need_win_eagl = 'auto'
250   need_win_dispmanx = 'auto'
251   need_win_viv_fb = 'auto'
252   need_win_gbm = 'auto'
253   need_win_android = 'auto'
254 else
255   need_win_x11 = 'no'
256   need_win_wayland = 'no'
257   need_win_win32 = 'no'
258   need_win_winrt = 'no'
259   need_win_cocoa = 'no'
260   need_win_egl = 'no'
261   need_win_eagl = 'no'
262   need_win_dispmanx = 'no'
263   need_win_viv_fb = 'no'
264   need_win_gbm = 'no'
265   need_win_android = 'no'
266   foreach winsys : gl_winsys
267     if winsys == 'x11'
268       need_win_x11 = 'yes'
269     elif winsys == 'wayland'
270       need_win_wayland = 'yes'
271     elif winsys == 'win32'
272       need_win_win32 = 'yes'
273     elif winsys == 'winrt'
274       need_win_winrt = 'yes'
275     elif winsys == 'cocoa'
276       need_win_cocoa = 'yes'
277     elif winsys == 'egl'
278       need_win_egl = 'yes'
279     elif winsys == 'eagl'
280       need_win_eagl = 'yes'
281     elif winsys == 'dispmanx'
282       need_win_dispmanx = 'yes'
283     elif winsys == 'viv-fb'
284       need_win_viv_fb = 'yes'
285     elif winsys == 'gbm'
286       need_win_gbm = 'yes'
287     elif winsys == 'android'
288       need_win_android = 'yes'
289     else
290       error('Unsupported GL winsys provided ' + winsys)
291     endif
292   endforeach
293 endif
294
295 gl_include_header = '''
296 #ifdef __GNUC__
297 #  pragma GCC diagnostic push
298 #  pragma GCC diagnostic ignored "-Wredundant-decls"
299 #endif
300 #ifndef GL_GLEXT_PROTOTYPES
301 #define GL_GLEXT_PROTOTYPES 1
302 #endif
303 '''
304
305 # convoluted way of getting at the subproject taking into account the wrap-mode
306 # so we don't download a subproject unless allowed
307 gl_header_dep = dependency('', fallback : ['gl-headers', 'gl_headers_dummy_dep'],
308     required : false)
309 if gl_header_dep.type_name() == 'internal'
310   # this will only contain the includes of headers that are not found
311   compat_includes = subproject('gl-headers').get_variable('compatibility_includes')
312 else
313   compat_includes = []
314 endif
315
316 # Desktop OpenGL checks
317 gl_dep = unneeded_dep
318 glx_dep = unneeded_dep
319
320 # (GLVND) OpenGL (without GLX) headers and interface
321 if need_api_opengl != 'no'
322   gl_dep = dependency('opengl', method: 'pkg-config', required : false)
323 endif
324
325 # non-GLVND aka Legacy OpenGL
326 if need_api_opengl != 'no' and not gl_dep.found()
327   if host_system == 'darwin'
328     gl_dep = dependency('appleframeworks', modules : ['OpenGL'], required : false)
329   else
330     # override meson's braindead gl detection on osx/windows/etc by forcing pkg-config
331     gl_dep = dependency('gl', method: 'pkg-config', required : false)
332   endif
333
334   if not gl_dep.found()
335     if host_system == 'windows'
336       gl_dep = cc.find_library('opengl32', required : false)
337     else
338       gl_dep = cc.find_library('GL', required : false)
339     endif
340
341     if not cc.has_header('GL/gl.h', include_directories : compat_includes)
342       gl_dep = unneeded_dep
343     endif
344
345     if not gl_dep.found() and need_api_opengl == 'yes'
346       error ('Could not find requested OpenGL library')
347     endif
348
349     if gl_dep.found()
350       gl_includes += [compat_includes]
351     endif
352   endif
353 endif
354
355 if need_platform_glx != 'no'
356   # (GLVND) GLX library and headers.
357   glx_dep = dependency('glx', method: 'pkg-config', required : false)
358
359   if not glx_dep.found()
360     if host_system == 'darwin'
361       glx_dep = cc.find_library('GL', required : false)
362     elif gl_dep.found()
363       glx_dep = gl_dep
364     elif need_platform_glx == 'yes'
365       error ('Could not find requested GLX library')
366     endif
367   endif
368 endif
369
370 if need_api_opengl != 'no'
371   opengl_includes = ''
372   if host_system == 'darwin'
373     opengl_includes += '''
374 #if !defined(MAC_OS_X_VERSION_MAX_ALLOWED) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1014
375 # define GL_SILENCE_DEPRECATION
376 #endif
377 #include <OpenGL/OpenGL.h>
378 #include <OpenGL/gl.h>
379 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
380 # define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
381 # include <OpenGL/gl3.h>
382 #endif
383 '''
384   else
385     opengl_includes += '''
386 #if _MSC_VER
387 # include <windows.h>
388 #endif
389 #include <GL/gl.h>
390 #if __WIN32__ || _WIN32
391 # include <GL/glext.h>
392 #endif
393 '''
394   endif
395 endif
396
397 bcm_host_dep = unneeded_dep
398 if need_win_dispmanx != 'no'
399
400   # Try pkg-config for bcm_host then fallback to find_library to also
401   # support older distribution
402   bcm_host_dep = dependency('bcm_host', required : false)
403   if not bcm_host_dep.found()
404     bcm_host_dep = cc.find_library('bcm_host', required : false)
405   endif
406 endif
407
408 # GLES2 checks
409 gles2_dep = unneeded_dep
410 gles3_h = false
411 gles3ext3_h = false
412 if need_api_gles2 != 'no'
413   if host_system == 'ios'
414     gles2_dep = dependency('appleframeworks', modules : ['OpenGLES'], required : false)
415   else
416     if bcm_host_dep.found()
417       gles2_dep = dependency('brcmglesv2', required : false)
418     endif
419     if not gles2_dep.found()
420       gles2_dep = dependency('glesv2', required : false)
421     endif
422   endif
423
424   if not gles2_dep.found()
425 #    if host_system == 'windows'
426 #    elif host_system == ios
427 #      gles2_dep = cc.find_library('GLESv2', required : false)
428 #    else
429       gles2_dep = cc.find_library('GLESv2', required : false)
430 #    endif
431
432     if not cc.has_header('GLES2/gl2.h', include_directories : compat_includes)
433       gles2_dep = unneeded_dep
434     endif
435
436     if not gles2_dep.found() and need_api_gles2 == 'yes'
437       error ('Could not find requested OpenGL ES library')
438     endif
439
440     if gles2_dep.found()
441       gl_includes += [compat_includes]
442     endif
443   endif
444
445   gles3_h = gles2_dep.found() and cc.has_header('GLES3/gl3.h', dependencies : gles2_dep, include_directories : compat_includes)
446
447   gles_includes = ''
448   if host_system == 'ios'
449     gles_includes += '''
450 # include <OpenGLES/ES2/gl.h>
451 # include <OpenGLES/ES2/glext.h>
452 '''
453   else
454     if gles3_h
455       gl_includes += [compat_includes]
456       gles3ext3_h = gles3_h and cc.has_header('GLES3/gl3ext.h', dependencies : gles2_dep, include_directories : compat_includes)
457       gles_includes += '''
458 # include <GLES3/gl3.h>
459 # include <GLES2/gl2ext.h>'''
460       if gles3ext3_h
461         gles_includes += '''
462 # include <GLES3/gl3ext.h>'''
463       endif
464     else
465       gles_includes += '''
466 # include <GLES2/gl2.h>
467 # include <GLES2/gl2ext.h>'''
468     endif
469   endif
470 endif
471
472 # can we include both gles2 and opengl headers?
473 if gles2_dep.found() and gl_dep.found()
474   gl_include_block = gl_include_header + gles_includes + opengl_includes
475   # TODO: Revert to passing gl_include_block via prefix: once
476   # https://github.com/mesonbuild/meson/issues/2364 is fixed
477   if not cc.compiles(gl_include_block + '\n' + 'void f (void) {}',dependencies : [gles2_dep, gl_dep], include_directories : compat_includes)
478     message ('Cannot include both OpenGL and OpenGL ES headers')
479     if need_api_gles2 != 'yes'
480       gles2_dep = unneeded_dep
481     elif need_api_opengl != 'yes'
482       gl_dep = unneeded_dep
483     else
484       error('Both OpenGL and OpenGL ES were requested but cannot be included together')
485     endif
486   endif
487 endif
488 gl_include_block = gl_include_header
489 if gles2_dep.found()
490   gl_include_block += gles_includes
491 endif
492 if gl_dep.found()
493   gl_include_block += opengl_includes
494 endif
495
496 if gles2_dep.found()
497   gl_lib_deps += gles2_dep
498   glconf.set('GST_GL_HAVE_GLES2', 1)
499   if gles3_h
500     glconf.set('GST_GL_HAVE_GLES3',1)
501     if gles3ext3_h
502       glconf.set('GST_GL_HAVE_GLES3EXT3_H', 1)
503     endif
504   endif
505   enabled_gl_apis += 'gles2'
506 endif
507
508 if gl_dep.found()
509   gl_lib_deps += gl_dep
510   glconf.set('GST_GL_HAVE_OPENGL', 1)
511   enabled_gl_apis += 'gl'
512 endif
513
514 # EGL checks
515 egl_dep = unneeded_dep
516 if need_platform_egl != 'no'
517   if bcm_host_dep.found()
518     egl_dep = dependency('brcmegl', required : false)
519   endif
520   if not egl_dep.found()
521     egl_dep = dependency('egl', required : false)
522   endif
523   if not egl_dep.found()
524     egl_dep = cc.find_library('EGL', required : false)
525   endif
526
527   if egl_dep.found() and not cc.has_header('EGL/egl.h',
528                                            dependencies : egl_dep,
529                                            include_directories : compat_includes)
530     egl_dep = unneeded_dep
531   endif
532   if egl_dep.found() and not cc.has_header('EGL/eglext.h',
533                                            dependencies : egl_dep,
534                                            include_directories : compat_includes)
535     egl_dep = unneeded_dep
536   endif
537
538   if egl_dep.found()
539     gl_egl_sources += files([
540       'egl/gstegl.c',
541       'egl/gsteglimage.c',
542       'egl/gstglcontext_egl.c',
543       'egl/gstgldisplay_egl.c',
544       'egl/gstglmemoryegl.c',
545       'egl/gstgldisplay_egl_device.c',
546     ])
547     gl_egl_headers += files([
548       'egl/egl.h',
549       'egl/gstegl.h',
550       'egl/gsteglimage.h',
551       'egl/gstgldisplay_egl.h',
552       'egl/gstglmemoryegl.h',
553       'egl/gstgldisplay_egl_device.h',
554     ])
555     gl_platform_deps += egl_dep
556     glconf.set('GST_GL_HAVE_PLATFORM_EGL', 1)
557
558     if cc.has_header('libdrm/drm_fourcc.h')
559       gl_misc_deps += allocators_dep
560       glconf.set('GST_GL_HAVE_DMABUF', 1)
561     endif
562
563     egl_includes = '''
564 #include <EGL/egl.h>
565 #include <EGL/eglext.h>
566 '''
567     enabled_gl_platforms += 'egl'
568   elif need_platform_egl == 'yes'
569     error ('Could not find requested EGL library')
570   endif
571 endif
572
573 # winsys_egl checks
574 if need_win_egl == 'yes'
575   if need_platform_egl == 'no'
576     error('Impossible situation requested: Cannot use Winsys egl without EGL support')
577   elif not egl_dep.found()
578     error ('Could not find EGL libraries for Winsys egl')
579   else
580     enabled_gl_winsys += 'egl'
581   endif
582 endif
583
584 # wayland checks
585 wayland_client_dep = unneeded_dep
586 wayland_cursor_dep = unneeded_dep
587 wayland_egl_dep = unneeded_dep
588 if need_win_wayland != 'no'
589   if need_win_wayland == 'yes'
590     if need_platform_egl == 'no'
591       error('Impossible situation requested: Cannot use Wayland without EGL support')
592     endif
593   endif
594   if not egl_dep.found()
595     if need_win_wayland == 'yes'
596       error ('Could not find EGL libraries for wayland')
597     else
598       message ('Could not find EGL libraries for wayland')
599     endif
600   else
601     wayland_client_dep = dependency('wayland-client', version : '>= 1.11', required : false)
602     wayland_cursor_dep = dependency('wayland-cursor', version : '>= 1.0', required : false)
603     wayland_egl_dep = dependency('wayland-egl', version : '>= 1.0', required : false)
604     wayland_protocols_dep = dependency('wayland-protocols', version : '>= 1.15', required : false)
605     wayland_scanner = find_program('wayland-scanner', required: false)
606
607     if wayland_client_dep.found() and wayland_cursor_dep.found() and wayland_egl_dep.found() and wayland_protocols_dep.found() and wayland_scanner.found()
608       # Generate the XDG shell interface
609       wayland_protocols_basedir = wayland_protocols_dep.get_variable('pkgdatadir')
610       xdg_shell_xml_spec = join_paths(wayland_protocols_basedir, 'stable', 'xdg-shell', 'xdg-shell.xml')
611       xdg_shell_header = custom_target('xdg-shell-client-header',
612         command: [ wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@' ],
613         input: xdg_shell_xml_spec,
614         output: 'xdg-shell-client-protocol.h',
615       )
616       xdg_shell_code = custom_target('xdg-shell-client-code',
617         command: [ wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@' ],
618         input: xdg_shell_xml_spec,
619         output: 'xdg-shell-client-protocol.c',
620       )
621
622       gl_wayland_sources += files([
623         'wayland/gstgldisplay_wayland.c',
624       ])
625       gl_priv_sources += [
626         'wayland/gstglwindow_wayland_egl.c',
627         'wayland/wayland_event_source.c',
628         xdg_shell_header,
629         xdg_shell_code,
630       ]
631       gl_wayland_headers += files([
632         'wayland/wayland.h',
633         'wayland/gstgldisplay_wayland.h'
634       ])
635       glconf.set('GST_GL_HAVE_WINDOW_WAYLAND', 1)
636       gl_winsys_deps += [wayland_client_dep, wayland_cursor_dep, wayland_egl_dep]
637       enabled_gl_winsys += 'wayland'
638     else
639       if need_win_wayland == 'yes'
640         error ('Could not find requested Wayland libraries')
641       endif
642       wayland_client_dep = unneeded_dep
643       wayland_cursor_dep = unneeded_dep
644       wayland_egl_dep = unneeded_dep
645       wayland_protocols_dep = unneeded_dep
646     endif
647   endif
648 endif
649
650 # X11 checks
651 if need_platform_glx == 'yes'
652   if need_win_x11 == 'no'
653     error('Impossible situation requested: Cannot use GLX without X11 support')
654   elif need_api_opengl == 'no'
655     error('Impossible situation requested: Cannot use GLX without the OpenGL library')
656   endif
657 endif
658
659 xcb_dep = unneeded_dep
660 if need_win_x11 != 'no'
661   xcb_dep = dependency('x11-xcb', required : false)
662   if x11_dep.found() and xcb_dep.found()
663     gl_x11_sources += files([
664       'x11/gstgldisplay_x11.c',
665     ])
666     gl_priv_sources += [
667       'x11/gstglwindow_x11.c',
668       'x11/xcb_event_source.c',
669     ]
670     gl_x11_headers += files([
671       'x11/x11.h',
672       'x11/gstgldisplay_x11.h',
673     ])
674     glconf.set('GST_GL_HAVE_WINDOW_X11', 1)
675     gl_winsys_deps += [x11_dep, xcb_dep]
676     enabled_gl_winsys += 'x11'
677
678     if need_platform_glx != 'no' and glx_dep.found() and cc.has_function ('glXMakeCurrent', dependencies : glx_dep)
679       glconf.set('GST_GL_HAVE_PLATFORM_GLX', 1)
680       gl_priv_sources += [
681         'x11/gstglcontext_glx.c',
682       ]
683       # GLX is in the opengl library on linux
684       gl_platform_deps += glx_dep
685       enabled_gl_platforms += 'glx'
686     endif
687   elif need_win_x11 == 'yes'
688     error ('Could not find requested X11 libraries')
689   endif
690 endif
691
692 if need_win_dispmanx != 'no'
693   have_dispmanx_window_t = cc.has_type(
694       'EGL_DISPMANX_WINDOW_T',
695       prefix: '''
696 #include <bcm_host.h>
697 #include <EGL/egl.h>
698 ''',
699       dependencies: [gl_lib_deps, egl_dep, bcm_host_dep],
700       include_directories: gl_includes)
701
702   if have_dispmanx_window_t and bcm_host_dep.found()
703     if not egl_dep.found()
704       error('dispmanx requires the use of egl')
705     endif
706
707     gl_priv_sources += [
708       'dispmanx/gstglwindow_dispmanx_egl.c'
709     ]
710
711     glconf.set('GST_GL_HAVE_WINDOW_DISPMANX', 1)
712     gl_winsys_deps += bcm_host_dep
713     enabled_gl_winsys += 'dispmanx'
714     gl_cpp_args += ['-DUSE_EGL_RPI']
715   elif need_win_dispmanx == 'yes'
716     error('Could not find dispmanx libraries')
717   endif
718 endif
719
720 # win32 checks
721 if need_platform_wgl == 'yes'
722   if need_win_win32 == 'no'
723     error('Impossible situation requested: Cannot use WGL without the win32 window system')
724   endif
725 endif
726
727 if host_system == 'windows' and need_win_win32 != 'no'
728   gdi_dep = cc.find_library('gdi32', required : false)
729   if gdi_dep.found()
730     have_wgl = false
731     have_egl_win32 = false
732     if need_platform_wgl != 'no'
733       wglext_h = cc.has_header('GL/wglext.h',
734                                prefix : '''#include <windows.h>
735                                            #include <GL/gl.h>''',
736                                include_directories : compat_includes)
737       have_wgl = wglext_h and gl_dep.found()
738     endif
739
740     have_egl_win32 = enabled_gl_platforms.contains('egl') and gles2_dep.found()
741     if have_wgl or have_egl_win32
742       gl_includes += [compat_includes]
743       gl_platform_deps += gdi_dep
744       gl_priv_sources += [
745         'win32/gstglwindow_win32.c',
746       ]
747       enabled_gl_winsys += 'win32'
748       gl_winsys_deps += gdi_dep
749       glconf.set('GST_GL_HAVE_WINDOW_WIN32', 1)
750     endif
751
752     if have_wgl
753       gl_priv_sources += [
754         'wgl/gstglcontext_wgl.c',
755       ]
756       enabled_gl_platforms += 'wgl'
757       glconf.set('GST_GL_HAVE_PLATFORM_WGL', 1)
758     endif
759   endif
760 endif
761
762 # WinRT ANGLE checks
763 if need_win_winrt != 'no' and host_system == 'windows'
764   if need_win_winrt == 'yes' and not enabled_gl_platforms.contains('egl')
765     error('Impossible situation requested: Cannot use WinRT ANGLE without EGL support')
766   endif
767
768   if egl_dep.found()
769     windows_graphics_h = cc.has_header('windows.graphics.h')
770     windows_app_dep = cc.find_library('WindowsApp', required: false)
771     runtimeobject_lib = cc.find_library('runtimeobject', required: false)
772
773     if windows_graphics_h and windows_app_dep.found() and runtimeobject_lib.found()
774       enabled_gl_winsys += 'winrt'
775       glconf.set('GST_GL_HAVE_WINDOW_WINRT', 1)
776       gl_priv_sources += [
777         'winrt/gstglwindow_winrt_egl.cpp'
778       ]
779       gl_winsys_deps += runtimeobject_lib
780     elif need_win_winrt == 'yes'
781       error('WinRT is enabled, but headers/libraries were not found')
782     endif
783   elif need_win_winrt == 'yes'
784     error('WinRT ANGLE is enabled, but EGL was not found')
785   else
786     message('WinRT ANGLE disabled because EGL was not found')
787   endif
788 endif
789
790 if ['darwin', 'ios'].contains(host_system)
791   if not have_objc
792     error('No ObjC compiler found')
793   endif
794
795   objc = meson.get_compiler('objc')
796   if not objc.has_argument('-fobjc-arc')
797     error('ARC is required for building')
798   endif
799
800   gl_objc_args += ['-fobjc-arc']
801 endif
802
803 # OSX check
804 if need_platform_cgl == 'yes'
805   if need_win_cocoa == 'no'
806     error('Impossible situation requested: Cannot use CGL without Cocoa support')
807   elif need_api_opengl == 'no'
808     error('Impossible situation requested: Cannot use CGL without the OpenGL library')
809   endif
810 elif need_platform_cgl == 'no' and need_win_cocoa == 'yes'
811   error('Impossible situation requested: Cannot use Cocoa without CGL support')
812 endif
813
814 if host_system == 'darwin'
815   foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false)
816   quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false)
817   corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false)
818
819   if need_platform_cgl != 'no'
820     if foundation_dep.found() and quartzcore_dep.found() and corefoundation_dep.found()
821       gl_platform_deps += [quartzcore_dep, corefoundation_dep, foundation_dep]
822       enabled_gl_platforms += 'cgl'
823       glconf.set('GST_GL_HAVE_PLATFORM_CGL', 1)
824
825       if need_win_cocoa != 'no'
826         cocoa_dep = dependency('appleframeworks', modules : ['Cocoa'], required : false)
827         if cocoa_dep.found()
828           gl_priv_sources += [
829             'cocoa/gstglcaopengllayer.m',
830             'cocoa/gstglcontext_cocoa.m',
831             'cocoa/gstgldisplay_cocoa.m',
832             'cocoa/gstglwindow_cocoa.m'
833           ]
834           gl_winsys_deps += cocoa_dep
835           enabled_gl_winsys += 'cocoa'
836           glconf.set('GST_GL_HAVE_WINDOW_COCOA', 1)
837         elif need_win_cocoa == 'yes'
838           error('Could not find Cocoa')
839         endif
840       endif
841     elif need_platform_cgl == 'yes'
842       error('Could not find CGL dependencies')
843     endif
844   endif
845 endif
846
847 if need_platform_eagl == 'yes'
848   if host_system != 'ios'
849     error('Can only use EAGL on iOS')
850   endif
851   if need_win_eagl == 'no'
852     error('Impossible situation requested: Cannot use EAGL platform without the EAGL window system')
853   elif need_api_gles == 'no'
854     error('Impossible situation requested: Cannot use EAGL platform without the GLES library')
855   endif
856 elif need_platform_eagl == 'no' and need_win_eagl == 'yes'
857   error('Impossible situation requested: Cannot use EAGL window system without the EAGL platform')
858 endif
859
860 if host_system == 'ios' and need_platform_eagl != 'no' and need_win_eagl != 'no'
861   foundation_dep = dependency('appleframeworks', modules : ['Foundation'], required : false)
862   corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required : false)
863   coregraphics_dep = dependency('appleframeworks', modules : ['CoreGraphics'], required : false)
864   quartzcore_dep = dependency('appleframeworks', modules : ['QuartzCore'], required : false)
865   uikit_dep = dependency('appleframeworks', modules : ['UIkit'], required : false)
866
867   if foundation_dep.found() and corefoundation_dep.found() and coregraphics_dep.found() and quartzcore_dep.found() and uikit_dep.found()
868     gl_platform_deps += [
869       corefoundation_dep,
870       foundation_dep,
871       coregraphics_dep,
872       quartzcore_dep,
873       uikit_dep,
874     ]
875     gl_priv_sources += [
876       'eagl/gstglcontext_eagl.m',
877       'eagl/gstglwindow_eagl.m',
878     ]
879     enabled_gl_winsys += 'eagl'
880     enabled_gl_platforms += 'eagl'
881     glconf.set('GST_GL_HAVE_WINDOW_EAGL', 1)
882     glconf.set('GST_GL_HAVE_PLATFORM_EAGL', 1)
883   elif need_platform_eagl == 'yes' or need_win_eagl == 'yes'
884     error('Could not find dependencies for EAGL')
885   endif
886 endif
887
888 # GBM Checks
889 gbm_gudev_dep = unneeded_dep
890 gbm_libdrm_dep = unneeded_dep
891 gbm_dep = unneeded_dep
892 if need_win_gbm != 'no'
893   if need_win_gbm == 'yes'
894     if need_platform_egl == 'no'
895       error('Impossible situation requested: Cannot use GBM without EGL support')
896     endif
897   endif
898
899   gbm_gudev_dep = dependency('gudev-1.0', version : '>=147', required : false)
900   gbm_libdrm_dep = dependency('libdrm', version : '>= 2.4.55', required : false)
901   gbm_dep = dependency('gbm', required : false)
902   if egl_dep.found() and gbm_gudev_dep.found() and gbm_libdrm_dep.found() and gbm_dep.found()
903     gl_priv_sources += [
904       'gbm/gstgldisplay_gbm.c',
905       'gbm/gstgl_gbm_utils.c',
906       'gbm/gstglwindow_gbm_egl.c',
907     ]
908     enabled_gl_winsys += 'gbm'
909     gl_winsys_deps += [gbm_gudev_dep, gbm_libdrm_dep, gbm_dep]
910     glconf.set('GST_GL_HAVE_WINDOW_GBM', 1)
911   else
912     if need_win_gbm == 'yes'
913       error ('Could not find requested GBM libraries')
914     endif
915     gbm_gudev_dep = unneeded_dep
916     gbm_libdrm_dep = unneeded_dep
917     gbm_dep = unneeded_dep
918   endif
919 endif
920
921 if cc.has_function ('glTexDirectVIV', dependencies : gles2_dep)
922   glconf.set('GST_GL_HAVE_VIV_DIRECTVIV', 1)
923 endif
924
925 if need_platform_egl != 'no' and need_win_viv_fb != 'no'
926   if egl_dep.found() and cc.has_function ('fbGetDisplay', dependencies : egl_dep)
927     enabled_gl_winsys += 'viv-fb'
928     glconf.set('GST_GL_HAVE_WINDOW_VIV_FB', 1)
929     gl_priv_sources += [
930       'viv-fb/gstgldisplay_viv_fb.c',
931       'viv-fb/gstglwindow_viv_fb_egl.c',
932     ]
933     gl_cpp_args += ['-DEGL_API_FB']
934     gl_viv_fb_headers = [
935       'viv-fb/gstgldisplay_viv_fb.h',
936     ]
937     install_headers(gl_viv_fb_headers, subdir : 'gstreamer-1.0/gst/gl/viv-fb')
938   endif
939 endif
940
941 if need_win_android == 'yes'
942   if need_platform_egl == 'no'
943     error('Impossible situation requested: Cannot build for Android without EGL')
944   elif need_api_gles2 == 'no'
945     error('Impossible situation requested: Cannot build for Android without GLES2 support')
946   elif host_system != 'android'
947     error('Impossible situation requested: Cannot build for Android without an android system')
948   endif
949 endif
950
951 if host_system == 'android' and need_win_android != 'no' and need_platform_egl != 'no'
952   if gles2_dep.found() and egl_dep.found()
953     enabled_gl_winsys += ['android']
954     glconf.set('GST_GL_HAVE_WINDOW_ANDROID', 1)
955     gl_priv_sources += [
956       'android/gstglwindow_android_egl.c'
957     ]
958   endif
959 endif
960
961 gl_nvmm = false
962 nvbuf_utils_dep = unneeded_dep
963 if egl_dep.found()
964   # XXX: provide options for this?
965   # c_args and c_link_args can also cover this case just fine e.g.:
966   # -Dc_args='-I/usr/src/jetson_multimedia_api/include' -Dc_link_args='-L/usr/lib/aarch64-linux-gnu/tegra/'
967   nvbuf_utils_dep = cc.find_library('nvbuf_utils', required : false)
968   nvbuf_utils_h = cc.has_header('nvbuf_utils.h')
969   if nvbuf_utils_dep.found() and nvbuf_utils_h
970     gl_misc_deps += [nvbuf_utils_dep]
971     gl_nvmm = true
972     gl_cpp_args += ['-DHAVE_NVMM']
973   endif
974 endif
975
976 build_gstgl = true
977 if enabled_gl_apis.length() == 0
978   message('No OpenGL API libraries found or requested')
979   build_gstgl = false
980 endif
981 if enabled_gl_platforms.length() == 0
982   message('No OpenGL Platforms found or requested')
983   build_gstgl = false
984 endif
985 if enabled_gl_winsys.length() == 0
986   message('No OpenGL Window systems found or requested')
987   build_gstgl = false
988 endif
989
990 if build_gstgl
991   # find some types that may or may not be defined
992   if cc.has_type('GLeglImageOES', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
993     glconf.set('GST_GL_HAVE_GLEGLIMAGEOES', 1)
994   endif
995   if cc.has_type('GLchar', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
996     glconf.set('GST_GL_HAVE_GLCHAR', 1)
997   endif
998   if cc.has_type('GLsizeiptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
999     glconf.set('GST_GL_HAVE_GLSIZEIPTR', 1)
1000   endif
1001   if cc.has_type('GLintptr', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1002     glconf.set('GST_GL_HAVE_GLINTPTR', 1)
1003   endif
1004   if cc.has_type('GLsync', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1005     glconf.set('GST_GL_HAVE_GLSYNC', 1)
1006   endif
1007   if cc.has_type('GLuint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1008     glconf.set('GST_GL_HAVE_GLUINT64', 1)
1009   endif
1010   if cc.has_type('GLint64', prefix : gl_include_block, dependencies : gl_lib_deps, include_directories : gl_includes)
1011     glconf.set('GST_GL_HAVE_GLINT64', 1)
1012   endif
1013   if egl_dep.found() and cc.has_type('EGLAttrib', prefix : gl_include_block + egl_includes, dependencies : gl_lib_deps + [egl_dep], include_directories : gl_includes)
1014     glconf.set('GST_GL_HAVE_EGLATTRIB', 1)
1015   endif
1016   if egl_dep.found() and cc.has_type('EGLuint64KHR', prefix : gl_include_block + egl_includes, dependencies : gl_lib_deps + [egl_dep], include_directories : gl_includes)
1017     glconf.set('GST_GL_HAVE_EGLUINT64KHR', 1)
1018   endif
1019
1020   summary('GL api', enabled_gl_apis, list_sep: ', ')
1021   summary('GL platform', enabled_gl_platforms, list_sep: ', ')
1022   summary('GL winsys', enabled_gl_winsys, list_sep: ', ')
1023
1024   install_headers(gl_headers, subdir : 'gstreamer-1.0/gst/gl')
1025   install_headers(gl_prototype_headers, subdir : 'gstreamer-1.0/gst/gl/glprototypes')
1026
1027   configure_file(input : 'gstglconfig.h.meson',
1028     output : 'gstglconfig.h',
1029     install_dir : get_option('libdir') + '/gstreamer-1.0/include/gst/gl',
1030     install_tag : 'devel',
1031     configuration : glconf)
1032
1033   glib_mkenums = find_program('glib-mkenums')
1034   mkenums = find_program('gl_mkenum.py')
1035   gl_enumtypes_h = custom_target('gstglenumtypes_h',
1036     output : 'gl-enumtypes.h',
1037     input : gir_gl_headers,
1038     install : true,
1039     install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/gl/'),
1040     command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
1041
1042   gl_enumtypes_c = custom_target('gstglenumtypes_c',
1043     output : 'gl-enumtypes.c',
1044     input : gir_gl_headers,
1045     depends : [gl_enumtypes_h],
1046     command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@'])
1047   gen_sources = [gl_enumtypes_h]
1048
1049   common_args = gst_plugins_base_args + gl_cpp_args + ['-DBUILDING_GST_GL', '-DG_LOG_DOMAIN="GStreamer-GL"']
1050
1051   # We have custom_target() that generate headers in the current build dir,
1052   # but with implicit_include_directories: false, meson >= 0.58.0 won't include
1053   # it by default. We cannot use include_directories('.') here because it would
1054   # also include current source dir which is what we want to avoid because
1055   # case-insensitive FS would include gst-libs/gl/egl/egl.h as EGL/egl.h.
1056   common_args += '-I@0@'.format(meson.current_build_dir())
1057
1058   gstgl = library('gstgl-' + api_version,
1059     gl_sources, gl_egl_sources, gl_x11_sources, gl_wayland_sources, gl_priv_sources, gl_enumtypes_c, gl_enumtypes_h,
1060     c_args : common_args,
1061     cpp_args : common_args,
1062     objc_args : common_args + gl_objc_args,
1063     include_directories : [configinc, libsinc, gl_includes],
1064     version : libversion,
1065     soversion : soversion,
1066     darwin_versions : osxversion,
1067     install : true,
1068     dependencies : [gst_base_dep, video_dep, allocators_dep, gmodule_dep,
1069                     gl_lib_deps, gl_platform_deps, gl_winsys_deps, gl_misc_deps],
1070     # don't confuse EGL/egl.h with gst-libs/gl/egl/egl.h on case-insensitive file systems
1071     implicit_include_directories : false)
1072
1073   pkgconfig_gl_variables = [
1074     'gl_platforms=' + ' '.join(enabled_gl_platforms),
1075     'gl_winsys=' + ' '.join(enabled_gl_winsys),
1076     'gl_apis=' + ' '.join(enabled_gl_apis),
1077   ]
1078
1079   library_def = {'lib': gstgl}
1080   pkg_name = 'gstreamer-gl-1.0'
1081   pkgconfig.generate(gstgl,
1082     libraries : [gstvideo, gst_base_dep, gst_dep],
1083     variables : pkgconfig_variables + pkgconfig_gl_variables,
1084     uninstalled_variables : pkgconfig_gl_variables,
1085     subdirs : pkgconfig_subdirs,
1086     extra_cflags : ['-I${libdir}/gstreamer-1.0/include'],
1087     name : pkg_name,
1088     description : 'Streaming media framework, OpenGL plugins libraries',
1089   )
1090
1091   # Desperate times, desperate measures... fix up escaping of our variables
1092   run_command(meson_pkg_config_file_fixup_script,
1093     'gstreamer-gl-1.0', 'gl_platforms', 'gl_winsys', 'gl_apis',
1094     check: true)
1095
1096   pkgconfig.generate(
1097     libraries : [gstgl, gl_lib_deps],
1098     subdirs : pkgconfig_subdirs,
1099     name : 'gstreamer-gl-prototypes-1.0',
1100     description : 'Streaming media framework, OpenGL plugins libraries (OpenGL Prototypes)',
1101   )
1102
1103   if build_gir
1104     gir = {
1105         'sources' : gl_sources + [gl_enumtypes_h] + [gl_enumtypes_c] + gir_gl_headers,
1106         'namespace' : 'GstGL',
1107         'nsversion' : api_version,
1108         'identifier_prefix' : 'Gst',
1109         'symbol_prefix' : 'gst',
1110         'export_packages' : pkg_name,
1111         'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1112         'install' : true,
1113         'extra_args' : gir_init_section + ['--c-include=gst/gl/gl.h'],
1114         'dependencies' : [video_dep, gst_dep, gst_base_dep],
1115     }
1116     library_def += {'gir': [gir]}
1117     if not static_build
1118       gl_gir = gnome.generate_gir(gstgl, kwargs: gir)
1119       gen_sources += [gl_gir]
1120     endif
1121   endif
1122   gst_libraries += [[pkg_name, library_def]]
1123   gstgl_dep = declare_dependency(link_with : gstgl,
1124     include_directories : [libsinc, compat_includes],
1125     sources: gen_sources,
1126     dependencies : [video_dep, gst_base_dep, gl_winsys_deps],
1127     variables: pkgconfig_gl_variables)
1128   gstglproto_dep = declare_dependency(
1129     dependencies : [gstgl_dep] + gl_lib_deps,
1130     sources: gen_sources
1131   )
1132   meson.override_dependency('gstreamer-gl-1.0', gstgl_dep)
1133   meson.override_dependency('gstreamer-gl-prototypes-1.0', gstglproto_dep)
1134
1135   if gl_x11_headers.length() > 0
1136     install_headers(gl_x11_headers, subdir : 'gstreamer-1.0/gst/gl/x11')
1137     pkg_name = 'gstreamer-gl-x11-1.0'
1138     pkgconfig.generate(
1139       libraries : [gstgl],
1140       requires: ['x11-xcb'],
1141       subdirs : pkgconfig_subdirs,
1142       name : pkg_name,
1143       description : 'Streaming media framework, OpenGL plugins libraries (X11 specifics)',
1144     )
1145     gl_x11_gir = []
1146     if build_gir
1147       gir = {
1148         'sources' : gl_x11_sources + gl_x11_headers,
1149         'namespace' : 'GstGLX11',
1150         'nsversion' : api_version,
1151         'identifier_prefix' : 'Gst',
1152         'symbol_prefix' : 'gst',
1153         'export_packages' : 'gstreamer-gl-x11-1.0',
1154         'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1155         'install' : true,
1156         'extra_args' : gir_init_section + ['--c-include=gst/gl/x11/x11.h'],
1157         'dependencies' : [video_dep, gst_dep, gst_base_dep]
1158       }
1159       gir_dict = gir + {'includes': gir['includes'] + ['GstGL-1.0']}
1160       gst_libraries += [[pkg_name, {'gir': gir_dict}]]
1161       if not static_build
1162         gir += {'includes': gir['includes'] + [gl_gir[0]]}
1163         gl_x11_gir = gnome.generate_gir(gstgl, kwargs: gir)
1164       endif
1165     endif
1166     gstglx11_dep = declare_dependency(dependencies : [gstgl_dep, x11_dep, xcb_dep],
1167       sources : gl_x11_gir)
1168     meson.override_dependency('gstreamer-gl-x11-1.0', gstglx11_dep)
1169   endif
1170
1171   if gl_wayland_headers.length() > 0
1172     install_headers(gl_wayland_headers, subdir : 'gstreamer-1.0/gst/gl/wayland')
1173     pkg_name = 'gstreamer-gl-wayland-1.0'
1174     pkgconfig.generate(
1175       libraries : [gstgl],
1176       requires: ['wayland-egl', 'wayland-client'],
1177       subdirs : pkgconfig_subdirs,
1178       name : pkg_name,
1179       description : 'Streaming media framework, OpenGL plugins libraries (Wayland specifics)',
1180     )
1181     gl_wayland_gir = []
1182     if build_gir
1183       gir = {
1184         'sources' : gl_wayland_sources + gl_wayland_headers,
1185         'namespace' : 'GstGLWayland',
1186         'nsversion' : api_version,
1187         'identifier_prefix' : 'Gst',
1188         'symbol_prefix' : 'gst',
1189         'export_packages' : 'gstreamer-gl-wayland-1.0',
1190         'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1191         'install' : true,
1192         'extra_args' : gir_init_section + ['--c-include=gst/gl/wayland/wayland.h'],
1193         'dependencies' : [video_dep, gst_dep, gst_base_dep]
1194       }
1195
1196       gir_dict = gir + {'includes': gir['includes'] + ['GstGL-1.0']}
1197       gst_libraries += [[pkg_name, {'gir': gir_dict}]]
1198       if not static_build
1199         gir += {'includes': gir['includes'] + [gl_gir[0]]}
1200         gl_wayland_gir = gnome.generate_gir(gstgl, kwargs: gir)
1201       endif
1202     endif
1203     gstglwayland_dep = declare_dependency(dependencies : [gstgl_dep],
1204       sources : gl_wayland_gir)
1205     meson.override_dependency(pkg_name, gstglwayland_dep)
1206   endif
1207
1208   if gl_egl_headers.length() > 0
1209     install_headers(gl_egl_headers, subdir : 'gstreamer-1.0/gst/gl/egl')
1210     pkg_name = 'gstreamer-gl-egl-1.0'
1211     pkgconfig.generate(
1212       libraries : [gstgl, egl_dep],
1213       subdirs : pkgconfig_subdirs,
1214       name : pkg_name,
1215       description : 'Streaming media framework, OpenGL plugins libraries (EGL specifics)',
1216     )
1217     gl_egl_gir = []
1218     if build_gir
1219       gir = {
1220         'sources' : gl_egl_sources + gl_egl_headers,
1221         'namespace' : 'GstGLEGL',
1222         'nsversion' : api_version,
1223         'identifier_prefix' : 'Gst',
1224         'symbol_prefix' : 'gst',
1225         'export_packages' : pkg_name,
1226         'includes' : ['Gst-1.0', 'GstBase-1.0', 'GstVideo-1.0'],
1227         'install' : true,
1228         'extra_args' : gir_init_section + ['--c-include=gst/gl/egl/egl.h'],
1229         'dependencies' : [video_dep, gst_dep, gst_base_dep]
1230       }
1231       gir_dict = gir + {'includes': gir['includes'] + ['GstGL-1.0']}
1232       gst_libraries += [[pkg_name, {'gir': gir_dict}]]
1233       if not static_build
1234         gir += {'includes': gir['includes'] + [gl_gir[0]]}
1235         gl_egl_gir = gnome.generate_gir(gstgl, kwargs: gir)
1236       endif
1237     endif
1238     gstglegl_dep = declare_dependency(dependencies : [gstgl_dep],
1239       sources : gl_egl_gir)
1240     meson.override_dependency(pkg_name, gstglegl_dep)
1241   endif
1242
1243 elif get_option('gl').enabled()
1244   error('GStreamer OpenGL integration required via options, but needed dependencies not found.')
1245 endif