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