meson.build revision c8548ba8
1project('xserver', 'c',
2        default_options: [
3            'buildtype=debugoptimized',
4            'c_std=gnu99',
5        ],
6        version: '1.20.11',
7        meson_version: '>= 0.42.0',
8)
9add_project_arguments('-DHAVE_DIX_CONFIG_H', language: 'c')
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')
60
61xproto_dep = dependency('xproto', version: '>= 7.0.31')
62randrproto_dep = dependency('randrproto', version: '>= 1.6.0')
63renderproto_dep = dependency('renderproto', version: '>= 0.11')
64xextproto_dep = dependency('xextproto', version: '>= 7.2.99.901')
65inputproto_dep = dependency('inputproto', version: '>= 2.3')
66kbproto_dep = dependency('kbproto', version: '>= 1.0.3')
67fontsproto_dep = dependency('fontsproto', version: '>= 2.1.3')
68fixesproto_dep = dependency('fixesproto', version: '>= 5.0')
69damageproto_dep = dependency('damageproto', version: '>= 1.1')
70xcmiscproto_dep = dependency('xcmiscproto', version: '>= 1.2.0')
71bigreqsproto_dep = dependency('bigreqsproto', version: '>= 1.1.0')
72xtrans_dep = dependency('xtrans', version: '>= 1.3.5')
73
74videoproto_dep = dependency('videoproto')
75compositeproto_dep = dependency('compositeproto', version: '>= 0.4')
76recordproto_dep = dependency('recordproto', version: '>= 1.13.99.1')
77scrnsaverproto_dep = dependency('scrnsaverproto', version: '>= 1.1')
78resourceproto_dep = dependency('resourceproto', version: '>= 1.2.0')
79xf86driproto_dep = dependency('xf86driproto', version: '>= 2.1.0', required: get_option('dri1') == 'true')
80dri2proto_dep = dependency('dri2proto', version: '>= 2.8', required: get_option('dri2') == 'true')
81dri3proto_dep = dependency('dri3proto', version: '>= 1.2', required: get_option('dri3') == 'true')
82xineramaproto_dep = dependency('xineramaproto')
83xf86bigfontproto_dep = dependency('xf86bigfontproto', version: '>= 1.2.0')
84xf86vidmodeproto_dep = dependency('xf86vidmodeproto', version: '>= 2.2.99.1', required: false)
85windowswmproto_dep = dependency('windowswmproto', required: false)
86applewmproto_dep = dependency('applewmproto', version: '>= 1.4', required: false)
87xshmfence_dep = dependency('xshmfence', version: '>= 1.1', required: false)
88
89pixman_dep = dependency('pixman-1')
90libbsd_dep = dependency('libbsd', required: false)
91xkbcomp_dep = dependency('xkbcomp', required: false)
92xkbfile_dep = dependency('xkbfile')
93xfont2_dep = dependency('xfont2', version: '>= 2.0')
94nettle_dep = dependency('nettle')
95
96dbus_required = get_option('systemd_logind') == 'true'
97dbus_dep = dependency('dbus-1', version: '>= 1.0', required: dbus_required)
98
99build_hashtable = false
100
101# Resolve default values of some options
102xkb_dir = get_option('xkb_dir')
103if xkb_dir == ''
104    xkb_dir = xkbcomp_dep.get_pkgconfig_variable('xkbconfigdir')
105    if xkb_dir == ''
106        xkb_dir = join_paths(get_option('prefix'), 'share/X11/xkb')
107    endif
108endif
109
110xkb_output_dir = get_option('xkb_output_dir')
111if xkb_output_dir == ''
112    xkb_output_dir = join_paths(xkb_dir, 'compiled')
113endif
114
115xkb_bin_dir = get_option('xkb_bin_dir')
116if xkb_bin_dir == ''
117    xkb_bin_dir = xkbcomp_dep.get_pkgconfig_variable('bindir')
118    if xkb_bin_dir == ''
119        xkb_bin_dir = join_paths(get_option('prefix'), get_option('bindir'))
120    endif
121endif
122
123dfp = get_option('default_font_path')
124if dfp == ''
125    fontutil_dep = dependency('fontutil')
126    fontrootdir = fontutil_dep.get_pkgconfig_variable('fontrootdir')
127    default_font_path = ','.join([
128        join_paths(fontrootdir, 'misc'),
129        join_paths(fontrootdir, 'TTF'),
130        join_paths(fontrootdir, 'OTF'),
131        join_paths(fontrootdir, 'Type1'),
132        join_paths(fontrootdir, '100dpi'),
133        join_paths(fontrootdir, '75dpi'),
134    ])
135else
136    default_font_path = dfp
137endif
138
139hal_option = get_option('hal')
140glamor_option = get_option('glamor')
141
142build_udev = get_option('udev')
143if host_machine.system() == 'windows'
144    build_udev = false
145    hal_option = 'false'
146endif
147
148if get_option('systemd_logind') == 'auto'
149    build_systemd_logind = build_udev and dbus_dep.found()
150else
151    build_systemd_logind = get_option('systemd_logind') == 'true'
152endif
153
154build_xorg = false
155if (host_machine.system() != 'darwin' and
156    host_machine.system() != 'windows')
157    if get_option('xorg') == 'auto'
158        build_xorg = (host_machine.system() != 'darwin' and
159                      host_machine.system() != 'windows')
160    else
161        build_xorg = get_option('xorg') == 'true'
162    endif
163endif
164xorgsdkdir = join_paths(get_option('prefix'), get_option('includedir'), 'xorg')
165
166build_xwayland = false
167if (host_machine.system() != 'darwin' and
168    host_machine.system() != 'windows')
169    if get_option('xwayland') != 'false'
170        xwayland_required = get_option('xwayland') == 'true'
171
172        xwayland_dep = [
173            dependency('wayland-client', version: '>= 1.3.0', required: xwayland_required),
174            dependency('wayland-protocols', version: '>= 1.10', required: xwayland_required),
175            dependency('libdrm', version: '>= 2.4.89', required: xwayland_required),
176            dependency('epoxy', required: xwayland_required),
177        ]
178
179        build_xwayland = true
180        # check for all the deps being found, to handle 'auto' mode.
181        foreach d: xwayland_dep
182            if not d.found()
183                build_xwayland = false
184            endif
185        endforeach
186    endif
187endif
188
189build_xnest = false
190if (host_machine.system() != 'darwin' and
191    host_machine.system() != 'windows')
192    if get_option('xnest') != 'false'
193        xnest_required = get_option('xnest') == 'true'
194
195        xnest_dep = [
196            dependency('xext', version: '>= 1.0.99.4', required: xnest_required),
197            dependency('x11', required: xnest_required),
198            dependency('xau', required: xnest_required),
199        ]
200
201        build_xnest = true
202        # check for all the deps being found, to handle 'auto' mode.
203        foreach d: xnest_dep
204            if not d.found()
205                build_xnest = false
206            endif
207        endforeach
208    endif
209endif
210
211build_xwin = false
212if get_option('xwin') == 'auto'
213    if (host_machine.system() == 'cygwin' or
214        host_machine.system() == 'windows')
215            build_xwin = true
216    endif
217else
218    build_xwin = get_option('xwin') == 'true'
219endif
220
221# XXX: Finish these.
222build_xquartz = false
223
224if get_option('ipv6') == 'auto'
225    build_ipv6 = cc.has_function('getaddrinfo')
226else
227    build_ipv6 = get_option('ipv6') == 'true'
228endif
229
230int10 = get_option('int10')
231if int10 == 'auto'
232    int10 = 'x86emu'
233    if host_machine.cpu() == 'powerpc' and host_machine.system() == 'freebsd'
234        int10 = 'stub'
235    endif
236    if host_machine.cpu() == 'arm'
237        int10 = 'stub'
238    endif
239endif
240
241hal_dep = []
242if hal_option == 'auto'
243    if not build_udev
244        hal_dep = dependency('hal', required: false)
245        build_hal = hal_dep.found()
246    else
247        build_hal = false
248    endif
249else
250    build_hal = hal_option == 'true'
251    if build_hal
252        hal_dep = dependency('hal')
253    endif
254endif
255
256if build_udev and build_hal
257    error('Hotplugging through both libudev and hal not allowed')
258endif
259
260build_dbus = build_hal or build_systemd_logind
261
262udev_dep = dependency('', required:false)
263if build_udev
264    udev_dep = dependency('libudev', version: '>= 143')
265endif
266
267log_dir = get_option('log_dir')
268if log_dir == ''
269    log_dir = join_paths(get_option('prefix'), get_option('localstatedir'), 'log')
270endif
271
272module_dir = join_paths(get_option('libdir'), get_option('module_dir'))
273
274if glamor_option == 'auto'
275    build_glamor = build_xorg or build_xwayland
276else
277    build_glamor = get_option('glamor') == 'true'
278endif
279
280gbm_dep = dependency('', required: false)
281epoxy_dep = dependency('', required: false)
282if build_glamor
283    gbm_dep = dependency('gbm', version: '>= 10.2', required: false)
284    epoxy_dep = dependency('epoxy', required: false)
285endif
286
287eglstream_option = get_option('xwayland_eglstream')
288if build_xwayland and build_glamor
289    eglstream_dep = dependency('wayland-eglstream-protocols', required:false)
290    if eglstream_option == 'auto'
291        build_eglstream = eglstream_dep.found()
292    else
293        build_eglstream = eglstream_option == 'true'
294        if build_eglstream and not eglstream_dep.found()
295            error('glamor EGLStream support requested, but wayland-eglstream-protocols not found')
296        endif
297    endif
298else
299    build_eglstream = false
300endif
301
302# XXX: Add more sha1 options, because Linux is about choice
303sha1_dep = nettle_dep
304
305xdmcp_dep = dependency('', required : false)
306if get_option('xdmcp')
307    xdmcp_dep = dependency('xdmcp')
308endif
309
310has_xdm_auth = get_option('xdm-auth-1')
311
312if not xdmcp_dep.found()
313  has_xdm_auth = false
314endif
315
316build_glx = get_option('glx')
317if build_glx
318    build_hashtable = true
319endif
320
321libdrm_dep = dependency('libdrm', version: '>= 2.4.89', required: false)
322
323if get_option('dri1') == 'auto'
324    build_dri1 = xf86driproto_dep.found() and libdrm_dep.found()
325else
326    build_dri1 = get_option('dri1') == 'true'
327endif
328
329if get_option('dri2') == 'auto'
330    build_dri2 = dri2proto_dep.found() and libdrm_dep.found()
331else
332    build_dri2 = get_option('dri2') == 'true'
333endif
334
335if get_option('dri3') == 'auto'
336    build_dri3 = dri3proto_dep.found() and xshmfence_dep.found() and libdrm_dep.found()
337else
338    build_dri3 = get_option('dri3') == 'true'
339    if build_dri3
340       if not xshmfence_dep.found()
341           error('DRI3 requested, but xshmfence not found')
342       endif
343    endif
344endif
345
346libdrm_required = build_dri1 or build_dri2 or build_dri3
347if not libdrm_dep.found() and libdrm_required
348    error('DRI requested, but LIBDRM not found')
349endif
350
351build_modesetting = libdrm_dep.found() and dri2proto_dep.found()
352
353build_vbe = false
354if get_option('vbe') == 'auto'
355    if (host_machine.system() != 'darwin' and
356        host_machine.system() != 'windows' and
357        host_machine.system() != 'cygwin')
358        build_vbe = true
359    endif
360else
361    build_vbe = get_option('vbe') == 'true'
362endif
363
364build_vgahw = false
365if get_option('vgahw') == 'auto'
366    if (host_machine.system() != 'darwin' and
367        host_machine.system() != 'windows' and
368        host_machine.system() != 'cygwin')
369        build_vgahw = true
370    endif
371else
372    build_vgahw = get_option('vgahw') == 'true'
373endif
374
375build_dpms = get_option('dpms')
376if build_xquartz
377    build_dpms = false
378endif
379
380build_xf86bigfont = get_option('xf86bigfont')
381build_screensaver = get_option('screensaver')
382build_res = get_option('xres')
383if build_res
384    build_hashtable = true
385endif
386
387build_xace = get_option('xace')
388build_xinerama = get_option('xinerama')
389
390build_xsecurity = get_option('xcsecurity')
391if build_xsecurity
392    if not build_xace
393        error('cannot build Security extension without X-ACE')
394    endif
395endif
396
397build_xv = get_option('xv')
398build_xvmc = get_option('xvmc')
399if not build_xv
400    build_xvmc = false
401endif
402
403build_dga = false
404if get_option('dga') == 'auto'
405    xf86dgaproto_dep = dependency('xf86dgaproto', version: '>= 2.0.99.1', required: false)
406    if xf86dgaproto_dep.found()
407        build_dga = true
408    endif
409elif get_option('dga') == 'true'
410    xf86dgaproto_dep = dependency('xf86dgaproto', version: '>= 2.0.99.1', required: true)
411    build_dga = true
412endif
413
414build_apm = false
415if (get_option('linux_apm') == true and
416   host_machine.system() == 'linux')
417    if cc.has_header('linux/apm_bios.h')
418        build_apm = true
419    endif
420endif
421
422build_acpi = false
423if (get_option('linux_acpi') == true and
424   host_machine.system() == 'linux')
425    if (host_machine.cpu() == 'x86' or
426       host_machine.cpu() == 'x86_64' or
427       host_machine.cpu() == 'ia64')
428        build_acpi = true
429    endif
430endif
431
432build_mitshm = false
433if get_option('mitshm') == 'auto'
434    build_mitshm = cc.has_header('sys/shm.h')
435elif get_option('mitshm') == 'true'
436    build_mitshm = true
437endif
438
439# XXX: Allow configuration of these.
440build_xselinux = false
441build_xf86vidmode = xf86vidmodeproto_dep.found()
442
443m_dep = cc.find_library('m', required : false)
444dl_dep = cc.find_library('dl', required : false)
445
446common_dep = [
447    xproto_dep,
448    randrproto_dep,
449    renderproto_dep,
450    xextproto_dep,
451    inputproto_dep,
452    kbproto_dep,
453    fontsproto_dep,
454    fixesproto_dep,
455    damageproto_dep,
456    xcmiscproto_dep,
457    bigreqsproto_dep,
458    xtrans_dep,
459
460    videoproto_dep,
461    compositeproto_dep,
462    recordproto_dep,
463    scrnsaverproto_dep,
464    resourceproto_dep,
465    xf86driproto_dep,
466    dri2proto_dep,
467    dri3proto_dep,
468    xineramaproto_dep,
469    xf86bigfontproto_dep,
470    xf86dgaproto_dep,
471    xf86vidmodeproto_dep,
472    windowswmproto_dep,
473    applewmproto_dep,
474
475    pixman_dep,
476    libbsd_dep,
477    xkbfile_dep,
478    xfont2_dep,
479    xdmcp_dep,
480]
481
482inc = include_directories(
483    'Xext',
484    'Xi',
485    'composite',
486    'damageext',
487    'exa',
488    'fb',
489    'glamor',
490    'mi',
491    'miext/damage',
492    'miext/shadow',
493    'miext/sync',
494    'dbe',
495    'dri3',
496    'include',
497    'present',
498    'randr',
499    'render',
500    'xfixes',
501)
502
503glx_inc = include_directories('glx')
504
505top_srcdir_inc = include_directories('.')
506
507serverconfigdir = join_paths(get_option('libdir'), 'xorg')
508
509manpage_config = configuration_data()
510manpage_config.set('vendorversion', '"xorg-server @0@" "X Version 11"'.format(meson.project_version()))
511manpage_config.set('xorgversion', '"xorg-server @0@" "X Version 11"'.format(meson.project_version()))
512manpage_config.set('xservername', 'Xorg')
513manpage_config.set('xconfigfile', 'xorg.conf')
514manpage_config.set('projectroot', get_option('prefix'))
515manpage_config.set('apploaddir', '$(appdefaultdir)')
516manpage_config.set('appmansuffix', '1')
517manpage_config.set('drivermansuffix', '4')
518manpage_config.set('adminmansuffix', '8')
519manpage_config.set('libmansuffix', '3')
520manpage_config.set('miscmansuffix', '7')
521manpage_config.set('filemansuffix', '5')
522manpage_config.set('logdir', log_dir)
523manpage_config.set('datadir', join_paths(get_option('prefix'), get_option('datadir')))
524manpage_config.set('mandir', join_paths(get_option('prefix'), get_option('mandir')))
525manpage_config.set('sysconfdir', join_paths(get_option('prefix'), get_option('sysconfdir')))
526manpage_config.set('xconfigdir', 'xorg.conf.d')
527manpage_config.set('xkbdir', xkb_dir)
528manpage_config.set('XKB_DFLT_RULES', get_option('xkb_default_rules'))
529manpage_config.set('XKB_DFLT_MODEL', get_option('xkb_default_model'))
530manpage_config.set('XKB_DFLT_LAYOUT', get_option('xkb_default_layout'))
531manpage_config.set('XKB_DFLT_VARIANT', get_option('xkb_default_variant'))
532manpage_config.set('XKB_DFLT_OPTIONS', get_option('xkb_default_options'))
533manpage_config.set('bundle_id_prefix', '...')
534manpage_config.set('modulepath', module_dir)
535# wtf doesn't this work
536# manpage_config.set('suid_wrapper_dir', join_paths(get_option('prefix'), libexecdir))
537manpage_config.set('suid_wrapper_dir', join_paths(get_option('prefix'), 'libexec'))
538manpage_config.set('default_font_path', default_font_path)
539
540# Include must come first, as it sets up dix-config.h
541subdir('include')
542
543# X server core
544subdir('config')
545subdir('dix')
546subdir('dri3')
547subdir('glx')
548subdir('fb')
549subdir('mi')
550subdir('os')
551# X extensions
552subdir('composite')
553subdir('damageext')
554subdir('dbe')
555subdir('miext/damage')
556subdir('miext/shadow')
557subdir('miext/sync')
558subdir('present')
559if build_xwin or build_xquartz
560    subdir('pseudoramiX')
561endif
562subdir('randr')
563subdir('record')
564subdir('render')
565subdir('xfixes')
566subdir('xkb')
567subdir('Xext')
568subdir('Xi')
569# other
570if build_glamor
571    subdir('glamor')
572endif
573if build_xorg or get_option('xephyr')
574    subdir('exa')
575endif
576
577# Common static libraries of all X servers
578libxserver = [
579    libxserver_mi,
580    libxserver_dix,
581
582    libxserver_composite,
583    libxserver_damageext,
584    libxserver_dbe,
585    libxserver_randr,
586    libxserver_miext_damage,
587    libxserver_render,
588    libxserver_present,
589    libxserver_xext,
590    libxserver_miext_sync,
591    libxserver_xfixes,
592    libxserver_xi,
593    libxserver_xkb,
594    libxserver_record,
595
596    libxserver_os,
597]
598
599libxserver += libxserver_dri3
600
601subdir('hw')
602subdir('test')
603
604install_man(configure_file(
605    input: 'man/Xserver.man',
606    output: 'Xserver.1',
607    configuration: manpage_config,
608))
609
610if build_xorg
611    sdkconfig = configuration_data()
612    awk = find_program('awk')
613
614    sdkconfig.set('prefix', get_option('prefix'))
615    sdkconfig.set('exec_prefix', '${prefix}')
616    sdkconfig.set('libdir', join_paths('${exec_prefix}', get_option('libdir')))
617    sdkconfig.set('includedir', join_paths('${prefix}', get_option('includedir')))
618    sdkconfig.set('datarootdir', join_paths('${prefix}', get_option('datadir')))
619    sdkconfig.set('moduledir', join_paths('${exec_prefix}', module_dir))
620    sdkconfig.set('sdkdir', join_paths('${prefix}', get_option('includedir'), 'xorg'))
621    sdkconfig.set('sysconfigdir', join_paths('${datarootdir}', 'X11/xorg.conf.d'))
622
623    sdkconfig.set('abi_ansic',
624        run_command(awk, '-F', '[(,)]',
625                    '/^#define ABI_ANSIC.*SET/ { printf "%d.%d", $2, $3 }',
626                    files('hw/xfree86/common/xf86Module.h')
627        ).stdout()
628    )
629    sdkconfig.set('abi_videodrv',
630        run_command(awk, '-F', '[(,)]',
631                    '/^#define ABI_VIDEODRV.*SET/ { printf "%d.%d", $2, $3 }',
632                    files('hw/xfree86/common/xf86Module.h')
633        ).stdout()
634    )
635    sdkconfig.set('abi_xinput',
636        run_command(awk, '-F', '[(,)]',
637                    '/^#define ABI_XINPUT.*SET/ { printf "%d.%d", $2, $3 }',
638                    files('hw/xfree86/common/xf86Module.h')
639        ).stdout()
640    )
641    sdkconfig.set('abi_extension',
642        run_command(awk, '-F', '[(,)]',
643                    '/^#define ABI_EXTENSION.*SET/ { printf "%d.%d", $2, $3 }',
644                    files('hw/xfree86/common/xf86Module.h')
645        ).stdout()
646    )
647
648    sdk_required_modules = [
649      'pixman-1 >= 0.27.2',
650    ]
651
652    # XXX this isn't trying very hard, but hard enough.
653    sdkconfig.set('PACKAGE_VERSION', meson.project_version())
654    sdkconfig.set('SDK_REQUIRED_MODULES', ' '.join(sdk_required_modules))
655    sdkconfig.set('symbol_visibility', '-fvisibility=hidden')
656    sdkconfig.set('XORG_DRIVER_LIBS', '')
657
658    configure_file(
659        input: 'xorg-server.pc.in',
660        output: 'xorg-server.pc',
661        configuration: sdkconfig,
662        install_dir: join_paths(get_option('prefix'),
663                                get_option('libdir'),
664                                'pkgconfig'),
665    )
666endif
667
668install_data('xorg-server.m4',
669             install_dir: join_paths(get_option('datadir'), 'aclocal'))
670