summaryrefslogtreecommitdiff
path: root/meson.build
blob: 4af03efe373a32aa1e686714a71605b09a578f83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
project('xwayland', 'c',
        default_options: [
            'buildtype=debugoptimized',
            'c_std=gnu99',
        ],
        version: '21.1.1',
        meson_version: '>= 0.46.0',
)
add_project_arguments('-DHAVE_DIX_CONFIG_H', language: ['c', 'objc'])
cc = meson.get_compiler('c')

add_global_arguments('-fno-strict-aliasing', language : 'c')
add_global_arguments('-fvisibility=hidden', language : 'c')

add_global_link_arguments('-fvisibility=hidden', language : 'c')

if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
    test_wflags = [
        '-Wall',
        '-Wpointer-arith',
        '-Wmissing-declarations',
        '-Wformat=2',
        '-Wstrict-prototypes',
        '-Wmissing-prototypes',
        '-Wnested-externs',
        '-Wbad-function-cast',
        '-Wold-style-definition',
        '-Wunused',
        '-Wuninitialized',
        '-Wshadow',
        '-Wmissing-noreturn',
        '-Wmissing-format-attribute',
        '-Wredundant-decls',
        '-Werror=implicit',
        '-Werror=nonnull',
        '-Werror=init-self',
        '-Werror=main',
        '-Werror=missing-braces',
        '-Werror=sequence-point',
        '-Werror=return-type',
        '-Werror=trigraphs',
        '-Werror=array-bounds',
        '-Werror=write-strings',
        '-Werror=address',
        '-Werror=int-to-pointer-cast',
        '-Werror=pointer-to-int-cast',
    ]
else
    test_wflags = []
endif

common_wflags = []
foreach wflag: test_wflags
    if cc.has_argument(wflag)
        common_wflags += [ wflag ]
    endif
endforeach

add_global_arguments(common_wflags, language : ['c', 'objc'])

libdrm_req = '>= 2.4.89'
libselinux_req = '>= 2.0.86'
xext_req = '>= 1.0.99.4'
wayland_req = '>= 1.3.0'
wayland_protocols_req = '>= 1.18'
gbm_req = '>= 10.2'

xproto_dep = dependency('xproto', version: '>= 7.0.31')
randrproto_dep = dependency('randrproto', version: '>= 1.6.0')
renderproto_dep = dependency('renderproto', version: '>= 0.11')
xextproto_dep = dependency('xextproto', version: '>= 7.2.99.901')
inputproto_dep = dependency('inputproto', version: '>= 2.3')
kbproto_dep = dependency('kbproto', version: '>= 1.0.3')
fontsproto_dep = dependency('fontsproto', version: '>= 2.1.3')
fixesproto_dep = dependency('fixesproto', version: '>= 5.0')
damageproto_dep = dependency('damageproto', version: '>= 1.1')
xcmiscproto_dep = dependency('xcmiscproto', version: '>= 1.2.0')
bigreqsproto_dep = dependency('bigreqsproto', version: '>= 1.1.0')
xtrans_dep = dependency('xtrans', version: '>= 1.3.5')

videoproto_dep = dependency('videoproto')
compositeproto_dep = dependency('compositeproto', version: '>= 0.4')
recordproto_dep = dependency('recordproto', version: '>= 1.13.99.1')
scrnsaverproto_dep = dependency('scrnsaverproto', version: '>= 1.1')
resourceproto_dep = dependency('resourceproto', version: '>= 1.2.0')
dri3proto_dep = dependency('dri3proto', version: '>= 1.2', required: get_option('dri3') == 'true')
xineramaproto_dep = dependency('xineramaproto')
xf86bigfontproto_dep = dependency('xf86bigfontproto', version: '>= 1.2.0', required: get_option('xf86bigfont'))
xf86vidmodeproto_dep = dependency('xf86vidmodeproto', version: '>= 2.2.99.1')
xshmfence_dep = dependency('xshmfence', version: '>= 1.1', required: false)

pixman_dep = dependency('pixman-1')
libbsd_dep = dependency('libbsd', required: false)
xkbcomp_dep = dependency('xkbcomp', required: false)
xkbfile_dep = dependency('xkbfile')
xfont2_dep = dependency('xfont2', version: '>= 2.0')

build_hashtable = false

