xwayland: install pkgconfig to sharedir
[xserver.git] / meson.build
blob94dea6970a8cd5dcae02682539186f04c9a61c8f
1 project('xserver', 'c',
2         default_options: [
3             'buildtype=debugoptimized',
4             'c_std=gnu99',
5         ],
6         version: '21.1.99.1',
7         meson_version: '>= 0.56.0',
9 release_date = '2021-07-05'
11 add_project_arguments('-DHAVE_DIX_CONFIG_H', language: ['c', 'objc'])
12 cc = meson.get_compiler('c')
14 add_project_arguments('-fno-strict-aliasing', language : 'c')
15 add_project_arguments('-fvisibility=hidden', language : 'c')
17 add_project_link_arguments('-fvisibility=hidden', language : 'c')
19 if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
20     test_wflags = [
21         '-Wall',
22         '-Wpointer-arith',
23         '-Wmissing-declarations',
24         '-Wformat=2',
25         '-Wstrict-prototypes',
26         '-Wmissing-prototypes',
27         '-Wnested-externs',
28         '-Wbad-function-cast',
29         '-Wold-style-definition',
30         '-Wunused',
31         '-Wuninitialized',
32         '-Wshadow',
33         '-Wmissing-noreturn',
34         '-Wmissing-format-attribute',
35         '-Wredundant-decls',
36         '-Werror=implicit',
37         '-Werror=nonnull',
38         '-Werror=init-self',
39         '-Werror=main',
40         '-Werror=missing-braces',
41         '-Werror=sequence-point',
42         '-Werror=return-type',
43         '-Werror=trigraphs',
44         '-Werror=array-bounds',
45         '-Werror=write-strings',
46         '-Werror=address',
47         '-Werror=int-to-pointer-cast',
48         '-Werror=pointer-to-int-cast',
49     ]
50 else
51     test_wflags = []
52 endif
54 common_wflags = []
55 foreach wflag: test_wflags
56     if cc.has_argument(wflag)
57         common_wflags += [ wflag ]
58     endif
59 endforeach
61 add_project_arguments(common_wflags, language : ['c', 'objc'])
63 libdrm_req = '>= 2.4.116'
64 libselinux_req = '>= 2.0.86'
65 xext_req = '>= 1.0.99.4'
66 wayland_req = '>= 1.21.0'
67 wayland_protocols_req = '>= 1.34'
68 gbm_req = '>= 10.2'
69 xf86dgaproto_req = '>= 2.0.99.1'
70 xshmfence_req = '>= 1.1'
72 x11_dep = dependency('x11')
73 xproto_dep = dependency('xproto', version: '>= 7.0.31', fallback: ['xorgproto', 'ext_xorgproto'])
74 randrproto_dep = dependency('randrproto', version: '>= 1.6.0', fallback: ['xorgproto', 'ext_xorgproto'])
75 renderproto_dep = dependency('renderproto', version: '>= 0.11', fallback: ['xorgproto', 'ext_xorgproto'])
76 xextproto_dep = dependency('xextproto', version: '>= 7.2.99.901', fallback: ['xorgproto', 'ext_xorgproto'])
77 inputproto_dep = dependency('inputproto', version: '>= 2.3.99.1', fallback: ['xorgproto', 'ext_xorgproto'])
78 kbproto_dep = dependency('kbproto', version: '>= 1.0.3', fallback: ['xorgproto', 'ext_xorgproto'])
79 fontsproto_dep = dependency('fontsproto', version: '>= 2.1.3', fallback: ['xorgproto', 'ext_xorgproto'])
80 fixesproto_dep = dependency('fixesproto', version: '>= 6.0', fallback: ['xorgproto', 'ext_xorgproto'])
81 damageproto_dep = dependency('damageproto', version: '>= 1.1', fallback: ['xorgproto', 'ext_xorgproto'])
82 xcmiscproto_dep = dependency('xcmiscproto', version: '>= 1.2.0', fallback: ['xorgproto', 'ext_xorgproto'])
83 bigreqsproto_dep = dependency('bigreqsproto', version: '>= 1.1.0', fallback: ['xorgproto', 'ext_xorgproto'])
84 presentproto_dep = dependency('presentproto', version: '>= 1.4', fallback: ['xorgproto', 'ext_xorgproto'])
85 xtrans_dep = dependency('xtrans', version: '>= 1.3.5')
87 videoproto_dep = dependency('videoproto', fallback: ['xorgproto', 'ext_xorgproto'])
88 compositeproto_dep = dependency('compositeproto', version: '>= 0.4', fallback: ['xorgproto', 'ext_xorgproto'])
89 recordproto_dep = dependency('recordproto', version: '>= 1.13.99.1', fallback: ['xorgproto', 'ext_xorgproto'])
90 scrnsaverproto_dep = dependency('scrnsaverproto', version: '>= 1.1', fallback: ['xorgproto', 'ext_xorgproto'])
91 resourceproto_dep = dependency('resourceproto', version: '>= 1.2.0', fallback: ['xorgproto', 'ext_xorgproto'])
92 xf86driproto_dep = dependency('xf86driproto', version: '>= 2.1.0', fallback: ['xorgproto', 'ext_xorgproto'], required: get_option('dri1') == 'true')
93 dri2proto_dep = dependency('dri2proto', version: '>= 2.8', fallback: ['xorgproto', 'ext_xorgproto'], required: get_option('dri2') == 'true')
94 dri3proto_dep = dependency('dri3proto', version: '>= 1.4', fallback: ['xorgproto', 'ext_xorgproto'], required: get_option('dri3') == 'true')
95 xineramaproto_dep = dependency('xineramaproto', fallback: ['xorgproto', 'ext_xorgproto'])
96 xf86bigfontproto_dep = dependency('xf86bigfontproto', version: '>= 1.2.0', fallback: ['xorgproto', 'ext_xorgproto'], required: get_option('xf86bigfont'))
97 xf86vidmodeproto_dep = dependency('xf86vidmodeproto', version: '>= 2.2.99.1', fallback: ['xorgproto', 'ext_xorgproto'])
98 applewmproto_dep = dependency('applewmproto', version: '>= 1.4', fallback: ['xorgproto', 'ext_xorgproto'], required: false)
99 xshmfence_dep = dependency('xshmfence', version: xshmfence_req, required: false)
100 xwaylandproto_dep = dependency('xwaylandproto', version: '>= 1.0', fallback: ['xorgproto', 'ext_xorgproto'], required: false)
101 dpmsproto_dep = dependency('dpmsproto', version: '>= 1.2', required: get_option('dpms'))
103 pixman_dep = dependency('pixman-1')
104 libbsd_dep = dependency('libbsd-overlay', required: false)
105 xkbcomp_dep = dependency('xkbcomp', required: false)
106 xkbfile_dep = dependency('xkbfile')
107 xfont2_dep = dependency('xfont2', version: '>= 2.0')
109 dbus_required = get_option('systemd_logind') == 'true'
110 dbus_dep = dependency('dbus-1', version: '>= 1.0', required: dbus_required)
112 build_systemd = get_option('systemd_notify') == 'true'
113 # libsystemd-daemon was moved into libsystemd in version 209
114 libsystemd_daemon_dep = dependency('libsystemd', version: '>= 209', required: false)
115 if not libsystemd_daemon_dep.found()
116     libsystemd_daemon_dep = dependency('libsystemd-daemon', required: false)
117 endif
119 build_hashtable = false
121 # Resolve default values of some options
122 xkb_dir = get_option('xkb_dir')
123 if xkb_dir == ''
124     if xkbcomp_dep.found() and xkbcomp_dep.type_name() == 'pkgconfig'
125         xkb_dir = xkbcomp_dep.get_variable(pkgconfig : 'xkbconfigdir')
126     endif
127     if xkb_dir == ''
128         xkb_dir = join_paths(get_option('prefix'), 'share/X11/xkb')
129     endif
130 endif
132 xkb_output_dir = get_option('xkb_output_dir')
133 if xkb_output_dir == ''
134     xkb_output_dir = join_paths(xkb_dir, 'compiled')
135 endif
137 xkb_bin_dir = get_option('xkb_bin_dir')
138 if xkb_bin_dir == ''
139     if xkbcomp_dep.found() and xkbcomp_dep.type_name() == 'pkgconfig'
140         xkb_bin_dir = xkbcomp_dep.get_variable(pkgconfig : 'bindir')
141     endif
142     if xkb_bin_dir == ''
143         xkb_bin_dir = join_paths(get_option('prefix'), get_option('bindir'))
144     endif
145 endif
147 dfp = get_option('default_font_path')
148 if dfp == ''
149     fontrootdir = get_option('fontrootdir')
150     if fontrootdir == ''
151         fontutil_dep = dependency('fontutil', required: false)
152         if fontutil_dep.found()
153             fontrootdir = fontutil_dep.get_variable(pkgconfig : 'fontrootdir')
154         else
155             fontrootdir = join_paths(get_option('prefix'), get_option('datadir'), 'fonts', 'X11')
156         endif
157     endif
158     dfp_elements = [
159         join_paths(fontrootdir, 'misc'),
160         join_paths(fontrootdir, 'TTF'),
161         join_paths(fontrootdir, 'OTF'),
162         join_paths(fontrootdir, 'Type1'),
163         join_paths(fontrootdir, '100dpi'),
164         join_paths(fontrootdir, '75dpi'),
165     ]
166     if host_machine.system() == 'darwin'
167        dfp_elements += [
168        '/Library/Fonts',
169        '/System/Library/Fonts',
170     ]
171     endif
172     default_font_path = ','.join(dfp_elements)
173 else
174     default_font_path = dfp
175 endif
177 hal_option = get_option('hal')
178 glamor_option = get_option('glamor')
180 build_udev = get_option('udev')
181 build_udev_kms = get_option('udev_kms')
182 if ['windows',  'darwin', 'cygwin'].contains(host_machine.system())
183     build_udev = false
184     build_udev_kms = false
185     hal_option = 'false'
186 endif
188 if get_option('systemd_logind') == 'auto'
189     build_systemd_logind = build_udev_kms and dbus_dep.found()
190 else
191     build_systemd_logind = get_option('systemd_logind') == 'true'
192 endif
194 with_dtrace = get_option('dtrace')
195 if with_dtrace
196     dtrace = find_program('dtrace', required: true)
197 endif
199 build_xorg = false
200 if (host_machine.system() != 'windows')
201     if get_option('xorg') == 'auto'
202         build_xorg = (host_machine.system() != 'darwin' and
203                       host_machine.system() != 'windows')
204     else
205         build_xorg = get_option('xorg') == 'true'
206     endif
207 endif
208 xorgsdkdir = join_paths(get_option('prefix'), get_option('includedir'), 'xorg')
209 libxcvt_dep = dependency('libxcvt', fallback: ['libxcvt', 'libxcvt_dep'], required: build_xorg)
211 build_xwayland = false
212 if (host_machine.system() != 'darwin' and
213     host_machine.system() != 'windows' and
214     get_option('xwayland') != 'false')
215     xwayland_required = get_option('xwayland') == 'true'
216     build_glamor = glamor_option == 'true' or glamor_option == 'auto'
218     xwayland_path = get_option('xwayland-path')
219     if (xwayland_path == '')
220         xwayland_path = join_paths(get_option('prefix'), get_option('bindir'))
221     endif
223     xwayland_dep = [
224         dependency('wayland-client', version: wayland_req, required: xwayland_required),
225         dependency('wayland-protocols', version: wayland_protocols_req, required: xwayland_required),
226         dependency('libxcvt', fallback: ['libxcvt', 'libxcvt_dep'], required: xwayland_required),
227     ]
229     if build_glamor
230         xwayland_dep += dependency('xshmfence', version: xshmfence_req, required: xwayland_required)
231         xwayland_dep += dependency('libdrm', version: libdrm_req, required: xwayland_required)
232         xwayland_dep += dependency('epoxy', required: xwayland_required)
233     endif
235     build_xwayland = true
236     # check for all the deps being found, to handle 'auto' mode.
237     foreach d: xwayland_dep
238         if not d.found()
239             build_xwayland = false
240         endif
241     endforeach
242 endif
244 build_xnest = false
245 if (host_machine.system() != 'windows')
246     if get_option('xnest') != 'false'
247         xnest_required = get_option('xnest') == 'true'
249         xnest_dep = [
250             dependency('xext', version: xext_req, required: xnest_required),
251             dependency('x11', required: xnest_required),
252             dependency('xau', required: xnest_required),
253         ]
255         build_xnest = true
256         # check for all the deps being found, to handle 'auto' mode.
257         foreach d: xnest_dep
258             if not d.found()
259                 build_xnest = false
260             endif
261         endforeach
262     endif
263 endif
265 build_xwin = false
266 if get_option('xwin') == 'auto'
267     if (host_machine.system() == 'cygwin' or
268         host_machine.system() == 'windows')
269             build_xwin = true
270     endif
271 else
272     build_xwin = get_option('xwin') == 'true'
273 endif
275 build_xquartz = false
276 if get_option('xquartz') == 'auto'
277     if host_machine.system() == 'darwin'
278             build_xquartz = true
279     endif
280 else
281     build_xquartz = get_option('xquartz') == 'true'
282 endif
284 build_rootless = false
285 if build_xquartz
286     build_rootless = true
287 endif
289 if get_option('ipv6') == 'auto'
290     build_ipv6 = cc.has_function('getaddrinfo')
291 else
292     build_ipv6 = get_option('ipv6') == 'true'
293 endif
295 int10 = get_option('int10')
296 if int10 == 'auto'
297     int10 = 'x86emu'
298     if host_machine.cpu() == 'ppc' and host_machine.system() == 'freebsd'
299         int10 = 'stub'
300     endif
301     if host_machine.cpu() == 'arm'
302         int10 = 'stub'
303     endif
304 endif
306 hal_dep = []
307 if hal_option == 'auto'
308     if not build_udev
309         hal_dep = dependency('hal', required: false)
310         build_hal = hal_dep.found()
311     else
312         build_hal = false
313     endif
314 else
315     build_hal = hal_option == 'true'
316     if build_hal
317         hal_dep = dependency('hal')
318     endif
319 endif
321 if build_udev and build_hal
322     error('Hotplugging through both libudev and hal not allowed')
323 endif
325 build_dbus = build_hal or build_systemd_logind
327 udev_dep = dependency('', required:false)
328 if build_udev or build_udev_kms
329     udev_dep = dependency('libudev', version: '>= 143')
330 endif
332 log_dir = get_option('log_dir')
333 if log_dir == ''
334     log_dir = join_paths(get_option('prefix'), get_option('localstatedir'), 'log')
335 endif
337 module_dir = join_paths(get_option('libdir'), get_option('module_dir'))
339 if glamor_option == 'auto'
340     build_glamor = build_xorg or build_xwayland
341 else
342     build_glamor = glamor_option == 'true'
343 endif
345 gbm_dep = dependency('', required: false)
346 epoxy_dep = dependency('', required: false)
347 if build_glamor
348     gbm_dep = dependency('gbm', version: gbm_req, required: false)
349     epoxy_dep = dependency('epoxy', required: false)
350 endif
352 if build_xwayland
353     libdecor_dep = dependency('libdecor-0', required: false)
354     libdecor_option = get_option('libdecor')
355     if libdecor_option == 'auto'
356         have_libdecor = libdecor_dep.found()
357     else
358         have_libdecor = libdecor_option == 'true'
359         if have_libdecor and not libdecor_dep.found()
360             error('libdecor support requested but not found')
361         endif
362     endif
363 else
364     have_libdecor = false
365 endif
367 if build_xwayland
368     libei_dep = dependency('libei-1.0', version: '>= 1.0.0', required: get_option('xwayland_ei') in ['portal', 'socket'])
369     liboeffis_dep = dependency('liboeffis-1.0', version: '>= 1.0.0', required: get_option('xwayland_ei') == 'portal')
371     build_ei = libei_dep.found() and get_option('xwayland_ei') != 'false'
372     build_ei_portal = liboeffis_dep.found() and get_option('xwayland_ei') in ['portal', 'auto']
373 else
374     build_ei = false
375     build_ei_portal = false
376 endif
378 # Lots of sha1 options, because Linux is about choice :)
380 # The idea behind the ordering here is that we should first prefer system
381 # builtin providers, and then smaller implementations of over larger ones.
382 test_sha1 = [
383     'libc',          # libmd API is in libc on some BSDs
384     'CommonCrypto',  # darwin API
385     'CryptoAPI',     # windows API
386     'libmd',         # other BSDs & Solaris
387     'libsha1',       # "a tiny library providing a SHA1 implementation, created for facilitating X server compilation on embedded devices where larger libraries containing SHA1 implementations are not needed"
388     'libnettle',
389     'libgcrypt',     # in debian base system
390     'libcrypto',
393 if get_option('sha1') != 'auto'
394     test_sha1 = [get_option('sha1')]
395 endif
397 sha1_found = false
398 foreach t : test_sha1
399     if t == 'libc'
400         if cc.has_function('SHA1Init')
401             sha1_found = true
402             sha1_dep = dependency('', required: false)
403         endif
404     elif t == 'CommonCrypto'
405         if cc.has_function('CC_SHA1_Init')
406             sha1_found = true
407             sha1_dep = dependency('', required: false)
408         endif
409     elif t == 'CryptoAPI'
410         if cc.has_header('wincrypt.h')
411             sha1_found = true
412             sha1_dep = dependency('', required: false)
413         endif
414     elif t == 'libmd'
415         md_dep = cc.find_library('md', required: false)
416         if md_dep.found()
417             sha1_found = true
418             sha1_dep = md_dep
419         endif
420     elif t == 'libsha1'
421         libsha1_dep = dependency('libsha1', required: false)
422         if libsha1_dep.found()
423             sha1_found = true
424             sha1_dep = libsha1_dep
425         endif
426     elif t == 'libnettle'
427         nettle_dep = dependency('nettle', required: false)
428         if nettle_dep.found()
429             sha1_found = true
430             sha1_dep = nettle_dep
431         endif
432     elif t == 'libgcrypt'
433         gcrypt_dep = dependency('libgcrypt', required: false)
434         if gcrypt_dep.found()
435             sha1_found = true
436             sha1_dep = gcrypt_dep
437         endif
438     elif t == 'libcrypto'
439         # we don't need all of OpenSSL, just libcrypto
440         libcrypto_dep = cc.find_library('crypto', required: false)
441         openssl_dep = dependency('openssl', required: false)
442         if libcrypto_dep.found() or openssl_dep.found()
443             sha1_found = true
444             if libcrypto_dep.found()
445                sha1_dep = libcrypto_dep
446             else
447                sha1_dep = openssl_dep
448             endif
449         endif
450     endif
452     if sha1_found
453         sha1 = t
454         break
455     endif
456 endforeach
458 if sha1_found
459     message('Using @0@ SHA1 functions'.format(sha1))
460 else
461     if get_option('sha1') != 'auto'
462         error('@0@ SHA1 requested, but not found'.format(get_option('sha1')))
463     else
464         error('No suitable SHA1 implementation found')
465     endif
466 endif
468 xdmcp_dep = dependency('', required : false)
469 if get_option('xdmcp')
470     xdmcp_dep = dependency('xdmcp')
471 endif
473 has_xdm_auth = get_option('xdm-auth-1')
475 if not xdmcp_dep.found()
476   has_xdm_auth = false
477 endif
479 build_glx = get_option('glx')
480 if build_glx
481     build_hashtable = true
482 endif
484 libdrm_dep = dependency('libdrm', version: libdrm_req, required: false)
486 if get_option('dri1') == 'auto'
487     build_dri1 = xf86driproto_dep.found() and libdrm_dep.found()
488 else
489     build_dri1 = get_option('dri1') == 'true'
490 endif
492 if get_option('dri2') == 'auto'
493     build_dri2 = dri2proto_dep.found() and libdrm_dep.found()
494 else
495     build_dri2 = get_option('dri2') == 'true'
496 endif
498 if get_option('dri3') == 'auto'
499     build_dri3 = dri3proto_dep.found() and xshmfence_dep.found() and libdrm_dep.found()
500 else
501     build_dri3 = get_option('dri3') == 'true'
502     if build_dri3
503        if not xshmfence_dep.found()
504            error('DRI3 requested, but xshmfence not found')
505        endif
506     endif
507 endif
509 libdrm_required = (build_dri1 or build_dri2 or build_dri3) and get_option('drm') == true
510 if not libdrm_dep.found() and libdrm_required
511     error('DRI requested, but LIBDRM not found')
512 endif
514 build_modesetting = libdrm_dep.found() and dri2proto_dep.found()
516 build_vgahw = false
517 if get_option('vgahw') == 'auto'
518     if (host_machine.system() != 'darwin' and
519         host_machine.system() != 'windows' and
520         host_machine.system() != 'cygwin')
521         build_vgahw = true
522     endif
523 else
524     build_vgahw = get_option('vgahw') == 'true'
525 endif
527 build_dpms = get_option('dpms')
528 if build_xquartz
529     build_dpms = false
530 endif
532 build_xf86bigfont = get_option('xf86bigfont')
533 build_screensaver = get_option('screensaver')
534 build_res = get_option('xres')
535 if build_res
536     build_hashtable = true
537 endif
539 build_xace = get_option('xace')
540 build_xinerama = get_option('xinerama')
542 build_xsecurity = get_option('xcsecurity')
543 if build_xsecurity
544     if not build_xace
545         error('cannot build Security extension without X-ACE')
546     endif
547 endif
549 build_xv = get_option('xv')
550 build_xvmc = get_option('xvmc')
551 if not build_xv
552     build_xvmc = false
553 endif
555 build_dga = false
556 xf86dgaproto_dep = dependency('', required: false)
557 if get_option('dga') == 'auto'
558     xf86dgaproto_dep = dependency('xf86dgaproto', version: xf86dgaproto_req, required: false)
559     if xf86dgaproto_dep.found()
560         build_dga = true
561     endif
562 elif get_option('dga') == 'true'
563     xf86dgaproto_dep = dependency('xf86dgaproto', version: xf86dgaproto_req, required: true)
564     build_dga = true
565 endif
567 build_apm = false
568 if (get_option('linux_apm') == true and
569    host_machine.system() == 'linux')
570     if cc.has_header('linux/apm_bios.h')
571         build_apm = true
572     endif
573 endif
575 build_acpi = false
576 if (get_option('linux_acpi') == true and
577    host_machine.system() == 'linux')
578     if (host_machine.cpu() == 'x86' or
579        host_machine.cpu() == 'x86_64' or
580        host_machine.cpu() == 'ia64')
581         build_acpi = true
582     endif
583 endif
585 build_mitshm = false
586 if get_option('mitshm') == 'auto'
587     build_mitshm = cc.has_header('sys/shm.h')
588 elif get_option('mitshm') == 'true'
589     build_mitshm = true
590 endif
592 m_dep = cc.find_library('m', required : false)
593 dl_dep = cc.find_library('dl', required : false)
595 common_dep = [
596     xproto_dep,
597     randrproto_dep,
598     renderproto_dep,
599     xextproto_dep,
600     inputproto_dep,
601     kbproto_dep,
602     fontsproto_dep,
603     fixesproto_dep,
604     damageproto_dep,
605     xcmiscproto_dep,
606     bigreqsproto_dep,
607     presentproto_dep,
608     xtrans_dep,
609     libsystemd_daemon_dep,
611     videoproto_dep,
612     compositeproto_dep,
613     recordproto_dep,
614     scrnsaverproto_dep,
615     resourceproto_dep,
616     xf86driproto_dep,
617     dri2proto_dep,
618     dri3proto_dep,
619     xineramaproto_dep,
620     xf86bigfontproto_dep,
621     xf86dgaproto_dep,
622     xf86vidmodeproto_dep,
623     applewmproto_dep,
624     dpmsproto_dep,
626     pixman_dep,
627     libbsd_dep,
628     xkbfile_dep,
629     xfont2_dep,
630     xdmcp_dep,
633 inc = include_directories(
634     '.',
635     'Xext',
636     'Xi',
637     'composite',
638     'damageext',
639     'exa',
640     'fb',
641     'glamor',
642     'mi',
643     'miext/damage',
644     'miext/shadow',
645     'miext/sync',
646     'dbe',
647     'dix',
648     'dri3',
649     'include',
650     'present',
651     'randr',
652     'render',
653     'xfixes',
656 build_xselinux = false
657 if get_option('xselinux') != 'false'
658     dep_selinux = dependency('libselinux', version: libselinux_req,
659                              required: get_option('xselinux') == 'true')
660     dep_audit = dependency('audit', required: get_option('xselinux') == 'true')
661     if get_option('xselinux') == 'true'
662         build_xselinux = true
663     else
664         build_xselinux = dep_selinux.found() and dep_audit.found()
665     endif
667     if build_xselinux
668         common_dep += dep_selinux
669         common_dep += dep_audit
670     endif
671 endif
673 socket_dep = []
674 if host_machine.system() == 'windows'
675     socket_dep = meson.get_compiler('c').find_library('ws2_32')
676     common_dep += socket_dep
677 endif
679 if get_option('libunwind')
680     common_dep += dependency('libunwind', required: true)
681 endif
683 glx_inc = include_directories('glx')
685 top_dir_inc = include_directories('.')
687 serverconfigdir = get_option('serverconfigdir')
688 if serverconfigdir == ''
689     serverconfigdir = join_paths(get_option('prefix'), get_option('libdir'), 'xorg')
690 endif
692 subdir('man')
694 require_docs = get_option('docs') == 'true'
695 require_devel_docs = get_option('devel-docs') == 'true'
696 require_docs_pdf = (require_docs or require_devel_docs) and get_option('docs-pdf') == 'true'
698 sgml_doctools_dep = dependency('xorg-sgml-doctools',
699                                required: require_docs or require_devel_docs)
700 xmlto = find_program('xmlto', required: require_docs or require_devel_docs)
701 xsltproc = find_program('xsltproc', required: require_docs or require_devel_docs)
702 fop = find_program('fop', required: require_docs_pdf)
704 build_docs = (get_option('docs') != 'false' and
705     sgml_doctools_dep.found() and
706     xmlto.found())
708 build_docs_devel = (get_option('devel-docs') != 'false' and
709     sgml_doctools_dep.found() and
710     xmlto.found())
712 build_docs_pdf = (get_option('docs-pdf') != 'false' and
713     (build_docs or build_docs_devel) and
714     fop.found())
716 if build_docs or build_docs_devel
717     doc_sgml_path = sgml_doctools_dep.get_variable(pkgconfig : 'sgmlrootdir')
718     doc_stylesheet_srcdir = join_paths(doc_sgml_path, 'X11')
720     # Meson does not and will not support functions so we are copy-pasting
721     # documentation build code around which is unfortunate
722     # See https://mesonbuild.com/FAQ.html#why-doesnt-meson-have-user-defined-functionsmacros
724     docs_xmlto_search_flags = [
725         '--searchpath', doc_stylesheet_srcdir,
726         '--searchpath', meson.project_build_root(),
727     ]
729     docs_xslt_search_flags = [
730         '--path', doc_stylesheet_srcdir,
731         '--path', meson.project_build_root(),
732     ]
733 endif
735 # Include must come first, as it sets up dix-config.h
736 subdir('include')
738 # X server core
739 subdir('config')
740 subdir('dix')
741 subdir('dri3')
742 subdir('glx')
743 subdir('fb')
744 subdir('mi')
745 subdir('os')
746 # X extensions
747 subdir('composite')
748 subdir('damageext')
749 subdir('dbe')
750 subdir('miext/damage')
751 subdir('miext/shadow')
752 subdir('miext/sync')
753 if build_rootless
754     subdir('miext/rootless')
755 endif
756 subdir('present')
757 if build_xwin or build_xquartz
758     subdir('pseudoramiX')
759 endif
760 subdir('randr')
761 subdir('record')
762 subdir('render')
763 subdir('xfixes')
764 subdir('xkb')
765 subdir('Xext')
766 subdir('Xi')
767 # other
768 if build_glamor
769     subdir('glamor')
770 endif
771 if build_xorg or get_option('xephyr')
772     subdir('exa')
773 endif
774 subdir('doc')
776 # Common static libraries of all X servers
777 libxserver = [
778     libxserver_mi,
779     libxserver_dix,
781     libxserver_composite,
782     libxserver_damageext,
783     libxserver_dbe,
784     libxserver_randr,
785     libxserver_miext_damage,
786     libxserver_render,
787     libxserver_present,
788     libxserver_xext,
789     libxserver_miext_sync,
790     libxserver_xfixes,
791     libxserver_xi,
792     libxserver_xkb,
793     libxserver_record,
795     libxserver_os,
798 libxserver += libxserver_dri3
800 subdir('hw')
802 if host_machine.system() != 'windows'
803     subdir('test')
804 endif
806 if build_xorg
807     sdkconfig = configuration_data()
808     awk = find_program('awk')
810     sdkconfig.set('prefix', get_option('prefix'))
811     sdkconfig.set('exec_prefix', '${prefix}')
812     sdkconfig.set('libdir', join_paths('${exec_prefix}', get_option('libdir')))
813     sdkconfig.set('includedir', join_paths('${prefix}', get_option('includedir')))
814     sdkconfig.set('datarootdir', join_paths('${prefix}', get_option('datadir')))
815     sdkconfig.set('moduledir', join_paths('${exec_prefix}', module_dir))
816     sdkconfig.set('sdkdir', join_paths('${prefix}', get_option('includedir'), 'xorg'))
817     sdkconfig.set('sysconfigdir', join_paths('${datarootdir}', 'X11/xorg.conf.d'))
819     sdkconfig.set('abi_ansic',
820         run_command(awk, '-F', '[(,)]',
821                     '/^#define ABI_ANSIC.*SET/ { printf "%d.%d", $2, $3 }',
822                     files('hw/xfree86/common/xf86Module.h'),
823                     check: false
824         ).stdout()
825     )
826     sdkconfig.set('abi_videodrv',
827         run_command(awk, '-F', '[(,)]',
828                     '/^#define ABI_VIDEODRV.*SET/ { printf "%d.%d", $2, $3 }',
829                     files('hw/xfree86/common/xf86Module.h'),
830                     check: false
831         ).stdout()
832     )
833     sdkconfig.set('abi_xinput',
834         run_command(awk, '-F', '[(,)]',
835                     '/^#define ABI_XINPUT.*SET/ { printf "%d.%d", $2, $3 }',
836                     files('hw/xfree86/common/xf86Module.h'),
837                     check: false
838         ).stdout()
839     )
840     sdkconfig.set('abi_extension',
841         run_command(awk, '-F', '[(,)]',
842                     '/^#define ABI_EXTENSION.*SET/ { printf "%d.%d", $2, $3 }',
843                     files('hw/xfree86/common/xf86Module.h'),
844                     check: false
845         ).stdout()
846     )
848     sdk_required_modules = [
849       'pixman-1 >= 0.27.2',
850     ]
852     # XXX this isn't trying very hard, but hard enough.
853     sdkconfig.set('PACKAGE_VERSION', meson.project_version())
854     sdkconfig.set('SDK_REQUIRED_MODULES', ' '.join(sdk_required_modules))
855     sdkconfig.set('symbol_visibility', '-fvisibility=hidden')
856     sdkconfig.set('XORG_DRIVER_LIBS', '')
858     # On Windows, modules built with the SDK will need to link with server and
859     # module implibs to resolve symbols
860     if (host_machine.system() == 'cygwin' or
861         host_machine.system() == 'windows')
862         sdkconfig.set('XORG_DRIVER_LIBS', '-lXorg.exe -L\${moduledir} -lshadow -no-undefined')
863     endif
865     configure_file(
866         input: 'xorg-server.pc.in',
867         output: 'xorg-server.pc',
868         configuration: sdkconfig,
869         install_dir: join_paths(get_option('prefix'),
870                                 get_option('libdir'),
871                                 'pkgconfig'),
872     )
874     install_data('xorg-server.m4',
875                  install_dir: join_paths(get_option('datadir'), 'aclocal'))
876 endif
878 if build_docs or build_docs_devel
879     docxmlconfig = configuration_data()
880     docxmlconfig.set('PACKAGE_VERSION', meson.project_version())
881     docxmlconfig.set('RELEASE_DATE', release_date)
882     configure_file(
883         input: 'xserver.ent.in',
884         output: 'xserver.ent',
885         configuration: docxmlconfig
886     )
887 endif