xref: /OK3568_Linux_fs/external/xserver/meson.build (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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
364rga_dep = dependency('', required: false)
365if build_modesetting
366    rga_dep = dependency('librga', required: false)
367endif
368
369build_vgahw = false
370if get_option('vgahw') == 'auto'
371    if (host_machine.system() != 'darwin' and
372        host_machine.system() != 'windows' and
373        host_machine.system() != 'cygwin')
374        build_vgahw = true
375    endif
376else
377    build_vgahw = get_option('vgahw') == 'true'
378endif
379
380build_dpms = get_option('dpms')
381if build_xquartz
382    build_dpms = false
383endif
384
385build_xf86bigfont = get_option('xf86bigfont')
386build_screensaver = get_option('screensaver')
387build_res = get_option('xres')
388if build_res
389    build_hashtable = true
390endif
391
392build_xace = get_option('xace')
393build_xinerama = get_option('xinerama')
394
395build_xsecurity = get_option('xcsecurity')
396if build_xsecurity
397    if not build_xace
398        error('cannot build Security extension without X-ACE')
399    endif
400endif
401
402build_xv = get_option('xv')
403build_xvmc = get_option('xvmc')
404if not build_xv
405    build_xvmc = false
406endif
407
408build_dga = false
409if get_option('dga') == 'auto'
410    xf86dgaproto_dep = dependency('xf86dgaproto', version: '>= 2.0.99.1', required: false)
411    if xf86dgaproto_dep.found()
412        build_dga = true
413    endif
414elif get_option('dga') == 'true'
415    xf86dgaproto_dep = dependency('xf86dgaproto', version: '>= 2.0.99.1', required: true)
416    build_dga = true
417endif
418
419build_apm = false
420if (get_option('linux_apm') == true and
421   host_machine.system() == 'linux')
422    if cc.has_header('linux/apm_bios.h')
423        build_apm = true
424    endif
425endif
426
427build_acpi = false
428if (get_option('linux_acpi') == true and
429   host_machine.system() == 'linux')
430    if (host_machine.cpu() == 'x86' or
431       host_machine.cpu() == 'x86_64' or
432       host_machine.cpu() == 'ia64')
433        build_acpi = true
434    endif
435endif
436
437build_mitshm = false
438if get_option('mitshm') == 'auto'
439    build_mitshm = cc.has_header('sys/shm.h')
440elif get_option('mitshm') == 'true'
441    build_mitshm = true
442endif
443
444# XXX: Allow configuration of these.
445build_xselinux = false
446build_xf86vidmode = xf86vidmodeproto_dep.found()
447
448m_dep = cc.find_library('m', required : false)
449dl_dep = cc.find_library('dl', required : false)
450
451common_dep = [
452    xproto_dep,
453    randrproto_dep,
454    renderproto_dep,
455    xextproto_dep,
456    inputproto_dep,
457    kbproto_dep,
458    fontsproto_dep,
459    fixesproto_dep,
460    damageproto_dep,
461    xcmiscproto_dep,
462    bigreqsproto_dep,
463    xtrans_dep,
464
465    videoproto_dep,
466    compositeproto_dep,
467    recordproto_dep,
468    scrnsaverproto_dep,
469    resourceproto_dep,
470    xf86driproto_dep,
471    dri2proto_dep,
472    dri3proto_dep,
473    xineramaproto_dep,
474    xf86bigfontproto_dep,
475    xf86dgaproto_dep,
476    xf86vidmodeproto_dep,
477    windowswmproto_dep,
478    applewmproto_dep,
479
480    pixman_dep,
481    libbsd_dep,
482    xkbfile_dep,
483    xfont2_dep,
484    xdmcp_dep,
485]
486
487inc = include_directories(
488    'Xext',
489    'Xi',
490    'composite',
491    'damageext',
492    'exa',
493    'fb',
494    'glamor',
495    'mi',
496    'miext/damage',
497    'miext/shadow',
498    'miext/sync',
499    'dbe',
500    'dri3',
501    'include',
502    'present',
503    'randr',
504    'render',
505    'xfixes',
506)
507
508glx_inc = include_directories('glx')
509
510top_srcdir_inc = include_directories('.')
511
512serverconfigdir = join_paths(get_option('libdir'), 'xorg')
513
514manpage_config = configuration_data()
515manpage_config.set('vendorversion', '"xorg-server @0@" "X Version 11"'.format(meson.project_version()))
516manpage_config.set('xorgversion', '"xorg-server @0@" "X Version 11"'.format(meson.project_version()))
517manpage_config.set('xservername', 'Xorg')
518manpage_config.set('xconfigfile', 'xorg.conf')
519manpage_config.set('projectroot', get_option('prefix'))
520manpage_config.set('apploaddir', '$(appdefaultdir)')
521manpage_config.set('appmansuffix', '1')
522manpage_config.set('drivermansuffix', '4')
523manpage_config.set('adminmansuffix', '8')
524manpage_config.set('libmansuffix', '3')
525manpage_config.set('miscmansuffix', '7')
526manpage_config.set('filemansuffix', '5')
527manpage_config.set('logdir', log_dir)
528manpage_config.set('datadir', join_paths(get_option('prefix'), get_option('datadir')))
529manpage_config.set('mandir', join_paths(get_option('prefix'), get_option('mandir')))
530manpage_config.set('sysconfdir', join_paths(get_option('prefix'), get_option('sysconfdir')))
531manpage_config.set('xconfigdir', 'xorg.conf.d')
532manpage_config.set('xkbdir', xkb_dir)
533manpage_config.set('XKB_DFLT_RULES', get_option('xkb_default_rules'))
534manpage_config.set('XKB_DFLT_MODEL', get_option('xkb_default_model'))
535manpage_config.set('XKB_DFLT_LAYOUT', get_option('xkb_default_layout'))
536manpage_config.set('XKB_DFLT_VARIANT', get_option('xkb_default_variant'))
537manpage_config.set('XKB_DFLT_OPTIONS', get_option('xkb_default_options'))
538manpage_config.set('bundle_id_prefix', '...')
539manpage_config.set('modulepath', module_dir)
540# wtf doesn't this work
541# manpage_config.set('suid_wrapper_dir', join_paths(get_option('prefix'), libexecdir))
542manpage_config.set('suid_wrapper_dir', join_paths(get_option('prefix'), 'libexec'))
543manpage_config.set('default_font_path', default_font_path)
544
545# Include must come first, as it sets up dix-config.h
546subdir('include')
547
548# X server core
549subdir('config')
550subdir('dix')
551subdir('dri3')
552subdir('glx')
553subdir('fb')
554subdir('mi')
555subdir('os')
556# X extensions
557subdir('composite')
558subdir('damageext')
559subdir('dbe')
560subdir('miext/damage')
561subdir('miext/shadow')
562subdir('miext/sync')
563subdir('present')
564if build_xwin or build_xquartz
565    subdir('pseudoramiX')
566endif
567subdir('randr')
568subdir('record')
569subdir('render')
570subdir('xfixes')
571subdir('xkb')
572subdir('Xext')
573subdir('Xi')
574# other
575if build_glamor
576    subdir('glamor')
577endif
578if build_xorg or get_option('xephyr')
579    subdir('exa')
580endif
581
582# Common static libraries of all X servers
583libxserver = [
584    libxserver_mi,
585    libxserver_dix,
586
587    libxserver_composite,
588    libxserver_damageext,
589    libxserver_dbe,
590    libxserver_randr,
591    libxserver_miext_damage,
592    libxserver_render,
593    libxserver_present,
594    libxserver_xext,
595    libxserver_miext_sync,
596    libxserver_xfixes,
597    libxserver_xi,
598    libxserver_xkb,
599    libxserver_record,
600
601    libxserver_os,
602]
603
604libxserver += libxserver_dri3
605
606subdir('hw')
607subdir('test')
608
609install_man(configure_file(
610    input: 'man/Xserver.man',
611    output: 'Xserver.1',
612    configuration: manpage_config,
613))
614
615if build_xorg
616    sdkconfig = configuration_data()
617    awk = find_program('awk')
618
619    sdkconfig.set('prefix', get_option('prefix'))
620    sdkconfig.set('exec_prefix', '${prefix}')
621    sdkconfig.set('libdir', join_paths('${exec_prefix}', get_option('libdir')))
622    sdkconfig.set('includedir', join_paths('${prefix}', get_option('includedir')))
623    sdkconfig.set('datarootdir', join_paths('${prefix}', get_option('datadir')))
624    sdkconfig.set('moduledir', join_paths('${exec_prefix}', module_dir))
625    sdkconfig.set('sdkdir', join_paths('${prefix}', get_option('includedir'), 'xorg'))
626    sdkconfig.set('sysconfigdir', join_paths('${datarootdir}', 'X11/xorg.conf.d'))
627
628    sdkconfig.set('abi_ansic',
629        run_command(awk, '-F', '[(,)]',
630                    '/^#define ABI_ANSIC.*SET/ { printf "%d.%d", $2, $3 }',
631                    files('hw/xfree86/common/xf86Module.h')
632        ).stdout()
633    )
634    sdkconfig.set('abi_videodrv',
635        run_command(awk, '-F', '[(,)]',
636                    '/^#define ABI_VIDEODRV.*SET/ { printf "%d.%d", $2, $3 }',
637                    files('hw/xfree86/common/xf86Module.h')
638        ).stdout()
639    )
640    sdkconfig.set('abi_xinput',
641        run_command(awk, '-F', '[(,)]',
642                    '/^#define ABI_XINPUT.*SET/ { printf "%d.%d", $2, $3 }',
643                    files('hw/xfree86/common/xf86Module.h')
644        ).stdout()
645    )
646    sdkconfig.set('abi_extension',
647        run_command(awk, '-F', '[(,)]',
648                    '/^#define ABI_EXTENSION.*SET/ { printf "%d.%d", $2, $3 }',
649                    files('hw/xfree86/common/xf86Module.h')
650        ).stdout()
651    )
652
653    sdk_required_modules = [
654      'pixman-1 >= 0.27.2',
655    ]
656
657    # XXX this isn't trying very hard, but hard enough.
658    sdkconfig.set('PACKAGE_VERSION', meson.project_version())
659    sdkconfig.set('SDK_REQUIRED_MODULES', ' '.join(sdk_required_modules))
660    sdkconfig.set('symbol_visibility', '-fvisibility=hidden')
661    sdkconfig.set('XORG_DRIVER_LIBS', '')
662
663    configure_file(
664        input: 'xorg-server.pc.in',
665        output: 'xorg-server.pc',
666        configuration: sdkconfig,
667        install_dir: join_paths(get_option('prefix'),
668                                get_option('libdir'),
669                                'pkgconfig'),
670    )
671endif
672
673install_data('xorg-server.m4',
674             install_dir: join_paths(get_option('datadir'), 'aclocal'))
675