# Resolve default values of some options
xkb_dir = get_option('xkb_dir')
if xkb_dir == ''
    if xkbcomp_dep.found() and xkbcomp_dep.type_name() == 'pkgconfig'
        xkb_dir = xkbcomp_dep.get_pkgconfig_variable('xkbconfigdir')
    endif
    if xkb_dir == ''
        xkb_dir = join_paths(get_option('prefix'), 'share/X11/xkb')
    endif
endif

xkb_output_dir = get_option('xkb_output_dir')
if xkb_output_dir == ''
    xkb_output_dir = join_paths(xkb_dir, 'compiled')
endif

xkb_bin_dir = get_option('xkb_bin_dir')
if xkb_bin_dir == ''
    if xkbcomp_dep.found() and xkbcomp_dep.type_name() == 'pkgconfig'
        xkb_bin_dir = xkbcomp_dep.get_pkgconfig_variable('bindir')
    endif
    if xkb_bin_dir == ''
        xkb_bin_dir = join_paths(get_option('prefix'), get_option('bindir'))
    endif
endif

dfp = get_option('default_font_path')
if dfp == ''
    fontutil_dep = dependency('fontutil')
    fontrootdir = fontutil_dep.get_pkgconfig_variable('fontrootdir')
    dfp_elements = [
        join_paths(fontrootdir, 'misc'),
        join_paths(fontrootdir, 'TTF'),
        join_paths(fontrootdir, 'OTF'),
        join_paths(fontrootdir, 'Type1'),
        join_paths(fontrootdir, '100dpi'),
        join_paths(fontrootdir, '75dpi'),
    ]
    if host_machine.system() == 'darwin'
       dfp_elements += [
       '/Library/Fonts',
       '/System/Library/Fonts',
    ]
    endif
    default_font_path = ','.join(dfp_elements)
else
    default_font_path = dfp
endif

build_glamor = get_option('glamor')

with_dtrace = get_option('dtrace')
if with_dtrace
    dtrace = find_program('dtrace', required: true)
endif

build_xwayland = true

xwayland_path = get_option('xwayland-path')
if (xwayland_path == '')
    xwayland_path = join_paths(get_option('prefix'), get_option('bindir'))
endif

xwayland_dep = [
    dependency('wayland-client', version: wayland_req, required: true),
    dependency('wayland-protocols', version: wayland_protocols_req, required: true),
]

if build_glamor
    xwayland_dep += dependency('libdrm', version: libdrm_req, required: true)
    xwayland_dep += dependency('epoxy', required: true)
endif

if get_option('ipv6') == 'auto'
    build_ipv6 = cc.has_function('getaddrinfo')
else
    build_ipv6 = get_option('ipv6') == 'true'
endif

gbm_dep = dependency('', required: false)
epoxy_dep = dependency('', required: false)
if build_glamor
    gbm_dep = dependency('gbm', version: gbm_req, required: false)
    epoxy_dep = dependency('epoxy', required: false)
endif

eglstream_option = get_option('xwayland_eglstream')
if build_xwayland and build_glamor
    eglstream_dep = dependency('wayland-eglstream-protocols', required:false)
    if eglstream_option == 'auto'
        build_eglstream = eglstream_dep.found()
    else
        build_eglstream = eglstream_option == 'true'
        if build_eglstream and not eglstream_dep.found()
            error('glamor EGLStream support requested, but wayland-eglstream-protocols not found')
        endif
    endif
else
    build_eglstream = false
endif

# Lots of sha1 options, because Linux is about choice :)

# The idea behind the ordering here is that we should first prefer system
# builtin providers, and then smaller implementations of over larger ones.
test_sha1 = [
    'libc',          # libmd API is in libc on some BSDs
    'CommonCrypto',  # darwin API
    'CryptoAPI',     # windows API
    'libmd',         # other BSDs & Solaris
    '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"
    'libnettle',
    'libgcrypt',     # in debian base system
    'libcrypto',
]

if get_option('sha1') != 'auto'
    test_sha1 = [get_option('sha1')]
endif

