aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan Baker2017-09-13 13:46:13 -0500
committerDylan Baker2018-01-12 11:40:48 -0600
commit5f7deb50787b82038cc35fb1e31b761e33e5a341 (patch)
tree6a9fe255f2c5a8b0ab556118fb0cd3dd9de17634 /meson.build
parentf115de819bc10bb36565f344a66fa619219911b9 (diff)
downloadexternal-libgbm-5f7deb50787b82038cc35fb1e31b761e33e5a341.tar.gz
external-libgbm-5f7deb50787b82038cc35fb1e31b761e33e5a341.tar.xz
external-libgbm-5f7deb50787b82038cc35fb1e31b761e33e5a341.zip
Add meson build system
This patch adds a complete meson build system, including tests and install. It has the necessary hooks to allow it be used as a subproject for other meson based builds such as mesa. Signed-off-by: Dylan Baker <dylan.c.baker@intel.com> Reviewed-and-tested-by: Igor Gnatenko <i.gnatenko.brain@gmail.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build367
1 files changed, 367 insertions, 0 deletions
diff --git a/meson.build b/meson.build
new file mode 100644
index 00000000..05566081
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,367 @@
1# Copyright © 2017-2018 Intel Corporation
2
3# Permission is hereby granted, free of charge, to any person obtaining a copy
4# of this software and associated documentation files (the "Software"), to deal
5# in the Software without restriction, including without limitation the rights
6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7# copies of the Software, and to permit persons to whom the Software is
8# furnished to do so, subject to the following conditions:
9
10# The above copyright notice and this permission notice shall be included in
11# all copies or substantial portions of the Software.
12
13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19# SOFTWARE.
20
21project(
22 'libdrm',
23 ['c'],
24 version : '2.4.89',
25 license : 'MIT',
26 meson_version : '>= 0.42',
27 default_options : ['buildtype=debugoptimized', 'c_std=gnu99'],
28)
29
30pkg = import('pkgconfig')
31
32with_udev = get_option('udev')
33with_freedreno_kgsl = get_option('freedreno-kgsl')
34with_install_tests = get_option('install-test-programs')
35with_cairo_tests = get_option('cairo-tests')
36with_valgrind = get_option('valgrind')
37
38config = configuration_data()
39
40# TODO: openbsd is guess, the others are correct
41if ['freebsd', 'dragonfly', 'netbsd', 'openbsd'].contains(host_machine.system())
42 dep_pthread_stubs = dependency('pthread-stubs', version : '>= 0.4')
43else
44 dep_pthread_stubs = []
45endif
46dep_threads = dependency('threads')
47
48cc = meson.get_compiler('c')
49
50# Check for atomics
51intel_atomics = false
52lib_atomics = false
53
54if cc.compiles('''
55 int atomic_add(int *i) { return __sync_add_and_fetch (i, 1); }
56 int atomic_cmpxchg(int *i, int j, int k) { return __sync_val_compare_and_swap (i, j, k); }
57 ''',
58 name : 'Intel Atomics')
59 intel_atomics = true
60 with_atomics = true
61elif cc.has_header('atomic_ops.h')
62 lib_atomics = true
63 with_atomics = true
64elif cc.has_function('atomic_cas_uint')
65 with_atomics = true
66else
67 with_atomics = false
68endif
69
70config.set10('HAVE_LIBDRM_ATOMIC_PRIMITIVES', intel_atomics)
71config.set10('HAVE_LIB_ATOMIC_OPS', lib_atomics)
72
73with_intel = false
74_intel = get_option('intel')
75if _intel != 'false'
76 if _intel == 'true' and not with_atomics
77 error('libdrm_intel requires atomics.')
78 else
79 with_intel = _intel == 'true' or host_machine.cpu_family().startswith('x86')
80 endif
81endif
82
83with_radeon = false
84_radeon = get_option('radeon')
85if _radeon != 'false'
86 if _radeon == 'true' and not with_atomics
87 error('libdrm_radeon requires atomics.')
88 endif
89 with_radeon = true
90endif
91
92with_amdgpu = false
93_amdgpu = get_option('amdgpu')
94if _amdgpu != 'false'
95 if _amdgpu == 'true' and not with_atomics
96 error('libdrm_amdgpu requires atomics.')
97 endif
98 with_amdgpu = true
99endif
100
101with_nouveau = false
102_nouveau = get_option('nouveau')
103if _nouveau != 'false'
104 if _nouveau == 'true' and not with_atomics
105 error('libdrm_nouveau requires atomics.')
106 endif
107 with_nouveau = true
108endif
109
110with_vmwgfx = false
111_vmwgfx = get_option('vmwgfx')
112if _vmwgfx != 'false'
113 with_vmwgfx = true
114endif
115
116with_omap = false
117_omap = get_option('omap')
118if _omap == 'true'
119 if not with_atomics
120 error('libdrm_omap requires atomics.')
121 endif
122 with_omap = true
123endif
124
125with_freedreno = false
126_freedreno = get_option('freedreno')
127if _freedreno != 'false'
128 if _freedreno == 'true' and not with_atomics
129 error('libdrm_freedreno requires atomics.')
130 else
131 with_freedreno = _freedreno == 'true' or ['arm', 'aarch64'].contains(host_machine.cpu_family())
132 endif
133endif
134
135with_tegra = false
136_tegra = get_option('tegra')
137if _tegra == 'true'
138 if not with_atomics
139 error('libdrm_tegra requires atomics.')
140 endif
141 with_tegra = true
142endif
143
144with_etnaviv = false
145_etnaviv = get_option('etnaviv')
146if _etnaviv == 'true'
147 if not with_atomics
148 error('libdrm_etnaviv requires atomics.')
149 endif
150 with_etnaviv = true
151endif
152
153with_exynos = get_option('exynos') == 'true'
154
155with_vc4 = false
156_vc4 = get_option('vc4')
157if _vc4 != 'false'
158 with_vc4 = _vc4 == 'true' or ['arm', 'aarch64'].contains(host_machine.cpu_family())
159endif
160
161# XXX: Aparently only freebsd and dragonfly bsd actually need this (and
162# gnu/kfreebsd), not openbsd and netbsd
163with_libkms = false
164_libkms = get_option('libkms')
165if _libkms != 'false'
166 with_libkms = _libkms == 'true' or ['linux', 'freebsd', 'dragonfly'].contains(host_machine.system())
167endif
168
169if with_udev
170 dep_udev = dependency('udev')
171 config.set10('UDEV', true)
172else
173 dep_udev = []
174endif
175
176# Among others FreeBSD does not have a separate dl library.
177if not cc.has_function('dlsym')
178 dep_dl = cc.find_library('dl', required : with_nouveau)
179else
180 dep_dl = []
181endif
182# clock_gettime might require -rt, or it might not. find out
183if not cc.has_function('clock_gettime', prefix : '#define _GNU_SOURCE\n#include <time.h>')
184 # XXX: untested
185 dep_rt = cc.find_library('rt')
186else
187 dep_rt = []
188endif
189dep_m = cc.find_library('m', required : false)
190if cc.has_header('sys/sysctl.h')
191 config.set10('HAVE_SYS_SYSCTL_H', true)
192endif
193if cc.has_header('sys/select.h')
194 config.set10('HAVE_SYS_SELECT_H', true)
195endif
196if cc.has_header_symbol('sys/sysmacros.h', 'major')
197 config.set10('MAJOR_IN_SYSMACROS', true)
198elif cc.has_header_symbol('sys/mkdev.h', 'major')
199 config.set10('MAJOR_IN_MKDEV', true)
200endif
201if cc.has_function('open_memstream')
202 config.set10('HAVE_OPEN_MEMSTREAM', true)
203endif
204
205warn_c_args = []
206foreach a : ['-Wall', '-Wextra', '-Wsign-compare',
207 '-Werror-implicit-function-declaration', '-Wpointer-arith',
208 '-Wwrite-strings', '-Wstrict-prototypes', '-Wmissing-prototypes',
209 '-Wmissing-declarations', '-Wnested-externs', '-Wpacked',
210 '-Wswitch-enum', '-Wmissing-format-attribute',
211 '-Wstrict-aliasing=2', '-Winit-self', '-Winline', '-Wshadow',
212 '-Wdeclaration-after-statement', '-Wold-style-definition']
213 if cc.has_argument(a)
214 warn_c_args += a
215 endif
216endforeach
217# GCC will never error for -Wno-*, so check for -W* then add -Wno-* to the list
218# of options
219foreach a : ['unused-parameter', 'attributes', 'long-long',
220 'missing-field-initializers']
221 if cc.has_argument('-W@0@'.format(a))
222 warn_c_args += '-Wno-@0@'.format(a)
223 endif
224endforeach
225
226
227dep_pciaccess = dependency('pciaccess', version : '>= 0.10', required : with_intel)
228dep_cunit = dependency('cunit', version : '>= 2.1', required : false)
229dep_cairo = dependency('cairo', required : with_cairo_tests == 'true')
230dep_valgrind = dependency('valgrind', required : with_valgrind == 'true')
231
232with_man_pages = get_option('man-pages')
233prog_xslt = find_program('xsltproc', required : with_man_pages == 'true')
234prog_sed = find_program('sed', required : with_man_pages == 'true')
235manpage_style = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
236if prog_xslt.found()
237 if run_command(prog_xslt, '--nonet', manpage_style).returncode() != 0
238 if with_man_pages == 'true'
239 error('Manpage style sheet cannot be found')
240 endif
241 with_man_pages = 'false'
242 endif
243endif
244with_man_pages = with_man_pages != 'false' and prog_xslt.found() and prog_sed.found()
245
246# Used for tets
247prog_bash = find_program('bash')
248
249if cc.compiles('''int foo_hidden(void) __attribute__((visibility(("hidden"))));''',
250 name : 'compiler supports __attribute__(("hidden"))')
251 config.set10('HAVE_VISIBILITY', true)
252endif
253
254foreach t : [[with_intel, 'INTEL'], [with_vmwgfx, 'VMWGFX'],
255 [with_nouveau, 'NOUVEAU'], [with_omap, 'OMAP'],
256 [with_exynos, 'EXYNOS'], [with_freedreno, 'FREEDRENO'],
257 [with_tegra, 'TEGRA'], [with_vc4, 'VC4'],
258 [with_etnaviv, 'ETNAVIV']]
259 if t[0]
260 config.set10('HAVE_@0@'.format(t[1]), true)
261 endif
262endforeach
263if with_freedreno_kgsl
264 if not with_freedreno
265 error('cannot enable freedreno-kgsl without freedreno support')
266 endif
267 config.set10('HAVE_FREEDRENO_KGSL', true)
268endif
269if dep_cairo.found()
270 config.set10('HAVE_CAIRO', true)
271endif
272if dep_valgrind.found()
273 config.set10('HAVE_VALGRIND', true)
274endif
275
276config.set10('_GNU_SOURCE', true)
277config_file = configure_file(
278 configuration : config,
279 output : 'config.h',
280)
281add_project_arguments('-DHAVE_CONFIG_H', language : 'c')
282
283inc_root = include_directories('.')
284inc_drm = include_directories('include/drm')
285
286libdrm = shared_library(
287 'drm',
288 [files(
289 'xf86drm.c', 'xf86drmHash.c', 'xf86drmRandom.c', 'xf86drmSL.c',
290 'xf86drmMode.c'
291 ),
292 config_file,
293 ],
294 c_args : warn_c_args,
295 dependencies : [dep_udev, dep_valgrind, dep_rt, dep_m],
296 include_directories : inc_drm,
297 version : '2.4.0',
298 install : true,
299)
300
301ext_libdrm = declare_dependency(
302 link_with : libdrm,
303 include_directories : inc_drm,
304)
305
306install_headers('libsync.h', 'xf86drm.h', 'xf86drmMode.h')
307install_headers(
308 'include/drm/drm.h', 'include/drm/drm_fourcc.h', 'include/drm/drm_mode.h',
309 'include/drm/drm_sarea.h', 'include/drm/i915_drm.h',
310 'include/drm/mach64_drm.h', 'include/drm/mga_drm.h',
311 'include/drm/nouveau_drm.h', 'include/drm/qxl_drm.h',
312 'include/drm/r128_drm.h', 'include/drm/radeon_drm.h',
313 'include/drm/amdgpu_drm.h', 'include/drm/savage_drm.h',
314 'include/drm/sis_drm.h', 'include/drm/tegra_drm.h', 'include/drm/vc4_drm.h',
315 'include/drm/via_drm.h', 'include/drm/virtgpu_drm.h',
316 subdir : 'libdrm',
317)
318if with_vmwgfx
319 install_headers('include/drm/vmwgfx_drm.h', subdir : 'libdrm')
320endif
321
322pkg.generate(
323 name : 'libdrm',
324 libraries : libdrm,
325 subdirs : ['.', 'libdrm'],
326 version : meson.project_version(),
327 description : 'Userspace interface to kernel DRM services',
328)
329
330if with_libkms
331 subdir('libkms')
332endif
333if with_intel
334 subdir('intel')
335endif
336if with_nouveau
337 subdir('nouveau')
338endif
339if with_radeon
340 subdir('radeon')
341endif
342if with_amdgpu
343 subdir('amdgpu')
344endif
345if with_omap
346 subdir('omap')
347endif
348if with_exynos
349 subdir('exynos')
350endif
351if with_freedreno
352 subdir('freedreno')
353endif
354if with_tegra
355 subdir('tegra')
356endif
357if with_vc4
358 subdir('vc4')
359endif
360if with_etnaviv
361 subdir('etnaviv')
362endif
363if with_man_pages
364 subdir('man')
365endif
366subdir('data')
367subdir('tests')