1project('xserver', 'c',
2        default_options: [
3            'buildtype=debugoptimized',
4            'c_std=gnu99',
5        ],
6        version: '21.1.18',
7        meson_version: '>= 0.47.0',
8)
9release_date = '2025-06-18'
10
11add_project_arguments('-DHAVE_DIX_CONFIG_H', language: ['c', 'objc'])
12cc = meson.get_compiler('c')
13
14add_global_arguments('-fno-strict-aliasing', language : 'c')
15add_global_arguments('-fvisibility=hidden', language : 'c')
16
17add_global_link_arguments('-fvisibility=hidden', language : 'c')
18
19if 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    ]
50else
51    test_wflags = []
52endif
53
54common_wflags = []
55foreach wflag: test_wflags
56    if cc.has_argument(wflag)
57        common_wflags += [ wflag ]
58    endif
59endforeach
60
61add_global_arguments(common_wflags, language : ['c', 'objc'])
62
63libdrm_req = '>= 2.4.89'
64libselinux_req = '>= 2.0.86'
65xext_req = '>= 1.0.99.4'
66wayland_req = '>= 1.5.0'
67wayland_protocols_req = '>= 1.18'
68gbm_req = '>= 10.2'
69xf86dgaproto_req = '>= 2.0.99.1'
70
71xproto_dep = dependency('xproto', version: '>= 7.0.31', fallback: ['xorgproto', 'ext_xorgproto'])
72randrproto_dep = dependency('randrproto', version: '>= 1.6.0', fallback: ['xorgproto', 'ext_xorgproto'])
73renderproto_dep = dependency('renderproto', version: '>= 0.11', fallback: ['xorgproto', 'ext_xorgproto'])
74xextproto_dep = dependency('xextproto', version: '>= 7.2.99.901', fallback: ['xorgproto', 'ext_xorgproto'])
75inputproto_dep = dependency('inputproto', version: '>= 2.3.99.1', fallback: ['xorgproto', 'ext_xorgproto'])
76kbproto_dep = dependency('kbproto', version: '>= 1.0.3', fallback: ['xorgproto', 'ext_xorgproto'])
77fontsproto_dep = dependency('fontsproto', version: '>= 2.1.3', fallback: ['xorgproto', 'ext_xorgproto'])
78fixesproto_dep = dependency('fixesproto', version: '>= 6.0', fallback: ['xorgproto', 'ext_xorgproto'])
79damageproto_dep = dependency('damageproto', version: '>= 1.1', fallback: ['xorgproto', 'ext_xorgproto'])
80xcmiscproto_dep = dependency('xcmiscproto', version: '>= 1.2.0', fallback: ['xorgproto', 'ext_xorgproto'])
81bigreqsproto_dep = dependency('bigreqsproto', version: '>= 1.1.0', fallback: ['xorgproto', 'ext_xorgproto'])
82xtrans_dep = dependency('xtrans', version: '>= 1.3.5')
83
84videoproto_dep = dependency('videoproto', fallback: ['xorgproto', 'ext_xorgproto'])
85compositeproto_dep = dependency('compositeproto', version: '>= 0.4', fallback: ['xorgproto', 'ext_xorgproto'])
86recordproto_dep = dependency('recordproto', version: '>= 1.13.99.1', fallback: ['xorgproto', 'ext_xorgproto'])
87scrnsaverproto_dep = dependency('scrnsaverproto', version: '>= 1.1', fallback: ['xorgproto', 'ext_xorgproto'])
88resourceproto_dep = dependency('resourceproto', version: '>= 1.2.0', fallback: ['xorgproto', 'ext_xorgproto'])
89xf86driproto_dep = dependency('xf86driproto', version: '>= 2.1.0', fallback: ['xorgproto', 'ext_xorgproto'], required: get_option('dri1') == 'true')
90dri2proto_dep = dependency('dri2proto', version: '>= 2.8', fallback: ['xorgproto', 'ext_xorgproto'], required: get_option('dri2') == 'true')
91dri3proto_dep = dependency('dri3proto', version: '>= 1.2', fallback: ['xorgproto', 'ext_xorgproto'], required: get_option('dri3') == 'true')
92xineramaproto_dep = dependency('xineramaproto', fallback: ['xorgproto', 'ext_xorgproto'])
93xf86bigfontproto_dep = dependency('xf86bigfontproto', version: '>= 1.2.0', fallback: ['xorgproto', 'ext_xorgproto'], required: get_option('xf86bigfont'))
94xf86vidmodeproto_dep = dependency('xf86vidmodeproto', version: '>= 2.2.99.1', fallback: ['xorgproto', 'ext_xorgproto'])
95applewmproto_dep = dependency('applewmproto', version: '>= 1.4', fallback: ['xorgproto', 'ext_xorgproto'], required: false)
96xshmfence_dep = dependency('xshmfence', version: '>= 1.1', required: false)
97
98pixman_dep = dependency('pixman-1')
99libbsd_dep = dependency('libbsd-overlay', required: false)
100xkbcomp_dep = dependency('xkbcomp', required: false)
101xkbfile_dep = dependency('xkbfile')
102xfont2_dep = dependency('xfont2', version: '>= 2.0')
103
104dbus_required = get_option('systemd_logind') == 'true'
105dbus_dep = dependency('dbus-1', version: '>= 1.0', required: dbus_required)
106
107# libsystemd-daemon was moved into libsystemd in version 209
108libsystemd_daemon_dep = dependency('libsystemd', version: '>= 209', required: false)
109if not libsystemd_daemon_dep.found()
110    libsystemd_daemon_dep = dependency('libsystemd-daemon', required: false)
111endif
112
113build_hashtable = false
114
115# Resolve default values of some options
116xkb_dir = get_option('xkb_dir')
117if xkb_dir == ''
118    if xkbcomp_dep.found() and xkbcomp_dep.type_name() == 'pkgconfig'
119        xkb_dir = xkbcomp_dep.get_pkgconfig_variable('xkbconfigdir')
120    endif
121    if xkb_dir == ''
122        xkb_dir = join_paths(get_option('prefix'), 'share/X11/xkb')
123    endif
124endif
125
126xkb_output_dir = get_option('xkb_output_dir')
127if xkb_output_dir == ''
128    xkb_output_dir = join_paths(xkb_dir, 'compiled')
129endif
130
131xkb_bin_dir = get_option('xkb_bin_dir')
132if xkb_bin_dir == ''
133    if xkbcomp_dep.found() and xkbcomp_dep.type_name() == 'pkgconfig'
134        xkb_bin_dir = xkbcomp_dep.get_pkgconfig_variable('bindir')
135    endif
136    if xkb_bin_dir == ''
137        xkb_bin_dir = join_paths(get_option('prefix'), get_option('bindir'))
138    endif
139endif
140
141dfp = get_option('default_font_path')
142if dfp == ''
143    fontutil_dep = dependency('fontutil')
144    fontrootdir = fontutil_dep.get_pkgconfig_variable('fontrootdir')
145    dfp_elements = [
146        join_paths(fontrootdir, 'misc'),
147        join_paths(fontrootdir, 'TTF'),
148        join_paths(fontrootdir, 'OTF'),
149        join_paths(fontrootdir, 'Type1'),
150        join_paths(fontrootdir, '100dpi'),
151        join_paths(fontrootdir, '75dpi'),
152    ]
153    if host_machine.system() == 'darwin'
154       dfp_elements += [
155       '/Library/Fonts',
156       '/System/Library/Fonts',
157    ]
158    endif
159    default_font_path = ','.join(dfp_elements)
160else
161    default_font_path = dfp
162endif
163
164hal_option = get_option('hal')
165glamor_option = get_option('glamor')
166
167build_udev = get_option('udev')
168build_udev_kms = get_option('udev_kms')
169if ['windows',  'darwin', 'cygwin'].contains(host_machine.system())
170    build_udev = false
171    build_udev_kms = false
172    hal_option = 'false'
173endif
174
175if get_option('systemd_logind') == 'auto'
176    build_systemd_logind = build_udev_kms and dbus_dep.found()
177else
178    build_systemd_logind = get_option('systemd_logind') == 'true'
179endif
180
181with_dtrace = get_option('dtrace')
182if with_dtrace
183    dtrace = find_program('dtrace', required: true)
184endif
185
186build_xorg = false
187if (host_machine.system() != 'windows')
188    if get_option('xorg') == 'auto'
189        build_xorg = (host_machine.system() != 'darwin' and
190                      host_machine.system() != 'windows')
191    else
192        build_xorg = get_option('xorg') == 'true'
193    endif
194endif
195xorgsdkdir = join_paths(get_option('prefix'), get_option('includedir'), 'xorg')
196libxcvt_dep = dependency('libxcvt', required: build_xorg)
197
198build_xnest = false
199if (host_machine.system() != 'windows')
200    if get_option('xnest') != 'false'
201        xnest_required = get_option('xnest') == 'true'
202
203        xnest_dep = [
204            dependency('xext', version: xext_req, required: xnest_required),
205            dependency('x11', required: xnest_required),
206            dependency('xau', required: xnest_required),
207        ]
208
209        build_xnest = true
210        # check for all the deps being found, to handle 'auto' mode.
211        foreach d: xnest_dep
212            if not d.found()
213                build_xnest = false
214            endif
215        endforeach
216    endif
217endif
218
219build_xwin = false
220if get_option('xwin') == 'auto'
221    if (host_machine.system() == 'cygwin' or
222        host_machine.system() == 'windows')
223            build_xwin = true
224    endif
225else
226    build_xwin = get_option('xwin') == 'true'
227endif
228
229build_xquartz = false
230if get_option('xquartz') == 'auto'
231    if host_machine.system() == 'darwin'
232            build_xquartz = true
233    endif
234else
235    build_xquartz = get_option('xquartz') == 'true'
236endif
237
238build_rootless = false
239if build_xquartz
240    build_rootless = true
241endif
242
243if get_option('ipv6') == 'auto'
244    build_ipv6 = cc.has_function('getaddrinfo')
245else
246    build_ipv6 = get_option('ipv6') == 'true'
247endif
248
249int10 = get_option('int10')
250if int10 == 'auto'
251    int10 = 'x86emu'
252    if host_machine.cpu() == 'powerpc' and host_machine.system() == 'freebsd'
253        int10 = 'stub'
254    endif
255    if host_machine.cpu() == 'arm'
256        int10 = 'stub'
257    endif
258endif
259
260hal_dep = []
261if hal_option == 'auto'
262    if not build_udev
263        hal_dep = dependency('hal', required: false)
264        build_hal = hal_dep.found()
265    else
266        build_hal = false
267    endif
268else
269    build_hal = hal_option == 'true'
270    if build_hal
271        hal_dep = dependency('hal')
272    endif
273endif
274
275if build_udev and build_hal
276    error('Hotplugging through both libudev and hal not allowed')
277endif
278
279build_dbus = build_hal or build_systemd_logind
280
281udev_dep = dependency('', required:false)
282if build_udev or build_udev_kms
283    udev_dep = dependency('libudev', version: '>= 143')
284endif
285
286log_dir = get_option('log_dir')
287if log_dir == ''
288    log_dir = join_paths(get_option('prefix'), get_option('localstatedir'), 'log')
289endif
290
291module_dir = join_paths(get_option('libdir'), get_option('module_dir'))
292
293if glamor_option == 'auto'
294    build_glamor = build_xorg
295else
296    build_glamor = glamor_option == 'true'
297endif
298
299gbm_dep = dependency('', required: false)
300epoxy_dep = dependency('', required: false)
301if build_glamor
302    gbm_dep = dependency('gbm', version: gbm_req, required: false)
303    epoxy_dep = dependency('epoxy', required: false)
304endif
305
306# Lots of sha1 options, because Linux is about choice :)
307
308# The idea behind the ordering here is that we should first prefer system
309# builtin providers, and then smaller implementations of over larger ones.
310test_sha1 = [
311    'libc',          # libmd API is in libc on some BSDs
312    'CommonCrypto',  # darwin API
313    'CryptoAPI',     # windows API
314    'libmd',         # other BSDs & Solaris
315    '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"
316    'libnettle',
317    'libgcrypt',     # in debian base system
318    'libcrypto',
319]
320
321if get_option('sha1') != 'auto'
322    test_sha1 = [get_option('sha1')]
323endif
324
325sha1_found = false
326foreach t : test_sha1
327    if t == 'libc'
328        if cc.has_function('SHA1Init')
329            sha1_found = true
330            sha1_dep = dependency('', required: false)
331        endif
332    elif t == 'CommonCrypto'
333        if cc.has_function('CC_SHA1_Init')
334            sha1_found = true
335            sha1_dep = dependency('', required: false)
336        endif
337    elif t == 'CryptoAPI'
338        if cc.has_header('wincrypt.h')
339            sha1_found = true
340            sha1_dep = dependency('', required: false)
341        endif
342    elif t == 'libmd'
343        md_dep = cc.find_library('md', required: false)
344        if md_dep.found()
345            sha1_found = true
346            sha1_dep = md_dep
347        endif
348    elif t == 'libsha1'
349        libsha1_dep = dependency('libsha1', required: false)
350        if libsha1_dep.found()
351            sha1_found = true
352            sha1_dep = libsha1_dep
353        endif
354    elif t == 'libnettle'
355        nettle_dep = dependency('nettle', required: false)
356        if nettle_dep.found()
357            sha1_found = true
358            sha1_dep = nettle_dep
359        endif
360    elif t == 'libgcrypt'
361        gcrypt_dep = dependency('libgcrypt', required: false)
362        if gcrypt_dep.found()
363            sha1_found = true
364            sha1_dep = gcrypt_dep
365        endif
366    elif t == 'libcrypto'
367        # we don't need all of OpenSSL, just libcrypto
368        libcrypto_dep = cc.find_library('crypto', required: false)
369        openssl_dep = dependency('openssl', required: false)
370        if libcrypto_dep.found() or openssl_dep.found()
371            sha1_found = true
372            if libcrypto_dep.found()
373               sha1_dep = libcrypto_dep
374            else
375               sha1_dep = openssl_dep
376            endif
377        endif
378    endif
379
380    if sha1_found
381        sha1 = t
382        break
383    endif
384endforeach
385
386if sha1_found
387    message('Using @0@ SHA1 functions'.format(sha1))
388else
389    if get_option('sha1') != 'auto'
390        error('@0@ SHA1 requested, but not found'.format(get_option('sha1')))
391    else
392        error('No suitable SHA1 implementation found')
393    endif
394endif
395
396xdmcp_dep = dependency('', required : false)
397if get_option('xdmcp')
398    xdmcp_dep = dependency('xdmcp')
399endif
400
401has_xdm_auth = get_option('xdm-auth-1')
402
403if not xdmcp_dep.found()
404  has_xdm_auth = false
405endif
406
407build_glx = get_option('glx')
408if build_glx
409    build_hashtable = true
410endif
411
412libdrm_dep = dependency('libdrm', version: libdrm_req, required: false)
413
414if get_option('dri1') == 'auto'
415    build_dri1 = xf86driproto_dep.found() and libdrm_dep.found()
416else
417    build_dri1 = get_option('dri1') == 'true'
418endif
419
420if get_option('dri2') == 'auto'
421    build_dri2 = dri2proto_dep.found() and libdrm_dep.found()
422else
423    build_dri2 = get_option('dri2') == 'true'
424endif
425
426if get_option('dri3') == 'auto'
427    build_dri3 = dri3proto_dep.found() and xshmfence_dep.found() and libdrm_dep.found()
428else
429    build_dri3 = get_option('dri3') == 'true'
430    if build_dri3
431       if not xshmfence_dep.found()
432           error('DRI3 requested, but xshmfence not found')
433       endif
434    endif
435endif
436
437libdrm_required = (build_dri1 or build_dri2 or build_dri3) and get_option('drm') == true
438if not libdrm_dep.found() and libdrm_required
439    error('DRI requested, but LIBDRM not found')
440endif
441
442build_modesetting = libdrm_dep.found() and dri2proto_dep.found()
443
444build_vgahw = false
445if get_option('vgahw') == 'auto'
446    if (host_machine.system() != 'darwin' and
447        host_machine.system() != 'windows' and
448        host_machine.system() != 'cygwin')
449        build_vgahw = true
450    endif
451else
452    build_vgahw = get_option('vgahw') == 'true'
453endif
454
455build_dpms = get_option('dpms')
456if build_xquartz
457    build_dpms = false
458endif
459
460build_xf86bigfont = get_option('xf86bigfont')
461build_screensaver = get_option('screensaver')
462build_res = get_option('xres')
463if build_res
464    build_hashtable = true
465endif
466
467build_xace = get_option('xace')
468build_xinerama = get_option('xinerama')
469
470build_xsecurity = get_option('xcsecurity')
471if build_xsecurity
472    if not build_xace
473        error('cannot build Security extension without X-ACE')
474    endif
475endif
476
477build_xv = get_option('xv')
478build_xvmc = get_option('xvmc')
479if not build_xv
480    build_xvmc = false
481endif
482
483build_dga = false
484xf86dgaproto_dep = dependency('', required: false)
485if get_option('dga') == 'auto'
486    xf86dgaproto_dep = dependency('xf86dgaproto', version: xf86dgaproto_req, required: false)
487    if xf86dgaproto_dep.found()
488        build_dga = true
489    endif
490elif get_option('dga') == 'true'
491    xf86dgaproto_dep = dependency('xf86dgaproto', version: xf86dgaproto_req, required: true)
492    build_dga = true
493endif
494
495build_apm = false
496if (get_option('linux_apm') == true and
497   host_machine.system() == 'linux')
498    if cc.has_header('linux/apm_bios.h')
499        build_apm = true
500    endif
501endif
502
503build_acpi = false
504if (get_option('linux_acpi') == true and
505   host_machine.system() == 'linux')
506    if (host_machine.cpu() == 'x86' or
507       host_machine.cpu() == 'x86_64' or
508       host_machine.cpu() == 'ia64')
509        build_acpi = true
510    endif
511endif
512
513build_mitshm = false
514if get_option('mitshm') == 'auto'
515    build_mitshm = cc.has_header('sys/shm.h')
516elif get_option('mitshm') == 'true'
517    build_mitshm = true
518endif
519
520m_dep = cc.find_library('m', required : false)
521dl_dep = cc.find_library('dl', required : false)
522
523common_dep = [
524    xproto_dep,
525    randrproto_dep,
526    renderproto_dep,
527    xextproto_dep,
528    inputproto_dep,
529    kbproto_dep,
530    fontsproto_dep,
531    fixesproto_dep,
532    damageproto_dep,
533    xcmiscproto_dep,
534    bigreqsproto_dep,
535    xtrans_dep,
536    libsystemd_daemon_dep,
537
538    videoproto_dep,
539    compositeproto_dep,
540    recordproto_dep,
541    scrnsaverproto_dep,
542    resourceproto_dep,
543    xf86driproto_dep,
544    dri2proto_dep,
545    dri3proto_dep,
546    xineramaproto_dep,
547    xf86bigfontproto_dep,
548    xf86dgaproto_dep,
549    xf86vidmodeproto_dep,
550    applewmproto_dep,
551
552    pixman_dep,
553    libbsd_dep,
554    xkbfile_dep,
555    xfont2_dep,
556    xdmcp_dep,
557]
558
559inc = include_directories(
560    'Xext',
561    'Xi',
562    'composite',
563    'damageext',
564    'exa',
565    'fb',
566    'glamor',
567    'mi',
568    'miext/damage',
569    'miext/shadow',
570    'miext/sync',
571    'dbe',
572    'dri3',
573    'include',
574    'present',
575    'randr',
576    'render',
577    'xfixes',
578)
579
580build_xselinux = false
581if get_option('xselinux') != 'false'
582    dep_selinux = dependency('libselinux', version: libselinux_req,
583			     required: get_option('xselinux') == 'true')
584    dep_audit = dependency('audit', required: get_option('xselinux') == 'true')
585    if get_option('xselinux') == 'true'
586        build_xselinux = true
587    else
588        build_xselinux = dep_selinux.found() and dep_audit.found()
589    endif
590
591    if build_xselinux
592        common_dep += dep_selinux
593        common_dep += dep_audit
594    endif
595endif
596
597socket_dep = []
598if host_machine.system() == 'windows'
599    socket_dep = meson.get_compiler('c').find_library('ws2_32')
600    common_dep += socket_dep
601endif
602
603if get_option('libunwind')
604    common_dep += dependency('libunwind', required: true)
605endif
606
607glx_inc = include_directories('glx')
608
609top_dir_inc = include_directories('.')
610
611serverconfigdir = join_paths(get_option('prefix'), get_option('libdir'), 'xorg')
612
613manpage_config = configuration_data()
614manpage_config.set('vendorversion', '"xorg-server @0@" "X Version 11"'.format(meson.project_version()))
615manpage_config.set('xorgversion', '"xorg-server @0@" "X Version 11"'.format(meson.project_version()))
616manpage_config.set('xservername', 'Xorg')
617manpage_config.set('xconfigfile', 'xorg.conf')
618manpage_config.set('projectroot', get_option('prefix'))
619manpage_config.set('apploaddir', '$(appdefaultdir)')
620manpage_config.set('appmansuffix', '1')
621manpage_config.set('drivermansuffix', '4')
622manpage_config.set('adminmansuffix', '8')
623manpage_config.set('libmansuffix', '3')
624manpage_config.set('miscmansuffix', '7')
625manpage_config.set('filemansuffix', '5')
626manpage_config.set('logdir', log_dir)
627manpage_config.set('datadir', join_paths(get_option('prefix'), get_option('datadir')))
628manpage_config.set('mandir', join_paths(get_option('prefix'), get_option('mandir')))
629manpage_config.set('sysconfdir', join_paths(get_option('prefix'), get_option('sysconfdir')))
630manpage_config.set('xconfigdir', 'xorg.conf.d')
631manpage_config.set('xkbdir', xkb_dir)
632manpage_config.set('XKB_DFLT_RULES', get_option('xkb_default_rules'))
633manpage_config.set('XKB_DFLT_MODEL', get_option('xkb_default_model'))
634manpage_config.set('XKB_DFLT_LAYOUT', get_option('xkb_default_layout'))
635manpage_config.set('XKB_DFLT_VARIANT', get_option('xkb_default_variant'))
636manpage_config.set('XKB_DFLT_OPTIONS', get_option('xkb_default_options'))
637manpage_config.set('bundle_id_prefix', '...')
638manpage_config.set('modulepath', module_dir)
639# wtf doesn't this work
640# manpage_config.set('suid_wrapper_dir', join_paths(get_option('prefix'), libexecdir))
641manpage_config.set('suid_wrapper_dir', join_paths(get_option('prefix'), 'libexec'))
642manpage_config.set('default_font_path', default_font_path)
643
644require_docs = get_option('docs') == 'true'
645require_devel_docs = get_option('devel-docs') == 'true'
646require_docs_pdf = (require_docs or require_devel_docs) and get_option('docs-pdf') == 'true'
647
648sgml_doctools_dep = dependency('xorg-sgml-doctools',
649                               required: require_docs or require_devel_docs)
650xmlto = find_program('xmlto', required: require_docs or require_devel_docs)
651xsltproc = find_program('xsltproc', required: require_docs or require_devel_docs)
652fop = find_program('fop', required: require_docs_pdf)
653
654build_docs = (get_option('docs') != 'false' and
655    sgml_doctools_dep.found() and
656    xmlto.found())
657
658build_docs_devel = (get_option('devel-docs') != 'false' and
659    sgml_doctools_dep.found() and
660    xmlto.found())
661
662build_docs_pdf = (get_option('docs-pdf') != 'false' and
663    (build_docs or build_docs_devel) and
664    fop.found())
665
666if build_docs or build_docs_devel
667    doc_sgml_path = sgml_doctools_dep.get_pkgconfig_variable('sgmlrootdir')
668    doc_stylesheet_srcdir = join_paths(doc_sgml_path, 'X11')
669
670    # once we bump meson dependency to 0.56.0 we can use
671    # meson.project_build_root() instead of meson.build_root()
672
673    # Meson does not and will not support functions so we are copy-pasting
674    # documentation build code around which is unfortunate
675    # See https://mesonbuild.com/FAQ.html#why-doesnt-meson-have-user-defined-functionsmacros
676
677    docs_xmlto_search_flags = [
678        '--searchpath', doc_stylesheet_srcdir,
679        '--searchpath', meson.build_root(),
680    ]
681
682    docs_xslt_search_flags = [
683        '--path', doc_stylesheet_srcdir,
684        '--path', meson.build_root(),
685    ]
686endif
687
688# Include must come first, as it sets up dix-config.h
689subdir('include')
690
691# X server core
692subdir('config')
693subdir('dix')
694subdir('dri3')
695subdir('glx')
696subdir('fb')
697subdir('mi')
698subdir('os')
699# X extensions
700subdir('composite')
701subdir('damageext')
702subdir('dbe')
703subdir('miext/damage')
704subdir('miext/shadow')
705subdir('miext/sync')
706if build_rootless
707    subdir('miext/rootless')
708endif
709subdir('present')
710if build_xwin or build_xquartz
711    subdir('pseudoramiX')
712endif
713subdir('randr')
714subdir('record')
715subdir('render')
716subdir('xfixes')
717subdir('xkb')
718subdir('Xext')
719subdir('Xi')
720# other
721if build_glamor
722    subdir('glamor')
723endif
724if build_xorg or get_option('xephyr')
725    subdir('exa')
726endif
727subdir('doc')
728
729# Common static libraries of all X servers
730libxserver = [
731    libxserver_mi,
732    libxserver_dix,
733
734    libxserver_composite,
735    libxserver_damageext,
736    libxserver_dbe,
737    libxserver_randr,
738    libxserver_miext_damage,
739    libxserver_render,
740    libxserver_present,
741    libxserver_xext,
742    libxserver_miext_sync,
743    libxserver_xfixes,
744    libxserver_xi,
745    libxserver_xkb,
746    libxserver_record,
747
748    libxserver_os,
749]
750
751libxserver += libxserver_dri3
752
753subdir('hw')
754
755if host_machine.system() != 'windows'
756    subdir('test')
757endif
758
759install_man(configure_file(
760    input: 'man/Xserver.man',
761    output: 'Xserver.1',
762    configuration: manpage_config,
763))
764
765if build_xorg
766    sdkconfig = configuration_data()
767    awk = find_program('awk')
768
769    sdkconfig.set('prefix', get_option('prefix'))
770    sdkconfig.set('exec_prefix', '${prefix}')
771    sdkconfig.set('libdir', join_paths('${exec_prefix}', get_option('libdir')))
772    sdkconfig.set('includedir', join_paths('${prefix}', get_option('includedir')))
773    sdkconfig.set('datarootdir', join_paths('${prefix}', get_option('datadir')))
774    sdkconfig.set('moduledir', join_paths('${exec_prefix}', module_dir))
775    sdkconfig.set('sdkdir', join_paths('${prefix}', get_option('includedir'), 'xorg'))
776    sdkconfig.set('sysconfigdir', join_paths('${datarootdir}', 'X11/xorg.conf.d'))
777
778    sdkconfig.set('abi_ansic',
779        run_command(awk, '-F', '[(,)]',
780                    '/^#define ABI_ANSIC.*SET/ { printf "%d.%d", $2, $3 }',
781                    files('hw/xfree86/common/xf86Module.h')
782        ).stdout()
783    )
784    sdkconfig.set('abi_videodrv',
785        run_command(awk, '-F', '[(,)]',
786                    '/^#define ABI_VIDEODRV.*SET/ { printf "%d.%d", $2, $3 }',
787                    files('hw/xfree86/common/xf86Module.h')
788        ).stdout()
789    )
790    sdkconfig.set('abi_xinput',
791        run_command(awk, '-F', '[(,)]',
792                    '/^#define ABI_XINPUT.*SET/ { printf "%d.%d", $2, $3 }',
793                    files('hw/xfree86/common/xf86Module.h')
794        ).stdout()
795    )
796    sdkconfig.set('abi_extension',
797        run_command(awk, '-F', '[(,)]',
798                    '/^#define ABI_EXTENSION.*SET/ { printf "%d.%d", $2, $3 }',
799                    files('hw/xfree86/common/xf86Module.h')
800        ).stdout()
801    )
802
803    sdk_required_modules = [
804      'pixman-1 >= 0.27.2',
805    ]
806
807    # XXX this isn't trying very hard, but hard enough.
808    sdkconfig.set('PACKAGE_VERSION', meson.project_version())
809    sdkconfig.set('SDK_REQUIRED_MODULES', ' '.join(sdk_required_modules))
810    sdkconfig.set('symbol_visibility', '-fvisibility=hidden')
811    sdkconfig.set('XORG_DRIVER_LIBS', '')
812
813    configure_file(
814        input: 'xorg-server.pc.in',
815        output: 'xorg-server.pc',
816        configuration: sdkconfig,
817        install_dir: join_paths(get_option('prefix'),
818                                get_option('libdir'),
819                                'pkgconfig'),
820    )
821
822    install_data('xorg-server.m4',
823                 install_dir: join_paths(get_option('datadir'), 'aclocal'))
824endif
825
826if build_docs or build_docs_devel
827    docxmlconfig = configuration_data()
828    docxmlconfig.set('PACKAGE_VERSION', meson.project_version())
829    docxmlconfig.set('RELEASE_DATE', release_date)
830    configure_file(
831        input: 'xserver.ent.in',
832        output: 'xserver.ent',
833        configuration: docxmlconfig
834    )
835endif
836