build: meson: libva gst-uninstall friendly
[platform/upstream/gstreamer.git] / meson.build
1 project('gstreamer-vaapi', 'c',
2   version : '1.15.0.1',
3   meson_version : '>= 0.46.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.30.4', '!= 0.99.0']
19 glib_req = '>= 2.40.0'
20 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
21
22 cc = meson.get_compiler('c')
23
24 if cc.has_link_argument('-Wl,-Bsymbolic-functions')
25   add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
26 endif
27
28 # Symbol visibility
29 if cc.has_argument('-fvisibility=hidden')
30   add_project_arguments('-fvisibility=hidden', language: 'c')
31 endif
32
33 # Disable strict aliasing
34 if cc.has_argument('-fno-strict-aliasing')
35   add_project_arguments('-fno-strict-aliasing', language: 'c')
36 endif
37
38 # Mandatory GST deps
39 libm = cc.find_library('m', required : false)
40 gst_dep = dependency('gstreamer-1.0', version : gst_req,
41   fallback : ['gstreamer', 'gst_dep'])
42 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
43   fallback : ['gstreamer', 'gst_base_dep'])
44 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
45     fallback : ['gst-plugins-base', 'pbutils_dep'])
46 gstallocators_dep = dependency('gstreamer-allocators-1.0', version : gst_req,
47     fallback : ['gst-plugins-base', 'allocators_dep'])
48 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
49     fallback : ['gst-plugins-base', 'video_dep'])
50 gstcodecparsers_dep = dependency('gstreamer-codecparsers-1.0', version : gst_req,
51     fallback : ['gst-plugins-bad', 'gstcodecparsers_dep'])
52 gstgl_dep = dependency('gstreamer-gl-1.0', version : gst_req,
53     fallback : ['gst-plugins-base', 'gstgl_dep'], required: false)
54 gmodule_dep = dependency('gmodule-2.0', required: false)
55
56
57 libva_dep = dependency('libva', version: libva_req,
58     fallback : ['libva', 'libva_dep'])
59 libva_drm_dep = dependency('libva-drm', version: '>= 0.33.0',
60     fallback : ['libva', 'libva_drm_dep'], required: false)
61 libva_wayland_dep = dependency('libva-wayland', version: '>= 0.33.0',
62     fallback : ['libva', 'libva_wayland_dep'], required: false)
63 libva_x11_dep = dependency('libva-x11', version: '>= 0.31.0',
64     fallback : ['libva', 'libva_x11_dep'], required: false)
65
66 libdrm_dep = dependency('libdrm', required: false)
67 libudev_dep = dependency('libudev', required: false)
68 egl_dep = dependency('egl', required: false)
69 gl_dep = dependency('gl', required: false)
70 glesv2_dep = dependency('glesv2', required: false)
71 libdl_dep = cc.find_library('dl', required: false)
72 wayland_client_dep = dependency('wayland-client', required: false)
73 x11_dep = dependency('x11', required: false)
74 xrandr_dep = dependency('xrandr', required: false)
75 xrender_dep = dependency('xrender', required: false)
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 = libva_dep.version().version_compare('>= 0.34.0') and get_option('with_encoders') != 'no'
91 USE_H265_DECODER = libva_dep.version().version_compare('>= 0.38.0')
92 USE_H265_ENCODER = USE_ENCODERS and libva_dep.version().version_compare('>= 0.38.0')
93 USE_JPEG_DECODER = libva_dep.version().version_compare('>= 0.34.0')
94 USE_JPEG_ENCODER = USE_ENCODERS and libva_dep.version().version_compare('>= 0.38.0')
95 USE_VP8_DECODER = libva_dep.version().version_compare('>= 0.36.0')
96 USE_VP8_ENCODER = USE_ENCODERS and libva_dep.version().version_compare('>= 0.36.0')
97 USE_VP9_DECODER = libva_dep.version().version_compare('>= 0.39.0')
98 USE_VP9_ENCODER = USE_ENCODERS and libva_dep.version().version_compare('>= 0.40.0')
99
100 USE_VPP = libva_dep.version().version_compare('>= 0.34.0')
101
102 USE_DRM = libva_drm_dep.found() and libdrm_dep.found() and libudev_dep.found() and get_option('with_drm') != 'no'
103 USE_EGL = gmodule_dep.found() and egl_dep.found() and GLES_VERSION_MASK != 0 and get_option('with_egl') != 'no'
104 USE_GLX = libva_x11_dep.found() and x11_dep.found() and gl_dep.found() and libdl_dep.found() and get_option('with_glx') != 'no'
105 USE_WAYLAND = libva_wayland_dep.found() and wayland_client_dep.found() and get_option('with_wayland') != 'no'
106 USE_X11 = libva_x11_dep.found() and x11_dep.found() and get_option('with_x11') != 'no'
107
108 if libva_dep.type_name() == 'pkgconfig'
109   driverdir = libva_dep.get_pkgconfig_variable('driverdir')
110 else
111   libva = subproject('libva')
112   driverdir = libva.get_variable('driverdir')
113 endif
114 if driverdir == ''
115   driverdir = '@0@/@1@/@2@'.format(get_option('prefix'), get_option('libdir'), 'dri')
116 endif
117
118 cdata = configuration_data()
119 cdata.set('GST_API_VERSION_S', '"@0@.@1@"'.format(gst_version_major, gst_version_minor))
120 cdata.set('PACKAGE', '"gstreamer-vaapi"')
121 cdata.set('VERSION', '"@0@"'.format(gst_version))
122 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
123 cdata.set('PACKAGE_NAME', '"GStreamer VA-API Plug-ins"')
124 cdata.set('PACKAGE_STRING', '"GStreamer VA-API Plug-ins @0@"'.format(gst_version))
125 cdata.set('PACKAGE_BUGREPORT', '"http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer"')
126 cdata.set('VA_DRIVERS_PATH', '"@0@"'.format(driverdir))
127 cdata.set10('USE_DRM', USE_DRM)
128 cdata.set10('USE_EGL', USE_EGL)
129 cdata.set10('USE_ENCODERS', USE_ENCODERS)
130 cdata.set10('USE_GLX', USE_GLX)
131 cdata.set10('USE_H265_DECODER', USE_H265_DECODER)
132 cdata.set10('USE_H265_ENCODER', USE_H265_ENCODER)
133 cdata.set10('USE_JPEG_DECODER', USE_JPEG_DECODER)
134 cdata.set10('USE_JPEG_ENCODER', USE_JPEG_ENCODER)
135 cdata.set10('USE_VP8_DECODER', USE_VP8_DECODER)
136 cdata.set10('USE_VP8_ENCODER', USE_VP8_ENCODER)
137 cdata.set10('USE_VP9_DECODER', USE_VP9_DECODER)
138 cdata.set10('USE_VP9_ENCODER', USE_VP9_ENCODER)
139 cdata.set10('USE_WAYLAND', USE_WAYLAND)
140 cdata.set10('USE_X11', USE_X11)
141 cdata.set10('HAVE_XKBLIB', cc.has_header('X11/XKBlib.h', dependencies: x11_dep))
142 cdata.set10('HAVE_XRANDR', xrandr_dep.found())
143 cdata.set10('HAVE_XRENDER', xrender_dep.found())
144 cdata.set10('USE_VA_VPP', USE_VPP)
145 cdata.set10('USE_GST_GL_HELPERS', gstgl_dep.found())
146 cdata.set('USE_GLES_VERSION_MASK', GLES_VERSION_MASK)
147
148 if libva_dep.version().version_compare('< 0.38.0')
149   check_headers = [
150     [USE_H265_DECODER, 'HAVE_VA_VA_DEC_HEVC_H'],
151     [USE_H265_ENCODER, 'HAVE_VA_VA_ENC_HEVC_H'],
152     [USE_JPEG_DECODER, 'HAVE_VA_VA_DEC_JPEG_H'],
153     [USE_JPEG_ENCODER, 'HAVE_VA_VA_ENC_JPEG_H'],
154     [USE_VP8_DECODER, 'HAVE_VA_VA_DEC_VP8_H'],
155     [USE_VP8_ENCODER, 'HAVE_VA_VA_ENC_VP8_H'],
156     [USE_VP9_DECODER, 'HAVE_VA_VA_DEC_VP9_H'],
157     [USE_VP9_ENCODER, 'HAVE_VA_VA_DEC_VP9_H'],
158     [USE_VPP, 'HAVE_VA_VA_VPP_H'],
159   ]
160   foreach h : check_headers
161     if h.get(0)
162       cdata.set(h.get(1), 1)
163     endif
164   endforeach
165
166   if USE_ENCODERS
167     check_headers = [
168       'HAVE_VA_VA_ENC_MPEG2_H',
169       'HAVE_VA_VA_ENC_H264_H',
170     ]
171     foreach h : check_headers
172       cdata.set(h, 1)
173     endforeach
174   endif
175 endif
176
177 api_version = '1.0'
178 soversion = 0
179 # maintaining compatibility with the previous libtool versioning
180 # current = minor * 100 + micro
181 libversion = '@0@.@1@.0'.format(soversion, gst_version_minor * 100 + gst_version_micro)
182
183 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
184
185 configure_file(configuration: cdata, output: 'config.h')
186 gstreamer_vaapi_args = ['-DHAVE_CONFIG_H']
187 configinc = include_directories('.')
188 libsinc = include_directories('gst-libs')
189
190 subdir('gst-libs')
191 subdir('gst')
192 #subdir('tests')
193
194 python3 = import('python3').find_python()
195 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')