Commit 781fd07e authored by Ville Syrjälä's avatar Ville Syrjälä Committed by Chris Wilson

meson: Add meson build system

Allow building the driver with meson. Could probably use
plenty of cleanups, but at least it gives me a working driver.
And I think I managed to make it build everything that
autotools builds.

Quite a few compiler warnings were suppressed as well. Might
want to look at those at some point.
Signed-off-by: Ville Syrjälä's avatarVille Syrjälä <ville.syrjala@linux.intel.com>
parent a3a9e99b
configure_file(input : 'intel.man',
output : 'intel.4',
command : [
'sed',
'-e',
's/__appmansuffix__/@0@/g'.format(man_config.get('appmansuffix')),
'-e',
's/__filemansuffix__/@0@/g'.format(man_config.get('filemansuffix')),
'-e',
's/__drivermansuffix__/@0@/g'.format(man_config.get('drivermansuffix')),
'-e',
's/__miscmansuffix__/@0@/g'.format(man_config.get('miscmansuffix')),
'-e',
's/__xservername__/@0@/g'.format(man_config.get('xservername')),
'-e',
's/__xconfigfile__/@0@/g'.format(man_config.get('xconfigfile')),
'-e',
's/__vendorversion__/@0@/g'.format(man_config.get('vendorversion')),
'@INPUT@'
],
capture : true,
install_dir: join_paths(get_option('mandir'), 'man4'),
install : true)
project('xf86-video-intel', 'c',
version : '2.99.917',
default_options: [
'warning_level=2',
'c_std=gnu99',
],
license : 'MIT',
meson_version : '>0.40.0')
config = configuration_data()
version = meson.project_version().split('.')
config.set('PACKAGE_VERSION_MAJOR', version[0])
config.set('PACKAGE_VERSION_MINOR', version[1])
config.set('PACKAGE_VERSION_PATCHLEVEL', version[2])
config.set_quoted('LIBEXEC_PATH', join_paths(get_option('prefix'),
get_option('libexecdir')))
cc = meson.get_compiler('c')
xorg = dependency('xorg-server', version : '>= 1.6', required : true)
pthreads = dependency('threads', required : true)
pciaccess = dependency('pciaccess', version : '>= 0.10', required : true)
x11 = dependency('x11', required : false)
xfixes = dependency('xfixes', required : false)
png = dependency('libpng', required : false)
if not cc.has_function('clock_gettime', args : '-lrt')
error('clock_gettime() missing')
endif
if cc.has_function('getline')
config.set('HAVE_GETLINE', 1)
endif
if cc.has_function('strndup')
config.set('HAVE_STRNDUP', 1)
endif
if cc.has_function('strcasecmp')
config.set('HAVE_STRCASECMP', 1)
endif
dependency('xproto', required : true)
dependency('fontsproto', required : true)
dependency('damageproto', required : true)
if cc.has_header_symbol('xorg-server.h', 'RANDR',
dependencies : xorg)
dependency('randrproto', required : true)
endif
if cc.has_header_symbol('xorg-server.h', 'RENDER',
dependencies : xorg)
dependency('renderproto', required : true)
endif
if cc.has_header_symbol('xorg-server.h', 'DPMSExtension',
dependencies : xorg)
dependency('xextproto', required : true)
endif
with_tools = get_option('tools')
config.set('USE_GIT_DESCRIBE', 1)
config.set('BUILDER_DESCRIPTION', 1)
atomic_primitives = 'none'
atomic_primitives_code = '''
int atomic_add(int i) {
return __sync_fetch_and_add (&i, 1);
}
int atomic_cmpxchg(int i, int j, int k) {
return __sync_val_compare_and_swap (&i, j, k);
}
int main(void) {
return 0;
}'''
if cc.links(atomic_primitives_code, name : 'atomic primitives')
atomic_primitives = 'intel'
config.set('HAVE_ATOMIC_PRIMITIVES', 1)
endif
if atomic_primitives == 'none' and cc.has_header('atomic_ops.h')
atomic_primitives = 'libatomic-ops'
config.set('HAVE_LIB_ATOMIC_OPS', 1)
endif
if atomic_primitives == 'none'
error('xf86-video-intel depends upon atomic operations, which were not found for your compiler/cpu. Try compiling with -march=native, or install the libatomics-op-dev package.')
endif
libudev = dependency('libudev', required : false)
if libudev.found()
config.set('HAVE_UDEV', 1)
endif
cpuid_code = '''
#include <cpuid.h>
#include <stddef.h>
int main(void) {
int eax, ebx, ecx, edx;
if (__get_cpuid_max(0, NULL) < 4)
return 0;
__cpuid_count(4, 0, eax, ebx, ecx, edx);
return 0;
}'''
if cc.links(cpuid_code, name : '__cpuid()')
config.set('HAVE_CPUID_H', 1)
endif
has_shm = (cc.has_header('sys/ipc.h') and
cc.has_header('X11/extensions/XShm.h') and
cc.has_header('X11/extensions/shmproto.h') and
cc.has_header('X11/extensions/shmstr.h'))
if has_shm
config.set('HAVE_MIT_SHM', 1)
config.set('HAVE_X11_EXTENSIONS_SHMPROTO_H', 1)
config.set('HAVE_X11_EXTENSIONS_SHMSTR_H', 1)
endif
if cc.has_header('X11/extensions/Xinerama.h')
config.set('HAVE_X11_EXTENSIONS_XINERAMA_H', 1)
endif
if cc.has_header('X11/extensions/dpmsconst.h')
config.set('HAVE_X11_EXTENSIONS_DPMSCONST_H', 1)
endif
pixman = dependency('pixman-1', version : '>= 0.16.0', required : true)
if pixman.version() >= '0.24.0'
config.set('HAS_PIXMAN_TRIANGLES', 1)
endif
if pixman.version() >= '0.27.1'
config.set('HAS_PIXMAN_GLYPHS', 1)
endif
with_kms = get_option('kms')
if with_kms
config.set('KMS', 1)
endif
with_ums = get_option('ums')
if with_ums
has_ums = cc.has_header('vgaHW.h',
dependencies : xorg)
# Currently 'required' doesn't work for cc.has_header() & co.
if not has_ums
error('UMS dependencies not met')
endif
config.set('UMS', 1)
endif
with_xvmc = get_option('xvmc')
if with_xvmc
dependency('xvmc', required : true)
dependency('dri2proto', required : true)
dependency('x11', required : true)
dependency('x11-xcb', required : true)
dependency('xcb-dri2', required : true)
dependency('xcb-aux', required : true)
dependency('libdrm_intel', required : true)
config.set('ENABLE_XVMC', 1)
endif
with_valgrind = get_option('valgrind')
if with_valgrind
message('Checking Valgrind support')
valgrind = dependency('valgrind', required : true)
config.set('HAVE_VALGRIND', 1)
endif
inc = include_directories([ '.', 'src', 'xvmc', 'src/render_program', ])
add_project_arguments('-include', 'config.h', language : 'c')
man_config = configuration_data()
man_config.set('appmansuffix', '1')
man_config.set('filemansuffix', '5')
man_config.set('drivermansuffix', '4')
man_config.set('miscmansuffix', '7')
man_config.set('xservername',
cc.get_define('__XSERVERNAME__',
prefix : '#include <xorg-server.h>',
dependencies : xorg))
man_config.set('xconfigfile',
cc.get_define('__XCONFIGFILE____',
prefix : '#include <xorg-server.h>',
dependencies : xorg))
man_config.set('vendorversion', '"@0@ @1@" "@2@"'.format(meson.project_name(),
meson.project_version(),
'X Version 11'))
subdir('src')
subdir('tools')
if with_xvmc
subdir('xvmc')
endif
subdir('man')
configure_file(output: 'config.h', install: false, configuration: config)
option('sna', type : 'boolean', value : true,
description : 'Build with SNA support')
option('uxa', type : 'boolean', value : true,
description : 'Build with UXA support')
option('xaa', type : 'boolean', value : true,
description : 'Build with XAA support')
option('ums', type : 'boolean', value : true,
description : 'Build with UMS support')
option('kms', type : 'boolean', value : true,
description : 'Build with KMS support')
option('dri1', type : 'boolean', value : true,
description : 'Build DRI1 support')
option('dri2', type : 'boolean', value : true,
description : 'Build with DRI2 support')
option('dri3', type : 'boolean', value : true,
description : 'Build with DRI3 support')
option('present', type : 'boolean', value : true,
description : 'Enable Present support')
option('xvmc', type : 'boolean', value : true,
description : 'Enable XvMC support')
option('valgrind', type : 'boolean', value : true,
description : 'Enable valgrindified ioctls for debugging')
option('default-dri', type : 'combo', value : '2', choices : [ '1', '2', '3' ],
description : 'Select the default maximum DRI level')
option('default-accel', type : 'combo', value : 'sna', choices : [ 'sna', 'uxa', 'none' ],
description : 'Select the default acceleration method')
option('tools', type : 'boolean', value : true,
description : 'Enable building and installing the miscellaneous tools')
option('backlight', type : 'boolean', value : true,
description : 'Enable control of the backlight')
option('backlight-helper', type : 'boolean', value : true,
description : 'Enable building the backlight helper executable for running X under a normal user')
option('tearfree', type : 'boolean', value : false,
description : 'Enable use of TearFree by default')
option('use-create2', type : 'boolean', value : false,
description : 'Enable use of create2 ioctl (experimental)')
option('async-swap', type : 'boolean', value : false,
description : 'Enable use of asynchronous swaps (experimental)')
option('debug', type : 'combo', value : 'no', choices : [ 'no', 'sync', 'memory', 'pixmap', 'full' ],
description : 'Enable internal debugging')
option('xorg-module-dir', type : 'string', value : '@libdir@/xorg/modules',
description : 'Default xorg module directory')
i810_sources = [
'i810_accel.c',
'i810_cursor.c',
'i810_driver.c',
'i810_memory.c',
'i810_video.c',
'i810_wmark.c',
]
xorg = dependency('xorg-server', required : true)
i810_deps = [
dependency('libdrm', required : true),
dependency('pciaccess', required : true),
xorg,
]
if cc.has_header('xaa.h', dependencies : xorg)
config.set('HAVE_XAA_H', 1)
i810_sources += 'i810_xaa.c'
endif
if cc.has_header('dgaproc.h', dependencies : xorg)
config.set('HAVE_DGAPROC_H', 1)
i810_sources += 'i810_dga.c'
endif
if with_dri1
i810_sources += 'i810_dri.c'
i810_deps += dependency('xf86driproto', required : true)
if with_xvmc
i810_sources += 'i810_hwmc.c'
endif
endif
i810 = static_library('legacy_i810',
sources : i810_sources,
dependencies : i810_deps,
include_directories : inc,
c_args : [
'-Wno-unused-parameter',
'-Wno-sign-compare',
],
install : false)
if with_xvmc
subdir('xvmc')
endif
shared_library('I810XvMC',
soversion : '1',
version : '1.0.0',
sources : 'I810XvMC.c',
dependencies : [
dependency('x11', required : true),
dependency('xvmc', required : true),
dependency('xorg-server', required : true),
dependency('libdrm', required : true),
],
c_args : [
'-Wno-unused-parameter',
'-Wno-sign-compare',
],
install : true)
xorg = dependency('xorg-server', required : true)
libdrm = dependency('libdrm', required : true)
pixman = dependency('pixman-1', required : true)
with_dri1 = get_option('dri1')
if with_dri1
dri1 = dependency('xf86driproto', required : true)
has_dri1 = (cc.has_header('dri.h', dependencies : xorg) and
cc.has_header('sarea.h', dependencies : xorg) and
cc.has_header('dristruct.h', dependencies : xorg))
# Currently 'required' doesn't work for cc.has_header() & co.
if not has_dri1
error('DRI1 dependencies not met')
endif
config.set('HAVE_DRI1', 1)
endif
with_dri2 = get_option('dri2')
if with_dri2
dri2 = dependency('dri2proto', version : '>= 2.6', required : true)
dri = dependency('dri', required : false)
if dri.found()
dridriverdir = dri.get_pkgconfig_variable('dridriverdir')
else
dridriverdir = join_paths(get_option('libdir'), 'dri')
endif
config.set('HAVE_DRI2', 1)
config.set_quoted('DRI_DRIVER_PATH', dridriverdir)
endif
with_dri3 = get_option('dri3')
if with_dri3
dri3 = dependency('dri3proto', required : true)
has_dri3 = (cc.has_header_symbol('xorg-server.h', 'DRI3',
dependencies : xorg) and
cc.has_header('misyncstr.h',
dependencies : xorg) and
cc.has_header('misyncshm.h',
dependencies : xorg))
# Currently 'required' doesn't work for cc.has_header() & co.
if not has_dri3
error('DRI3 dependencies not met')
endif
config.set('HAVE_DRI3', 1)
endif
default_dri = get_option('default-dri')
config.set('DEFAULT_DRI_LEVEL', default_dri)
present = dependency('presentproto', required : false)
has_present = (present.found() and
cc.has_header('present.h', dependencies : xorg))
if has_present
config.set('HAVE_PRESENT', 1)
endif
if get_option('backlight')
config.set('USE_BACKLIGHT', 1)
endif
with_backlight_helper = get_option('backlight-helper')
if with_backlight_helper
config.set('USE_BACKLIGHT_HELPER', 1)
endif
debug = get_option('debug')
if debug == 'sync'
config.set('DEBUG_SYNC', 1)
endif
if debug == 'memory' or debug == 'full'
config.set('DEBUG_MEMORY', 1)
endif
if debug == 'pixmap' or debug == 'full'
config.set('DEBUG_PIXMAP', 1)
endif
if debug == 'full'
config.set('HAS_DEBUG_FULL', 1)
endif
intel_drv_sources = [
'backlight.c',
'fd.c',
'intel_device.c',
'intel_options.c',
'intel_module.c',
]
intel_drv_deps = [
dependency('pciaccess', version : '>= 0.10', required : true),
xorg,
]
intel_drv_libs = []
if with_ums
subdir('legacy/i810')
intel_drv_libs += i810
endif
default_accel = get_option('default-accel')
with_sna = get_option('sna')
if with_sna
subdir('sna')
intel_drv_libs += sna
elif default_accel == 'sna'
error('SNA not available, so can\'t selected as the default acceleration method')
endif
with_uxa = get_option('uxa')
if with_uxa
subdir('uxa')
intel_drv_libs += uxa
elif default_accel == 'uxa'
error('UXA not available, so can\'t selected as the default acceleration method')
endif
if default_accel == 'sna'
config.set('DEFAULT_ACCEL_METHOD', 'SNA')
elif default_accel == 'uxa'
config.set('DEFAULT_ACCEL_METHOD', 'UXA')
else
config.set('DEFAULT_ACCEL_METHOD', 'NOACCEL')
endif
if with_valgrind
intel_drv_deps += valgrind
endif
xorg_moduledir = get_option('xorg-module-dir')
moduledir = ''
foreach dir : xorg_moduledir.split('/')
if dir == '@libdir@'
dir = get_option('libdir')
endif
moduledir = join_paths(moduledir, dir)
endforeach
shared_module('intel_drv',
sources : intel_drv_sources,
dependencies : intel_drv_deps,
link_with : intel_drv_libs,
c_args : [
'-DMAJOR_IN_SYSMACROS',
'-Wno-unused-parameter',
'-Wno-sign-compare',
'-Wno-missing-field-initializers',
],
name_prefix : '',
install_dir : join_paths(moduledir, 'drivers'),
install : true)
brw_deps = [
xorg,
libudev,
libdrm,
]
if with_valgrind
brw_deps += valgrind
endif
brw = static_library('brw',
sources : [
'brw_disasm.c',
'brw_eu.c',
'brw_eu_emit.c',
'brw_sf.c',
'brw_wm.c',
],
dependencies : brw_deps,
include_directories : inc,
c_args : [
'-Wno-unused-parameter',
'-Wno-sign-compare',
],
install : false)
executable('brw_test',
sources : [
'brw_test.c',
'brw_test_gen4.c',
'brw_test_gen5.c',
'brw_test_gen6.c',
'brw_test_gen7.c',
],
link_with : brw,
include_directories : inc,
c_args : [
'-Wno-unused-const-variable',
'-Wno-unused-parameter',
],
install : false)
fb = static_library('fb',
sources : [
'fbarc.c',
'fbbitmap.c',
'fbblt.c',
'fbbltone.c',
'fbclip.c',
'fbcopy.c',
'fbfill.c',
'fbgc.c',
'fbglyph.c',
'fbimage.c',
'fbline.c',
'fbpict.c',
'fbpoint.c',
'fbpush.c',
'fbseg.c',
'fbspan.c',
'fbstipple.c',
'fbtile.c',
'fbutil.c',
],
dependencies : [
xorg,
pixman,
],
c_args : [
'-Wno-unused-parameter',
'-Wno-sign-compare',
],
install : false)
static const char git_version[] = "@VCS_TAG@";
config.set('USE_SNA', 1)
if cc.has_member('struct sysinfo', 'totalram',
prefix : '#include <sys/sysinfo.h>')
config.set('HAVE_STRUCT_SYSINFO_TOTALRAM', 1)
endif
git_version_h = vcs_tag(input : 'git_version.h.in', output : 'git_version.h',
fallback : 'not compiled from git',
command : [ 'git', 'describe' ] )
config.set('HAVE_DOT_GIT', 1)
if cc.has_header('alloca.h')
config.set('HAVE_ALLOCA_H', 1)
endif
sna_deps = [
cc.find_library('m', required : true),
dependency('threads', required : true),
dependency('xorg-server', required : true),
dependency('libdrm', required : true),
]
sna_sources = [
'blt.c',
'kgem.c',
'sna_accel.c',
'sna_acpi.c',
'sna_blt.c',
'sna_composite.c',
'sna_cpu.c',
'sna_damage.c',
'sna_display.c',
'sna_display_fake.c',
'sna_driver.c',
'sna_glyphs.c',
'sna_gradient.c',
'sna_io.c',
'sna_render.c',
'sna_stream.c',
'sna_trapezoids.c',
'sna_trapezoids_boxes.c',
'sna_trapezoids_imprecise.c',
'sna_trapezoids_mono.c',
'sna_trapezoids_precise.c',
'sna_tiling.c',
'sna_transform.c',
'sna_threads.c',
'sna_vertex.c',
'sna_video.c',
'sna_video_overlay.c',
'sna_video_sprite.c',
'sna_video_textured.c',
'gen2_render.c',
'gen3_render.c',
'gen4_common.c',
'gen4_render.c',
'gen4_source.c',
'gen4_vertex.c',
'gen5_render.c',
'gen6_common.c',
'gen6_render.c',
'gen7_render.c',
'gen8_eu.c',
'gen8_render.c',
'gen8_vertex.c',
'gen9_render.c',
]
if libudev.found()
sna_deps += libudev
endif
if with_valgrind
sna_deps += valgrind
endif
if with_dri2
sna_sources += 'sna_dri2.c'
sna_deps += [
dependency('dri2proto', required : true),
cc.find_library('rt', required : true),
]
endif
if with_dri3
sna_sources += 'sna_dri3.c'
sna_deps += dri3
endif
if has_present
sna_sources += 'sna_present.c'
sna_deps += present
endif
if with_xvmc
sna_sources += 'sna_video_hwmc.c'
endif
if debug == 'full'
sna_sources += [
'kgem_debug.c',
'kgem_debug_gen2.c',
'kgem_debug_gen3.c',
'kgem_debug_gen4.c',
'kgem_debug_gen5.c',
'kgem_debug_gen6.c',
'kgem_debug_gen7.c',
]
endif
if get_option('tearfree')
config.set('TEARFREE', 1)
endif
if get_option('use-create2')
config.set('USE_CREATE2', 1)
endif
if get_option('async-swap')
config.set('USE_ASYNC_SWAP', 1)
endif
subdir('brw')
subdir('fb')
sna = static_library('sna',
[ git_version_h, sna_sources ],
dependencies : sna_deps,
link_with : [ brw, fb, ],
include_directories : inc,
c_args : [
'-Wno-missing-field-initializers',
'-Wno-unused-but-set-variable',
'-Wno-shift-negative-value',
'-Wno-unused-parameter',
'-Wno-sign-compare',
'-Wno-type-limits',
],
install : false)
config.set('USE_UXA', 1)
uxa_sources = [
'intel_batchbuffer.c',
'intel_display.c',
'intel_driver.c',
'intel_memory.c',
'intel_uxa.c',
'intel_video.c',
'intel_video_overlay.c',
'intel_uxa_video.c',
'i830_3d.c',
'i830_render.c',
'i915_3d.c',
'i915_render.c',
'i915_video.c',
'i965_3d.c',
'i965_video.c',
'i965_render.c',
'uxa.c',
'uxa-accel.c',
'uxa-glyphs.c',
'uxa-render.c',
'uxa-unaccel.c',
]
uxa_deps = [
dependency('xorg-server', version : '>= 1.6', required : true),
dependency('pixman-1', version : '>= 0.24.0', required : true),
dependency('libdrm', required : true),
dependency('libdrm_intel', version : '>= 2.4.52', required : true),
dependency('libudev', required : false),
]
if with_dri2
uxa_sources += 'intel_dri.c'
uxa_deps += dependency('dri2proto', version : '>= 2.6', required : true)
endif
if with_dri3
uxa_sources += [
'intel_dri3.c',
'intel_sync.c',
]
endif
if has_present
uxa_sources += 'intel_present.c'
endif
if with_xvmc
uxa_sources += 'intel_hwmc.c'
endif
uxa = static_library('uxa',
sources : uxa_sources,
dependencies : uxa_deps,
include_directories : inc,
c_args : [
'-Wno-deprecated-declarations',
'-Wno-shift-negative-value',
'-Wno-unused-parameter',
'-Wno-sign-compare',
],
install : false)
if with_tools
executable('intel-virtual-output',
sources : 'virtual.c',
dependencies : [
dependency('x11', required : true),
dependency('xext', required : true),
dependency('xfixes', required : true),
dependency('xrender', required : true),
dependency('xdamage', required : true),
dependency('xrandr', required : true),
dependency('xrender', required : true),
dependency('xcursor', required : true),
dependency('xscrnsaver', required : true),