sha1_found = false
foreach t : test_sha1
    if t == 'libc'
        if cc.has_function('SHA1Init')
            sha1_found = true
            sha1_dep = dependency('', required: false)
        endif
    elif t == 'CommonCrypto'
        if cc.has_function('CC_SHA1_Init')
            sha1_found = true
            sha1_dep = dependency('', required: false)
        endif
    elif t == 'CryptoAPI'
        if cc.has_header('wincrypt.h')
            sha1_found = true
            sha1_dep = dependency('', required: false)
        endif
    elif t == 'libmd'
        md_dep = cc.find_library('md', required: false)
        if md_dep.found()
            sha1_found = true
            sha1_dep = md_dep
        endif
    elif t == 'libsha1'
        libsha1_dep = dependency('libsha1', required: false)
        if libsha1_dep.found()
            sha1_found = true
            sha1_dep = libsha1_dep
        endif
    elif t == 'libnettle'
        nettle_dep = dependency('nettle', required: false)
        if nettle_dep.found()
            sha1_found = true
            sha1_dep = nettle_dep
        endif
    elif t == 'libgcrypt'
        gcrypt_dep = dependency('libgcrypt', required: false)
        if gcrypt_dep.found()
            sha1_found = true
            sha1_dep = gcrypt_dep
        endif
    elif t == 'libcrypto'
        # we don't need all of OpenSSL, just libcrypto
        libcrypto_dep = cc.find_library('crypto', required: false)
        openssl_dep = dependency('openssl', required: false)
        if libcrypto_dep.found() or openssl_dep.found()
            sha1_found = true
            if libcrypto_dep.found()
               sha1_dep = libcrypto_dep
            else
               sha1_dep = openssl_dep
            endif
        endif
    endif

    if sha1_found
        sha1 = t
        break
    endif
endforeach

if sha1_found
    message('Using @0@ SHA1 functions'.format(sha1))
else
    if get_option('sha1') != 'auto'
        error('@0@ SHA1 requested, but not found'.format(get_option('sha1')))
    else
        error('No suitable SHA1 implementation found')
    endif
endif

xdmcp_dep = dependency('', required : false)
if get_option('xdmcp')
    xdmcp_dep = dependency('xdmcp')
endif

has_xdm_auth = get_option('xdm-auth-1')

if not xdmcp_dep.found()
  has_xdm_auth = false
endif

build_glx = get_option('glx')
if build_glx
    build_hashtable = true
endif

libdrm_dep = dependency('libdrm', version: libdrm_req, required: false)

if get_option('dri3') == 'auto'
    build_dri3 = dri3proto_dep.found() and xshmfence_dep.found() and libdrm_dep.found()
else
    build_dri3 = get_option('dri3') == 'true'
    if build_dri3
       if not xshmfence_dep.found()
           error('DRI3 requested, but xshmfence not found')
       endif
    endif
endif

libdrm_required = build_dri3
if not libdrm_dep.found() and libdrm_required
    error('DRI requested, but LIBDRM not found')
endif

build_dpms = get_option('dpms')

build_xf86bigfont = get_option('xf86bigfont')
build_screensaver = get_option('screensaver')
build_res = get_option('xres')
if build_res
    build_hashtable = true
endif

build_xace = get_option('xace')
build_xinerama = get_option('xinerama')

build_xsecurity = get_option('xcsecurity')
if build_xsecurity
    if not build_xace
        error('cannot build Security extension without X-ACE')
    endif
endif

build_xv = get_option('xv')

build_mitshm = false
if get_option('mitshm') == 'auto'
    build_mitshm = cc.has_header('sys/shm.h')
elif get_option('mitshm') == 'true'
    build_mitshm = true
endif

m_dep = cc.find_library('m', required : false)
dl_dep = cc.find_library('dl', required : false)

common_dep = [
    xproto_dep,
    randrproto_dep,
    renderproto_dep,
    xextproto_dep,
    inputproto_dep,
    kbproto_dep,
    fontsproto_dep,
    fixesproto_dep,
    damageproto_dep,
    xcmiscproto_dep,
    bigreqsproto_dep,
    xtrans_dep,

    videoproto_dep,
    compositeproto_dep,
    recordproto_dep,
    scrnsaverproto_dep,
    resourceproto_dep,
    dri3proto_dep,
    xineramaproto_dep,
    xf86bigfontproto_dep,
    xf86vidmodeproto_dep,

    pixman_dep,
    libbsd_dep,
    xkbfile_dep,
    xfont2_dep,
    xdmcp_dep,
]

