1version_split = meson.project_version().split('.') 2major = version_split[0].to_int() 3minor = version_split[1].to_int() 4patch = version_split[2].to_int() 5if version_split.length() == 4 6 subpatch = version_split[3].to_int() 7else 8 subpatch = 0 9endif 10 11release = major * 10000000 + minor * 100000 + patch * 1000 + subpatch 12 13dri_dep = dependency('dri', required: build_glx) 14 15conf_data = configuration_data() 16conf_data.set('_DIX_CONFIG_H_', '1') 17 18conf_data.set('HAVE_TYPEOF', cc.compiles(''' 19 int foo(int bar) { typeof(bar) baz = 1; return baz; } 20''', 21 name: 'typeof()')) 22 23conf_data.set('MONOTONIC_CLOCK', cc.has_function('clock_gettime') and 24cc.compiles(''' 25 #define _POSIX_C_SOURCE 200112L 26 #include <time.h> 27 #include <unistd.h> 28 #ifndef CLOCK_MONOTONIC 29 #error CLOCK_MONOTONIC not defined 30 #endif 31''', 32 name: 'CLOCK_MONOTONIC')) 33 34conf_data.set('XSERVER_DTRACE', with_dtrace) 35 36if host_machine.endian() == 'little' 37 conf_data.set('X_BYTE_ORDER', 'X_LITTLE_ENDIAN') 38else 39 conf_data.set('X_BYTE_ORDER', 'X_BIG_ENDIAN') 40endif 41 42glx_align64 = [] 43if cc.sizeof('unsigned long') == 8 44 conf_data.set('_XSERVER64', '1') 45 glx_align64 = '-D__GLX_ALIGN64' 46endif 47 48conf_data.set('_GNU_SOURCE', '1') 49 50# autoconf checks for /dev/xf86 here, but the test should be based on 51# the target, not the build system. Could we get rid of this and just 52# ifdef for openbsd? 53conf_data.set('HAS_APERTURE_DRV', host_machine.system() == 'openbsd') 54 55if get_option('input_thread') == 'false' 56 enable_input_thread = false 57else 58 enable_input_thread = cc.has_header_symbol('pthread.h', 59 'PTHREAD_MUTEX_RECURSIVE') 60 if not enable_input_thread and get_option('input_thread') == 'true' 61 error('Input thread enabled and PTHREAD_MUTEX_RECURSIVE not found') 62 endif 63 if host_machine.system() == 'windows' and get_option('input_thread') == 'auto' 64 enable_input_thread = false 65 endif 66endif 67conf_data.set('HAVE_INPUTTHREAD', enable_input_thread) 68 69if cc.compiles(''' 70 #define _GNU_SOURCE 1 71 #include <pthread.h> 72 void foo(int bar) { pthread_setname_np(pthread_self(), "example"); } 73''', 74 name: 'pthread_setname_np(tid, name)') 75 conf_data.set('HAVE_PTHREAD_SETNAME_NP_WITH_TID', 1) 76elif cc.compiles(''' 77 #define _GNU_SOURCE 1 78 #include <pthread.h> 79 void foo(int bar) { pthread_setname_np("example"); } 80''', 81 name: 'pthread_setname_np(name)') 82 conf_data.set('HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID', 1) 83endif 84 85conf_data.set('HAVE_LIBBSD', libbsd_dep.found()) 86# Note: this symbol is used by libXtrans. 87conf_data.set('HAVE_SYSTEMD_DAEMON', libsystemd_daemon_dep.found()) 88conf_data.set('CONFIG_UDEV', build_udev) 89conf_data.set('CONFIG_UDEV_KMS', build_udev_kms) 90conf_data.set('HAVE_DBUS', build_dbus) 91conf_data.set('CONFIG_HAL', build_hal) 92conf_data.set('SYSTEMD_LOGIND', build_systemd_logind) 93conf_data.set('NEED_DBUS', build_systemd_logind or build_hal) 94conf_data.set('CONFIG_WSCONS', host_machine.system() == 'openbsd') 95 96conf_data.set('HAVE_XSHMFENCE', xshmfence_dep.found()) 97conf_data.set('WITH_LIBDRM', libdrm_required) 98conf_data.set('GLAMOR_HAS_EGL_QUERY_DMABUF', 99 epoxy_dep.found() and epoxy_dep.version().version_compare('>= 1.4.4')) 100conf_data.set('GLAMOR_HAS_EGL_QUERY_DRIVER', 101 epoxy_dep.found() and epoxy_dep.version().version_compare('>= 1.5.4')) 102conf_data.set('GLXEXT', build_glx) 103conf_data.set('GLAMOR', build_glamor) 104conf_data.set('GLAMOR_HAS_GBM', gbm_dep.found()) 105conf_data.set('GLAMOR_HAS_GBM_LINEAR', 106 build_glamor and gbm_dep.found() and gbm_dep.version().version_compare('>= 10.6')) 107conf_data.set('GBM_BO_WITH_MODIFIERS', 108 build_glamor and gbm_dep.found() and gbm_dep.version().version_compare('>= 17.1')) 109 110conf_data.set_quoted('SERVER_MISC_CONFIG_PATH', serverconfigdir) 111conf_data.set_quoted('PROJECTROOT', get_option('prefix')) 112conf_data.set_quoted('SYSCONFDIR', join_paths(get_option('prefix'), get_option('sysconfdir'))) 113conf_data.set_quoted('SUID_WRAPPER_DIR', join_paths(get_option('prefix'), get_option('libexecdir'))) 114conf_data.set_quoted('COMPILEDDEFAULTFONTPATH', default_font_path) 115 116conf_data.set('XORG_VERSION_CURRENT', release) 117 118conf_data.set('HASXDMAUTH', has_xdm_auth) 119conf_data.set('SECURE_RPC', get_option('secure-rpc')) 120 121conf_data.set('HAVE_DLFCN_H', cc.has_header('dlfcn.h')) 122conf_data.set('HAVE_EXECINFO_H', cc.has_header('execinfo.h')) 123conf_data.set('HAVE_FCNTL_H', cc.has_header('fcntl.h')) 124conf_data.set('HAVE_FNMATCH_H', cc.has_header('fnmatch.h')) 125conf_data.set('HAVE_LINUX_AGPGART_H', cc.has_header('linux/agpgart.h')) 126conf_data.set('HAVE_STDLIB_H', cc.has_header('stdlib.h')) 127conf_data.set('HAVE_STRING_H', cc.has_header('string.h')) 128conf_data.set('HAVE_STRINGS_H', cc.has_header('strings.h')) 129conf_data.set('HAVE_SYS_AGPGART_H', cc.has_header('sys/agpgart.h')) 130conf_data.set('HAVE_SYS_AGPIO_H', cc.has_header('sys/agpio.h')) 131conf_data.set('HAVE_SYS_UTSNAME_H', cc.has_header('sys/utsname.h')) 132conf_data.set('HAVE_SYS_SYSMACROS_H', cc.has_header('sys/sysmacros.h')) 133conf_data.set('HAVE_UNISTD_H', cc.has_header('unistd.h')) 134 135conf_data.set('HAVE_ARC4RANDOM_BUF', cc.has_function('arc4random_buf', dependencies: libbsd_dep)) 136conf_data.set('HAVE_BACKTRACE', cc.has_function('backtrace')) 137conf_data.set('HAVE_CBRT', cc.has_function('cbrt')) 138conf_data.set('HAVE_EPOLL_CREATE1', cc.has_function('epoll_create1')) 139conf_data.set('HAVE_GETUID', cc.has_function('getuid')) 140conf_data.set('HAVE_GETEUID', cc.has_function('geteuid')) 141conf_data.set('HAVE_ISASTREAM', cc.has_function('isastream')) 142conf_data.set('HAVE_ISSETUGID', cc.has_function('issetugid')) 143conf_data.set('HAVE_GETIFADDRS', cc.has_function('getifaddrs')) 144conf_data.set('HAVE_GETPEEREID', cc.has_function('getpeereid')) 145conf_data.set('HAVE_GETPEERUCRED', cc.has_function('getpeerucred')) 146conf_data.set('HAVE_GETPROGNAME', cc.has_function('getprogname')) 147conf_data.set('HAVE_GETZONEID', cc.has_function('getzoneid')) 148conf_data.set('HAVE_MEMFD_CREATE', cc.has_function('memfd_create')) 149conf_data.set('HAVE_MKOSTEMP', cc.has_function('mkostemp')) 150conf_data.set('HAVE_MMAP', cc.has_function('mmap')) 151conf_data.set('HAVE_POLL', cc.has_function('poll')) 152conf_data.set('HAVE_POLLSET_CREATE', cc.has_function('pollset_create')) 153conf_data.set('HAVE_POSIX_FALLOCATE', cc.has_function('posix_fallocate')) 154conf_data.set('HAVE_PORT_CREATE', cc.has_function('port_create')) 155conf_data.set('HAVE_REALLOCARRAY', cc.has_function('reallocarray', dependencies: libbsd_dep)) 156conf_data.set('HAVE_SETEUID', cc.has_function('seteuid')) 157conf_data.set('HAVE_SETITIMER', cc.has_function('setitimer')) 158conf_data.set('HAVE_SHMCTL64', cc.has_function('shmctl64')) 159conf_data.set('HAVE_SIGACTION', cc.has_function('sigaction')) 160conf_data.set('HAVE_SIGPROCMASK', cc.has_function('sigprocmask')) 161conf_data.set('HAVE_STRCASECMP', cc.has_function('strcasecmp')) 162conf_data.set('HAVE_STRCASESTR', cc.has_function('strcasestr')) 163conf_data.set('HAVE_STRLCAT', cc.has_function('strlcat', dependencies: libbsd_dep)) 164conf_data.set('HAVE_STRLCPY', cc.has_function('strlcpy', dependencies: libbsd_dep)) 165conf_data.set('HAVE_STRNCASECMP', cc.has_function('strncasecmp')) 166conf_data.set('HAVE_STRNDUP', cc.has_function('strndup') and cc.has_header_symbol('string.h', 'strndup')) 167conf_data.set('HAVE_TIMINGSAFE_MEMCMP', cc.has_function('timingsafe_memcmp')) 168conf_data.set('HAVE_VASPRINTF', cc.has_function('vasprintf')) 169conf_data.set('HAVE_VSNPRINTF', cc.has_function('vsnprintf')) 170conf_data.set('HAVE_WALKCONTEXT', cc.has_function('walkcontext')) 171 172conf_data.set('BUSFAULT', conf_data.get('HAVE_SIGACTION')) 173 174# Don't let X dependencies typedef 'pointer' 175conf_data.set('_XTYPEDEF_POINTER', '1') 176conf_data.set('_XITYPEDEF_POINTER', '1') 177 178conf_data.set('LISTEN_TCP', get_option('listen_tcp')) 179conf_data.set('LISTEN_UNIX', get_option('listen_unix')) 180conf_data.set('LISTEN_LOCAL', get_option('listen_local')) 181 182if cc.has_header_symbol('sys/socket.h', 'SCM_RIGHTS') 183 conf_data.set('XTRANS_SEND_FDS', '1') 184endif 185 186if not conf_data.get('HAVE_GETPEEREID') and not conf_data.get('HAVE_GETPEERUCRED') 187 if not cc.has_header_symbol('sys/socket.h', 'SO_PEERCRED') 188 conf_data.set('NO_LOCAL_CLIENT_CRED', 1) 189 endif 190endif 191 192conf_data.set('TCPCONN', '1') 193conf_data.set('UNIXCONN', host_machine.system() != 'windows') 194conf_data.set('IPv6', build_ipv6) 195 196conf_data.set('BIGREQS', '1') 197conf_data.set('COMPOSITE', '1') 198conf_data.set('DAMAGE', '1') 199conf_data.set('DBE', '1') 200conf_data.set('DGA', build_dga) 201conf_data.set('DPMSExtension', build_dpms) 202conf_data.set('DRI2', build_dri2) 203conf_data.set('DRI3', build_dri3) 204if build_glx 205 conf_data.set_quoted('DRI_DRIVER_PATH', dri_dep.get_pkgconfig_variable('dridriverdir')) 206endif 207conf_data.set('HAS_SHM', build_mitshm) 208conf_data.set('MITSHM', build_mitshm) 209conf_data.set('PANORAMIX', build_xinerama) 210conf_data.set('PRESENT', '1') 211conf_data.set('RANDR', '1') 212conf_data.set('RES', build_res) 213conf_data.set('RENDER', '1') 214conf_data.set('SCREENSAVER', build_screensaver) 215conf_data.set('SHAPE', '1') 216conf_data.set('XACE', build_xace) 217conf_data.set('XCMISC', '1') 218conf_data.set('XCSECURITY', build_xsecurity) 219conf_data.set('XDMCP', xdmcp_dep.found()) 220conf_data.set('XF86BIGFONT', build_xf86bigfont) 221conf_data.set('XF86DRI', build_dri1) 222conf_data.set('XF86VIDMODE', 1) 223conf_data.set('XFIXES', '1') 224conf_data.set('XFreeXDGA', build_dga) 225conf_data.set('XINERAMA', build_xinerama) 226conf_data.set('XINPUT', '1') 227conf_data.set('XRECORD', '1') 228conf_data.set('XSELINUX', build_xselinux) 229conf_data.set('XSYNC', '1') 230conf_data.set('XTEST', '1') 231conf_data.set('XV', build_xv) 232conf_data.set('XvExtension', build_xv) 233conf_data.set('XvMCExtension', build_xvmc) 234 235conf_data.set('HAVE_SHA1_IN_' + sha1.to_upper(), '1', description: 'Use @0@ SHA1 functions'.format(sha1)) 236conf_data.set('HAVE_LIBUNWIND', get_option('libunwind')) 237 238conf_data.set('HAVE_APM', build_apm or build_acpi) 239conf_data.set('HAVE_ACPI', build_acpi) 240 241enable_debugging = get_option('buildtype') == 'debug' 242conf_data.set('DEBUG', enable_debugging) 243 244conf_data.set_quoted('XVENDORNAME', get_option('vendor_name')) 245conf_data.set_quoted('XVENDORNAMESHORT', get_option('vendor_name_short')) 246conf_data.set_quoted('__VENDORDWEBSUPPORT__', get_option('vendor_web')) 247conf_data.set_quoted('BUILDERADDR', get_option('builder_addr')) 248conf_data.set_quoted('BUILDERSTRING', get_option('builder_string')) 249 250if build_rootless 251 conf_data.set('ROOTLESS', build_rootless) 252 conf_data.set('ROOTLESS_WORKAROUND', 1) 253 conf_data.set('ROOTLESS_SAFEALPHA', 1) 254endif 255 256# 257# for xorg-server.h only 258# 259defines_svr4 = '''#if !defined(SVR4) && !defined(__svr4__) && !defined(__SVR4) 260#error "I am not SVR4" 261#endif 262''' 263 264# BSD specifics 265supports_pccons = false 266supports_pcvt = false 267supports_syscons = false 268supports_wscons = false 269csrg_based = false 270 271if host_machine.system() == 'freebsd' or host_machine.system() == 'dragonflybsd' 272 supports_pccons = true 273 supports_pcvt = true 274 supports_syscons = true 275 csrg_based = true 276endif 277 278if host_machine.system() == 'kfreebsd' 279 supports_pccons = true 280 supports_pcvt = true 281 supports_syscons = true 282endif 283 284if host_machine.system() == 'netbsd' 285 supports_pccons = true 286 supports_pcvt = true 287 supports_wscons = true 288 csrg_based = true 289endif 290 291if host_machine.system() == 'openbsd' 292 supports_pcvt = true 293 supports_wscons = true 294 csrg_based = true 295endif 296 297if host_machine.system() == 'darwin' 298 csrg_based = true 299endif 300 301conf_data.set('SVR4', cc.compiles(defines_svr4)) 302conf_data.set_quoted('XKB_DFLT_RULES', get_option('xkb_default_rules')) 303conf_data.set('XORGSERVER', build_xorg) 304conf_data.set_quoted('XCONFIGFILE', 'xorg.conf') 305conf_data.set_quoted('__XSERVERNAME__', 'Xorg') 306conf_data.set('WITH_VGAHW', build_vgahw) 307conf_data.set('CSRG_BASED', csrg_based) 308conf_data.set('PCCONS_SUPPORT', supports_pccons) 309conf_data.set('PCVT_SUPPORT', supports_pcvt) 310conf_data.set('SYSCONS_SUPPORT', supports_syscons) 311conf_data.set('WSCONS_SUPPORT', supports_wscons) 312conf_data.set('XSERVER_LIBPCIACCESS', get_option('pciaccess')) 313conf_data.set('XSERVER_PLATFORM_BUS', build_udev_kms) 314 315configure_file(output : 'dix-config.h', 316 configuration : conf_data) 317 318configure_file(output : 'xorg-server.h', 319 input : 'xorg-server.h.meson.in', 320 configuration : conf_data, 321 install_dir: xorgsdkdir) 322 323version_data = configuration_data() 324version_data.set('VENDOR_RELEASE', '@0@'.format(release)) 325version_data.set_quoted('VENDOR_NAME', get_option('vendor_name')) 326version_data.set_quoted('VENDOR_NAME_SHORT', get_option('vendor_name_short')) 327version_data.set_quoted('VENDOR_WEB', get_option('vendor_web')) 328version_data.set_quoted('VENDOR_MAN_VERSION', 'Version @0@.@1@.@2@'.format(major, minor, patch)) 329configure_file(output : 'version-config.h', 330 configuration : version_data) 331 332xkb_data = configuration_data() 333 334xkb_data.set_quoted('XKB_BIN_DIRECTORY', xkb_bin_dir) 335xkb_data.set_quoted('XKB_BASE_DIRECTORY', xkb_dir) 336xkb_data.set_quoted('XKB_DFLT_RULES', get_option('xkb_default_rules')) 337xkb_data.set_quoted('XKB_DFLT_MODEL', get_option('xkb_default_model')) 338xkb_data.set_quoted('XKB_DFLT_LAYOUT', get_option('xkb_default_layout')) 339xkb_data.set_quoted('XKB_DFLT_VARIANT', get_option('xkb_default_variant')) 340xkb_data.set_quoted('XKB_DFLT_OPTIONS', get_option('xkb_default_options')) 341xkb_data.set_quoted('XKM_OUTPUT_DIR', xkb_output_dir) 342 343configure_file(output : 'xkb-config.h', 344 configuration : xkb_data) 345 346xorg_data = configuration_data() 347 348xorg_data.set_quoted('XORG_BIN_DIRECTORY', get_option('bindir')) 349xorg_data.set('XORG_VERSION_CURRENT', release) 350xorg_data.set_quoted('XF86CONFIGFILE', 'xorg.conf') 351xorg_data.set_quoted('XCONFIGFILE', 'xorg.conf') 352xorg_data.set_quoted('XCONFIGDIR', 'xorg.conf.d') 353xorg_data.set_quoted('DEFAULT_XDG_DATA_HOME', '.local/share') 354xorg_data.set_quoted('DEFAULT_XDG_DATA_HOME_LOGDIR', 'xorg') 355xorg_data.set_quoted('DEFAULT_LOGDIR', log_dir) 356xorg_data.set_quoted('DEFAULT_LOGPREFIX', 'Xorg.') 357xorg_data.set_quoted('DEFAULT_MODULE_PATH', join_paths(get_option('prefix'), module_dir)) 358xorg_data.set_quoted('DEFAULT_LIBRARY_PATH', join_paths(get_option('prefix'), get_option('libdir'))) 359xorg_data.set_quoted('__XSERVERNAME__', 'Xorg') 360xorg_data.set('XSERVER_LIBPCIACCESS', get_option('pciaccess')) 361xorg_data.set_quoted('PCI_TXT_IDS_PATH', '') 362xorg_data.set('XSERVER_PLATFORM_BUS', build_udev_kms) 363xorg_data.set('WSCONS_SUPPORT', host_machine.system() == 'netbsd' or host_machine.system() == 'openbsd') 364xorg_data.set('HAVE_STROPTS_H', cc.has_header('stropts.h')) 365xorg_data.set('HAVE_SYS_KD_H', cc.has_header('sys/kd.h')) 366xorg_data.set('HAVE_SYS_VT_H', cc.has_header('sys/vt.h')) 367 368if host_machine.system() == 'freebsd' or host_machine.system() == 'dragonflybsd' 369 if host_machine.cpu_family() == 'x86' or host_machine.cpu_family() == 'x86_64' 370 xorg_data.set('USE_DEV_IO', true) 371 endif 372elif host_machine.system() == 'netbsd' 373 if host_machine.cpu_family() == 'x86' or host_machine.cpu_family() == 'x86_64' 374 xorg_data.set('USE_I386_IOPL', true) 375 endif 376elif host_machine.system() == 'openbsd' 377 if host_machine.cpu_family() == 'x86' 378 xorg_data.set('USE_I386_IOPL', true) 379 endif 380 if host_machine.cpu_family() == 'x86_64' 381 xorg_data.set('USE_AMD64_IOPL', true) 382 endif 383endif 384 385configure_file(output : 'xorg-config.h', 386 input : 'xorg-config.h.meson.in', 387 configuration : xorg_data) 388 389xwin_data = configuration_data() 390xwin_data.set_quoted('DEFAULT_LOGDIR', log_dir) 391xwin_data.set('HAS_WINSOCK', host_machine.system() == 'windows', description: 'Use Windows sockets') 392xwin_data.set('HAS_DEVWINDOWS', host_machine.system() == 'cygwin', description: 'Has /dev/windows for signaling new win32 messages') 393xwin_data.set('RELOCATE_PROJECTROOT', host_machine.system() == 'windows', description: 'Make paths relative to the xserver installation location') 394# XXX: these three are all the same as DEBUG so we should just change to that 395xwin_data.set10('CYGDEBUG', enable_debugging) 396xwin_data.set10('CYGWINDOWING_DEBUG',enable_debugging) 397xwin_data.set10('CYGMULTIWINDOW_DEBUG', enable_debugging) 398 399configure_file(output : 'xwin-config.h', 400 input : 'xwin-config.h.meson.in', 401 configuration : xwin_data) 402 403xwayland_data = configuration_data() 404xwayland_data.set('XWL_HAS_GLAMOR', build_glamor and (gbm_dep.found() or build_eglstream)) 405xwayland_data.set('XWL_HAS_EGLSTREAM', build_eglstream) 406 407configure_file(output : 'xwayland-config.h', 408 input : 'xwayland-config.h.meson.in', 409 configuration : xwayland_data) 410 411dtrace_hdr = [] 412dtrace_tmpl = files('Xserver.d') 413if with_dtrace 414 dtrace_header = generator(dtrace, 415 output: '@BASENAME@-dtrace.h', 416 arguments: ['-h', '-s', '@INPUT@', '-o', '@OUTPUT@'] 417 ) 418 419 dtrace_hdr += dtrace_header.process(dtrace_tmpl) 420endif 421 422if build_xorg 423 install_data( 424 [ 425 'XIstubs.h', 426 'Xprintf.h', 427 'callback.h', 428 'client.h', 429 'closestr.h', 430 'closure.h', 431 'colormap.h', 432 'colormapst.h', 433 'hotplug.h', 434 'cursor.h', 435 'cursorstr.h', 436 'dix.h', 437 'dixaccess.h', 438 'dixevents.h', 439 'dixfont.h', 440 'dixfontstr.h', 441 'dixgrabs.h', 442 'dixstruct.h', 443 'events.h', 444 'exevents.h', 445 'extension.h', 446 'extinit.h', 447 'extnsionst.h', 448 'fourcc.h', 449 'gc.h', 450 'gcstruct.h', 451 'globals.h', 452 'glx_extinit.h', 453 'glxvndabi.h', 454 'input.h', 455 'inputstr.h', 456 'list.h', 457 'misc.h', 458 'miscstruct.h', 459 'opaque.h', 460 'nonsdk_extinit.h', 461 'optionstr.h', 462 'os.h', 463 'pixmap.h', 464 'pixmapstr.h', 465 'privates.h', 466 'property.h', 467 'propertyst.h', 468 'ptrveloc.h', 469 'region.h', 470 'regionstr.h', 471 'registry.h', 472 'resource.h', 473 'rgb.h', 474 'screenint.h', 475 'scrnintstr.h', 476 'selection.h', 477 'servermd.h', 478 'validate.h', 479 'displaymode.h', 480 'window.h', 481 'windowstr.h', 482 'xkbfile.h', 483 'xkbsrv.h', 484 'xkbstr.h', 485 'xkbrules.h', 486 'Xprintf.h', 487 'xserver_poll.h', 488 'xserver-properties.h', 489 ], 490 install_dir: xorgsdkdir, 491 ) 492endif 493