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