inc = include_directories(
    'Xext',
    'Xi',
    'composite',
    'damageext',
    'fb',
    'glamor',
    'mi',
    'miext/damage',
    'miext/sync',
    'dbe',
    'dri3',
    'include',
    'present',
    'randr',
    'render',
    'xfixes',
)

build_xselinux = false
if get_option('xselinux') != 'false'
    dep_selinux = dependency('libselinux', version: libselinux_req,
			     required: get_option('xselinux') == 'true')
    dep_audit = dependency('audit', required: get_option('xselinux') == 'true')
    if get_option('xselinux') == 'true'
        build_xselinux = true
    else
        build_xselinux = dep_selinux.found() and dep_audit.found()
    endif

    if build_xselinux
        common_dep += dep_selinux
        common_dep += dep_audit
    endif
endif

socket_dep = []
if host_machine.system() == 'windows'
    socket_dep = meson.get_compiler('c').find_library('ws2_32')
    common_dep += socket_dep
endif

if get_option('libunwind')
    common_dep += dependency('libunwind', required: true)
endif

glx_inc = include_directories('glx')

top_dir_inc = include_directories('.')

serverconfigdir = join_paths(get_option('prefix'), get_option('libdir'), 'xorg')

manpage_config = configuration_data()
manpage_config.set('vendorversion', '"xorg-server @0@" "X Version 11"'.format(meson.project_version()))
manpage_config.set('xorgversion', '"xorg-server @0@" "X Version 11"'.format(meson.project_version()))
manpage_config.set('xservername', 'Xorg')
manpage_config.set('xconfigfile', 'xorg.conf')
manpage_config.set('projectroot', get_option('prefix'))
manpage_config.set('apploaddir', '$(appdefaultdir)')
manpage_config.set('appmansuffix', '1')
manpage_config.set('drivermansuffix', '4')
manpage_config.set('adminmansuffix', '8')
manpage_config.set('libmansuffix', '3')
manpage_config.set('miscmansuffix', '7')
manpage_config.set('filemansuffix', '5')
manpage_config.set('datadir', join_paths(get_option('prefix'), get_option('datadir')))
manpage_config.set('mandir', join_paths(get_option('prefix'), get_option('mandir')))
manpage_config.set('sysconfdir', join_paths(get_option('prefix'), get_option('sysconfdir')))
manpage_config.set('xconfigdir', 'xorg.conf.d')
manpage_config.set('xkbdir', xkb_dir)
manpage_config.set('XKB_DFLT_RULES', get_option('xkb_default_rules'))
manpage_config.set('XKB_DFLT_MODEL', get_option('xkb_default_model'))
manpage_config.set('XKB_DFLT_LAYOUT', get_option('xkb_default_layout'))
manpage_config.set('XKB_DFLT_VARIANT', get_option('xkb_default_variant'))
manpage_config.set('XKB_DFLT_OPTIONS', get_option('xkb_default_options'))
manpage_config.set('bundle_id_prefix', '...')
manpage_config.set('default_font_path', default_font_path)

# Include must come first, as it sets up dix-config.h
subdir('include')

# X server core
subdir('dix')
subdir('dri3')
subdir('glx')
subdir('fb')
subdir('mi')
subdir('os')
# X extensions
subdir('composite')
subdir('damageext')
subdir('dbe')
subdir('miext/damage')
subdir('miext/sync')
subdir('present')
subdir('randr')
subdir('record')
subdir('render')
subdir('xfixes')
subdir('xkb')
subdir('Xext')
subdir('Xi')
# other
if build_glamor
    subdir('glamor')
endif

# Common static libraries of all X servers
libxserver = [
    libxserver_mi,
    libxserver_dix,

    libxserver_composite,
    libxserver_damageext,
    libxserver_dbe,
    libxserver_randr,
    libxserver_miext_damage,
    libxserver_render,
    libxserver_present,
    libxserver_xext,
    libxserver_miext_sync,
    libxserver_xfixes,
    libxserver_xi,
    libxserver_xkb,
    libxserver_record,

    libxserver_os,
]

libxserver += libxserver_dri3

subdir('hw')

if host_machine.system() != 'windows'
    subdir('test')
endif

install_man(configure_file(
    input: 'man/Xserver.man',
    output: 'Xserver.1',
    configuration: manpage_config,
))