meson: use new 'python' module instead of deprecated 'python3' one
[platform/upstream/gstreamer.git] / meson.build
1 project('gstreamer-vaapi', 'c',
2   version : '1.15.2.1',
3   meson_version : '>= 0.47.0',
4   default_options : [ 'warning_level=1',
5                       'buildtype=debugoptimized' ])
6
7 gst_version = meson.project_version()
8 version_arr = gst_version.split('.')
9 gst_version_major = version_arr[0].to_int()
10 gst_version_minor = version_arr[1].to_int()
11 gst_version_micro = version_arr[2].to_int()
12  if version_arr.length() == 4
13   gst_version_nano = version_arr[3].to_int()
14 else
15   gst_version_nano = 0
16 endif
17
18 libva_req = ['>= 0.39.0', '!= 0.99.0']
19 glib_req = '>= 2.40.0'
20 libwayland_req = '>= 1.11.0'
21 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
22
23 cc = meson.get_compiler('c')
24
25 if cc.has_link_argument('-Wl,-Bsymbolic-functions')
26   add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
27 endif
28
29 # Symbol visibility
30 if cc.has_argument('-fvisibility=hidden')
31   add_project_arguments('-fvisibility=hidden', language: 'c')
32 endif
33
34 # Disable strict aliasing
35 if cc.has_argument('-fno-strict-aliasing')
36   add_project_arguments('-fno-strict-aliasing', language: 'c')
37 endif
38
39 # Mandatory GST deps
40 libm = cc.find_library('m', required : false)
41 gst_dep = dependency('gstreamer-1.0', version : gst_req,
42   fallback : ['gstreamer', 'gst_dep'])
43 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
44   fallback : ['gstreamer', 'gst_base_dep'])
45 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
46     fallback : ['gst-plugins-base', 'pbutils_dep'])
47 gstallocators_dep = dependency('gstreamer-allocators-1.0', version : gst_req,
48     fallback : ['gst-plugins-base', 'allocators_dep'])
49 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
50     fallback : ['gst-plugins-base', 'video_dep'])
51 gstcodecparsers_dep = dependency('gstreamer-codecparsers-1.0', version : gst_req,
52     fallback : ['gst-plugins-bad', 'gstcodecparsers_dep'])
53 gstgl_dep = dependency('gstreamer-gl-1.0', version : gst_req,
54     fallback : ['gst-plugins-base', 'gstgl_dep'], required: false)
55 gmodule_dep = dependency('gmodule-2.0', required: false)
56 libva_dep = dependency('libva', version: libva_req)
57
58 libva_drm_dep = dependency('libva-drm', version: libva_req, required: false)
59 libva_wayland_dep = dependency('libva-wayland', version: libva_req, required: false)
60 libva_x11_dep = dependency('libva-x11', version: libva_req, required: false)
61 libdrm_dep = dependency('libdrm', required: false)
62 libudev_dep = dependency('libudev', required: false)
63 egl_dep = dependency('egl', required: false)
64 gl_dep = dependency('gl', required: false)
65 glesv2_dep = dependency('glesv2', required: false)
66 libdl_dep = cc.find_library('dl', required: false)
67 wayland_client_dep = dependency('wayland-client', version: libwayland_req, required: false)
68 wayland_protocols_dep = dependency('wayland-protocols', version: '>= 1.15', required: false)
69 wayland_scanner_bin = find_program('wayland-scanner', required: false)
70 x11_dep = dependency('x11', required: false)
71 xrandr_dep = dependency('xrandr', required: false)
72 xrender_dep = dependency('xrender', required: false)
73
74 # some of the examples can use GTK+-3
75 gtk_dep = dependency('gtk+-3.0', version : '>= 3.10', required : get_option('examples'))
76
77 GLES_VERSION_MASK = gl_dep.found() ? 1 : 0
78 if glesv2_dep.found()
79   if (cc.has_header('GLES2/gl2.h', dependencies: glesv2_dep) and
80       cc.has_header('GLES2/gl2ext.h', dependencies: glesv2_dep))
81     GLES_VERSION_MASK += 4
82   endif
83   if (cc.has_header('GLES3/gl3.h', dependencies: glesv2_dep) and
84       cc.has_header('GLES3/gl3ext.h', dependencies: glesv2_dep) and
85       cc.has_header('GLES2/gl2ext.h', dependencies: glesv2_dep))
86     GLES_VERSION_MASK += 8
87   endif
88 endif
89
90 USE_ENCODERS = get_option('with_encoders') != 'no'
91 USE_VP9_ENCODER = USE_ENCODERS and cc.has_header('va/va_enc_vp9.h', dependencies: libva_dep, prefix: '#include <va/va.h>')
92 USE_H264_FEI_ENCODER = USE_ENCODERS and cc.has_header('va/va_fei_h264.h', dependencies: libva_dep, prefix: '#include <va/va.h>')
93
94 USE_DRM = libva_drm_dep.found() and libdrm_dep.found() and libudev_dep.found() and get_option('with_drm') != 'no'
95 USE_EGL = gmodule_dep.found() and egl_dep.found() and GLES_VERSION_MASK != 0 and get_option('with_egl') != 'no'
96 USE_GLX = libva_x11_dep.found() and x11_dep.found() and gl_dep.found() and libdl_dep.found() and get_option('with_glx') != 'no'
97 USE_WAYLAND = libva_wayland_dep.found() and wayland_client_dep.found() and wayland_protocols_dep.found() and wayland_scanner_bin.found() and get_option('with_wayland') != 'no'
98 USE_X11 = libva_x11_dep.found() and x11_dep.found() and get_option('with_x11') != 'no'
99
100 driverdir = libva_dep.get_pkgconfig_variable('driverdir')
101 if driverdir == ''
102   driverdir = '@0@/@1@/@2@'.format(get_option('prefix'), get_option('libdir'), 'dri')
103 endif
104
105 cdata = configuration_data()
106 cdata.set('GST_API_VERSION_S', '"@0@.@1@"'.format(gst_version_major, gst_version_minor))
107 cdata.set('PACKAGE', '"gstreamer-vaapi"')
108 cdata.set('VERSION', '"@0@"'.format(gst_version))
109 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
110 cdata.set('PACKAGE_NAME', '"GStreamer VA-API Plug-ins"')
111 cdata.set('PACKAGE_STRING', '"GStreamer VA-API Plug-ins @0@"'.format(gst_version))
112 cdata.set('PACKAGE_BUGREPORT', '"http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer"')
113 cdata.set('VA_DRIVERS_PATH', '"@0@"'.format(driverdir))
114 cdata.set10('USE_DRM', USE_DRM)
115 cdata.set10('USE_EGL', USE_EGL)
116 cdata.set10('USE_ENCODERS', USE_ENCODERS)
117 cdata.set10('USE_GLX', USE_GLX)
118 cdata.set10('USE_VP9_ENCODER', USE_VP9_ENCODER)
119 cdata.set10('USE_H264_FEI_ENCODER', USE_H264_FEI_ENCODER)
120 cdata.set10('USE_WAYLAND', USE_WAYLAND)
121 cdata.set10('USE_X11', USE_X11)
122 cdata.set10('HAVE_XKBLIB', cc.has_header('X11/XKBlib.h', dependencies: x11_dep))
123 cdata.set10('HAVE_XRANDR', xrandr_dep.found())
124 cdata.set10('HAVE_XRENDER', xrender_dep.found())
125 cdata.set10('USE_GST_GL_HELPERS', gstgl_dep.found())
126 cdata.set('USE_GLES_VERSION_MASK', GLES_VERSION_MASK)
127
128 api_version = '1.0'
129 soversion = 0
130 # maintaining compatibility with the previous libtool versioning
131 # current = minor * 100 + micro
132 curversion = gst_version_minor * 100 + gst_version_micro
133 libversion = '@0@.@1@.0'.format(soversion, curversion)
134 osxversion = curversion + 1
135
136 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
137
138 configure_file(configuration: cdata, output: 'config.h')
139 gstreamer_vaapi_args = ['-DHAVE_CONFIG_H']
140 configinc = include_directories('.')
141 libsinc = include_directories('gst-libs')
142
143 subdir('gst-libs')
144 subdir('gst')
145 if not get_option('examples').disabled()
146   subdir('tests')
147 endif
148
149 python3 = import('python').find_installation()
150 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')