1project('xf86-video-intel', 'c',
2	version : '2.99.917',
3	default_options: [
4	  'warning_level=2',
5	  'c_std=gnu99',
6	],
7	license : 'MIT',
8	meson_version : '>0.40.0')
9
10config = configuration_data()
11
12version = meson.project_version().split('.')
13config.set('PACKAGE_VERSION_MAJOR', version[0])
14config.set('PACKAGE_VERSION_MINOR', version[1])
15config.set('PACKAGE_VERSION_PATCHLEVEL', version[2])
16
17config.set_quoted('LIBEXEC_PATH', join_paths(get_option('prefix'),
18					     get_option('libexecdir')))
19
20cc = meson.get_compiler('c')
21
22xorg = dependency('xorg-server', version : '>= 1.6', required : true)
23pthreads = dependency('threads', required : true)
24pciaccess = dependency('pciaccess', version : '>= 0.10', required : true)
25
26x11 = dependency('x11', required : false)
27xfixes = dependency('xfixes', required : false)
28png = dependency('libpng', required : false)
29
30if not cc.has_function('clock_gettime', args : '-lrt')
31  error('clock_gettime() missing')
32endif
33
34if cc.has_function('getline')
35  config.set('HAVE_GETLINE', 1)
36endif
37
38if cc.has_function('strndup')
39  config.set('HAVE_STRNDUP', 1)
40endif
41
42if cc.has_function('strcasecmp')
43  config.set('HAVE_STRCASECMP', 1)
44endif
45
46dependency('xproto', required : true)
47dependency('fontsproto', required : true)
48dependency('damageproto', required : true)
49
50if cc.has_header_symbol('xorg-server.h', 'RANDR',
51			dependencies : xorg)
52  dependency('randrproto', required : true)
53endif
54if cc.has_header_symbol('xorg-server.h', 'RENDER',
55			dependencies : xorg)
56  dependency('renderproto', required : true)
57endif
58if cc.has_header_symbol('xorg-server.h', 'DPMSExtension',
59			dependencies : xorg)
60  dependency('xextproto', required : true)
61endif
62
63with_tools = get_option('tools')
64
65config.set('USE_GIT_DESCRIBE', 1)
66config.set('BUILDER_DESCRIPTION', 1)
67
68atomic_primitives = 'none'
69
70atomic_primitives_code = '''
71int atomic_add(int i) {
72    return __sync_fetch_and_add (&i, 1);
73}
74int atomic_cmpxchg(int i, int j, int k) {
75    return __sync_val_compare_and_swap (&i, j, k);
76}
77int main(void) {
78    return 0;
79}'''
80if cc.links(atomic_primitives_code, name : 'atomic primitives')
81  atomic_primitives = 'intel'
82  config.set('HAVE_ATOMIC_PRIMITIVES', 1)
83endif
84
85if atomic_primitives == 'none' and cc.has_header('atomic_ops.h')
86  atomic_primitives = 'libatomic-ops'
87  config.set('HAVE_LIB_ATOMIC_OPS', 1)
88endif
89
90if atomic_primitives == 'none'
91  error('xf86-video-intel depends upon atomic operations, which were not found for your compiler/cpu. Try compiling with -march=native, or install the libatomics-op-dev package.')
92endif
93
94libudev = dependency('libudev', required : false)
95if libudev.found()
96  config.set('HAVE_UDEV', 1)
97endif
98
99cpuid_code = '''
100#include <cpuid.h>
101#include <stddef.h>
102int main(void) {
103    int eax, ebx, ecx, edx;
104    if (__get_cpuid_max(0, NULL) < 4)
105       return 0;
106    __cpuid_count(4, 0, eax, ebx, ecx, edx);
107    return 0;
108}'''
109if cc.links(cpuid_code, name : '__cpuid()')
110  config.set('HAVE_CPUID_H', 1)
111endif
112
113has_shm = (cc.has_header('sys/ipc.h') and
114	   cc.has_header('X11/extensions/XShm.h') and
115	   cc.has_header('X11/extensions/shmproto.h') and
116	   cc.has_header('X11/extensions/shmstr.h'))
117if has_shm
118  config.set('HAVE_MIT_SHM', 1)
119  config.set('HAVE_X11_EXTENSIONS_SHMPROTO_H', 1)
120  config.set('HAVE_X11_EXTENSIONS_SHMSTR_H', 1)
121endif
122
123if cc.has_header('X11/extensions/Xinerama.h')
124  config.set('HAVE_X11_EXTENSIONS_XINERAMA_H', 1)
125endif
126
127if cc.has_header('X11/extensions/dpmsconst.h')
128  config.set('HAVE_X11_EXTENSIONS_DPMSCONST_H', 1)
129endif
130
131pixman = dependency('pixman-1', version : '>= 0.16.0', required : true)
132
133if pixman.version() >= '0.24.0'
134  config.set('HAS_PIXMAN_TRIANGLES', 1)
135endif
136if pixman.version() >= '0.27.1'
137  config.set('HAS_PIXMAN_GLYPHS', 1)
138endif
139
140with_kms = get_option('kms')
141if with_kms
142  config.set('KMS', 1)
143endif
144
145with_ums = get_option('ums')
146if with_ums
147  has_ums = cc.has_header('vgaHW.h',
148			  dependencies : xorg)
149
150  # Currently 'required' doesn't work for cc.has_header() & co.
151  if not has_ums
152    error('UMS dependencies not met')
153  endif
154
155  config.set('UMS', 1)
156endif
157
158with_xvmc = get_option('xvmc')
159if with_xvmc
160  dependency('xvmc', required : true)
161  dependency('dri2proto', required : true)
162  dependency('x11', required : true)
163  dependency('x11-xcb', required : true)
164  dependency('xcb-dri2', required : true)
165  dependency('xcb-aux', required : true)
166  dependency('libdrm_intel', required : true)
167
168  config.set('ENABLE_XVMC', 1)
169endif
170
171with_valgrind = get_option('valgrind')
172if with_valgrind
173  message('Checking Valgrind support')
174  valgrind = dependency('valgrind', required : true)
175  config.set('HAVE_VALGRIND', 1)
176endif
177
178inc = include_directories([ '.', 'src', 'xvmc', 'src/render_program', ])
179
180add_project_arguments('-include', 'config.h', language : 'c')
181
182man_config = configuration_data()
183man_config.set('appmansuffix', '1')
184man_config.set('filemansuffix', '5')
185man_config.set('drivermansuffix', '4')
186man_config.set('miscmansuffix', '7')
187man_config.set('xservername',
188	       cc.get_define('__XSERVERNAME__',
189			     prefix : '#include <xorg-server.h>',
190			     dependencies : xorg))
191man_config.set('xconfigfile',
192	       cc.get_define('__XCONFIGFILE____',
193			     prefix : '#include <xorg-server.h>',
194			     dependencies : xorg))
195man_config.set('vendorversion', '"@0@ @1@" "@2@"'.format(meson.project_name(),
196							 meson.project_version(),
197							 'X Version 11'))
198
199subdir('src')
200subdir('tools')
201
202if with_xvmc
203  subdir('xvmc')
204endif
205
206subdir('man')
207
208configure_file(output: 'config.h', install: false, configuration: config)
209