From cf1ac31f554d92518d15c0e22c58975e43e03995 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 26 Jun 2020 16:41:59 +0200 Subject: [PATCH] build: Add meson build system files --- data/meson.build | 22 +++++++++++++++ docs/meson.build | 47 ++++++++++++++++++++++++++++++++ meson.build | 62 ++++++++++++++++++++++++++++++++++++++++++ meson_options.txt | 20 ++++++++++++++ src/meson.build | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 220 insertions(+) create mode 100644 data/meson.build create mode 100644 docs/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 src/meson.build diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 0000000..814638c --- /dev/null +++ b/data/meson.build @@ -0,0 +1,22 @@ +install_data( + '80-iio-sensor-proxy.rules', + install_dir: udev_rules_dir +) + +data_conf = configuration_data() +data_conf.set('sbindir', sbindir) +data_conf.set('geoclue_user', get_option('geoclue-user')) + +configure_file( + input: 'iio-sensor-proxy.service.in', + output: 'iio-sensor-proxy.service', + configuration: data_conf, + install_dir: systemd_system_unit_dir, +) + +configure_file( + input: 'net.hadess.SensorProxy.conf.in', + output: 'net.hadess.SensorProxy.conf', + configuration: data_conf, + install_dir: dbusconfdir +) diff --git a/docs/meson.build b/docs/meson.build new file mode 100644 index 0000000..6ac79c6 --- /dev/null +++ b/docs/meson.build @@ -0,0 +1,47 @@ +content_files = files() + +version_conf = configuration_data() +version_conf.set('VERSION', meson.project_version()) + +content_files += configure_file( + input: 'version.xml.in', + output: 'version.xml', + configuration: version_conf, +) + +content_files += gnome.gdbus_codegen( + meson.project_name(), + sources: meson.source_root() / 'src' / 'net.hadess.SensorProxy.xml', + interface_prefix: 'net.hadess', + namespace: 'SensorProxy', + docbook: 'docs', + build_by_default: true, +) + +gnome.gtkdoc( + meson.project_name(), + main_xml: meson.project_name() + '-docs.xml', + content_files: content_files, + src_dir: [ + meson.source_root() /'src', + meson.build_root() / 'src', + ], + ignore_headers: ['drivers.h', 'iio-buffer-utils.h', 'orientation.h', 'uinput.h', 'accel-mount-matrix.h'], + scan_args: ['--rebuild-sections'], +) + +man1_dir = join_paths(get_option('prefix'), get_option('mandir'), 'man1') + +xsltproc = find_program('xsltproc', required : true) +xsltproc_command = [ + xsltproc, + '--nonet', + '--stringparam', 'man.output.quietly', '1', + '--stringparam', 'funcsynopsis.style', 'ansi', + '--stringparam', 'man.th.extra1.suppress', '1', + '--stringparam', 'man.authors.section.enabled', '0', + '--stringparam', 'man.copyright.section.enabled', '0', + '-o', '@OUTPUT@', + 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl', + '@INPUT@', +] diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..1d91908 --- /dev/null +++ b/meson.build @@ -0,0 +1,62 @@ +project('iio-sensor-proxy', [ 'c' ], + version: '2.5', + license: 'GPLv2+', + default_options: [ + 'buildtype=debugoptimized', + 'warning_level=1', + 'c_std=c99', + ], + meson_version: '>= 0.54.0') + +cc = meson.get_compiler('c') + +common_cflags = cc.get_supported_arguments([ + '-fgnu89-inline', + '-fvisibility=hidden', + '-std=gnu99', + '-Wall', + '-Wundef', + '-Wunused', + '-Wstrict-prototypes', + '-Werror-implicit-function-declaration', + '-Wno-pointer-sign', + '-Wshadow' +]) + +sbindir = get_option('sbindir') +bindir = get_option('bindir') +dbusconfdir = get_option('sysconfdir') / 'dbus-1' / 'system.d' + +mathlib_dep = cc.find_library('m', required: false) +udev_rules_dir = get_option('udevrulesdir') +if udev_rules_dir == 'auto' + udev_dep = dependency('udev') + udev_rules_dir = udev_dep.get_pkgconfig_variable('udevdir') + '/rules.d' +endif +systemd_system_unit_dir = get_option('systemdsystemunitdir') +if systemd_system_unit_dir == 'auto' + systemd_dep = dependency('systemd') + systemd_system_unit_dir = systemd_dep.get_pkgconfig_variable('systemdsystemunitdir') +endif +if get_option('gtk-tests') + gtk_dep = dependency('gtk+-3.0', required: false) +endif +gio_dep = dependency('gio-2.0') +gudev_dep = dependency('gudev-1.0', version: '>= 232') + +gnome = import('gnome') + +add_global_arguments('-D_GNU_SOURCE=1', language: 'c') + +subdir('src') +subdir('data') + +if get_option('gtk_doc') + # Make like license available in the build root for docs + configure_file( + input: 'COPYING', + output: 'COPYING', + copy: true, + ) + subdir('docs') +endif diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..758427d --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,20 @@ +option('udevrulesdir', + description: 'udev rules directory', + type: 'string', + value: 'auto') +option('systemdsystemunitdir', + description: 'systemd unit directory', + type: 'string', + value: 'auto') +option('gtk-tests', + description: 'Whether to build GTK tests', + type: 'boolean', + value: false) +option('geoclue-user', + description: 'The USER (existing) as which geoclue service is running', + type: 'string', + value: 'geoclue') +option('gtk_doc', + type: 'boolean', + value: false, + description: 'Build docs') diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..3060a24 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,69 @@ +deps = [ gio_dep, gudev_dep, mathlib_dep ] + +resources = gnome.compile_resources( + 'iio-sensor-proxy-resources', 'iio-sensor-proxy.gresource.xml', + c_name: 'iio_sensor_proxy', + source_dir: '.', + export: true +) + +sources = [ + 'iio-sensor-proxy.c', + 'drivers.c', + 'orientation.c', + 'drv-iio-buffer-accel.c', + 'drv-iio-poll-accel.c', + 'drv-input-accel.c', + 'drv-fake-compass.c', + 'drv-fake-light.c', + 'drv-iio-poll-light.c', + 'drv-hwmon-light.c', + 'drv-iio-buffer-light.c', + 'drv-iio-buffer-compass.c', + 'drv-iio-poll-proximity.c', + 'iio-buffer-utils.c', + 'accel-mount-matrix.c', + 'accel-scale.c', + 'accel-attributes.c', + resources, +] + +executable('iio-sensor-proxy', + sources, + dependencies: deps, + install: true, + install_dir: sbindir +) + +executable('fake-input-accelerometer', + [ 'fake-input-accelerometer.c' ], + dependencies: deps, + install: false +) + +executable('test-mount-matrix', + [ 'test-mount-matrix.c', 'accel-mount-matrix.c' ], + dependencies: deps, + install: false +) + +executable('test-orientation', + [ 'test-orientation.c', 'orientation.c', 'accel-mount-matrix.c', 'accel-scale.c' ], + dependencies: deps, + install: false +) + +if get_option('gtk-tests') + executable('test-orientation-gtk', + [ 'test-orientation-gtk.c', 'orientation.c', 'accel-scale.c' ], + dependencies: [ deps, gtk_dep ], + install: false + ) +endif + +executable('monitor-sensor', + [ 'monitor-sensor.c' ], + dependencies: gio_dep, + install: true, + install_dir: bindir +)