|
| 1 | +project( |
| 2 | + 'rtkit', 'c', |
| 3 | + version: '0.12', |
| 4 | + license: 'GPL3', |
| 5 | + meson_version: '>=0.49.0', |
| 6 | + default_options: ['c_std=c99', 'warning_level=2'], |
| 7 | +) |
| 8 | + |
| 9 | +add_project_arguments( |
| 10 | + '-D_GNU_SOURCE', '-DHAVE_CONFIG_H', |
| 11 | + language: 'c' |
| 12 | +) |
| 13 | + |
| 14 | +cc = meson.get_compiler('c') |
| 15 | +sh = find_program('sh') |
| 16 | +xxd = find_program('xxd') |
| 17 | + |
| 18 | +dbus_dep = dependency('dbus-1') |
| 19 | +libcap_dep = dependency('libcap') |
| 20 | +libsystemd_dep = dependency('libsystemd') |
| 21 | +polkit_dep = dependency('polkit-gobject-1', required: false) |
| 22 | +systemd_dep = dependency('systemd', required: false) |
| 23 | +thread_dep = dependency('threads') |
| 24 | + |
| 25 | +librt_dep = cc.find_library('z') |
| 26 | +cc.check_header('sched.h', dependencies: librt_dep) |
| 27 | +cc.has_function('sched_setscheduler', dependencies: librt_dep) |
| 28 | + |
| 29 | +libexecdir = get_option('libexecdir') |
| 30 | +testsdir = get_option('libexecdir') / 'installed-tests' / meson.project_name() |
| 31 | + |
| 32 | +busservicedir = get_option('dbus_systemservicedir') |
| 33 | +if busservicedir == '' |
| 34 | + busservicedir = dbus_dep.get_pkgconfig_variable( |
| 35 | + 'system_bus_services_dir', |
| 36 | + default: get_option('datadir') / 'dbus-1' / 'system-services', |
| 37 | + ) |
| 38 | +endif |
| 39 | + |
| 40 | +interfacedir = get_option('dbus_interfacedir') |
| 41 | +if interfacedir == '' |
| 42 | + interfacedir = dbus_dep.get_pkgconfig_variable( |
| 43 | + 'interfaces_dir', |
| 44 | + default: get_option('datadir') / 'dbus-1' / 'interfaces', |
| 45 | + ) |
| 46 | +endif |
| 47 | + |
| 48 | +rulesdir = get_option('dbus_rulesdir') |
| 49 | +if rulesdir == '' |
| 50 | + rulesdir = get_option('datadir') / 'dbus-1' / 'system.d' |
| 51 | +endif |
| 52 | + |
| 53 | +policydir = get_option('polkit_actiondir') |
| 54 | +if policydir == '' and polkit_dep.found() |
| 55 | + policydir = polkit_dep.get_pkgconfig_variable('actiondir', default: '') |
| 56 | +endif |
| 57 | +if policydir == '' |
| 58 | + policydir = get_option('datadir') / 'polkit-1' / 'actions' |
| 59 | +endif |
| 60 | + |
| 61 | +systemunitdir = '' |
| 62 | +if systemunitdir == '' and systemd_dep.found() |
| 63 | + systemunitdir = systemd_dep.get_pkgconfig_variable( |
| 64 | + 'systemdsystemunitdir', |
| 65 | + default: '', |
| 66 | + ) |
| 67 | +endif |
| 68 | +if systemunitdir == '' |
| 69 | + systemunitdir = get_option('libdir') / 'systemd' / 'system' |
| 70 | +endif |
| 71 | + |
| 72 | +config = configuration_data() |
| 73 | +config.set('LIBEXECDIR', get_option('prefix') / libexecdir) |
| 74 | +config.set_quoted('PACKAGE_VERSION', meson.project_version()) |
| 75 | + |
| 76 | +config_h = configure_file( |
| 77 | + input: 'config.h.meson', |
| 78 | + output: 'config.h', |
| 79 | + configuration: config, |
| 80 | +) |
| 81 | + |
| 82 | +xml_introspection_h = configure_file( |
| 83 | + input: 'org.freedesktop.RealtimeKit1.xml', |
| 84 | + output: 'xml-introspection.h', |
| 85 | + command: [ |
| 86 | + sh, '-c', '"$1" -i < "$2" > "$3"', sh, |
| 87 | + xxd, '@INPUT@', '@OUTPUT@' |
| 88 | + ], |
| 89 | +) |
| 90 | + |
| 91 | +executable( |
| 92 | + 'rtkit-daemon', |
| 93 | + 'rtkit-daemon.c', 'rtkit.c', 'rtkit.h', config_h, xml_introspection_h, |
| 94 | + dependencies: [ |
| 95 | + dbus_dep, |
| 96 | + libcap_dep, |
| 97 | + librt_dep, |
| 98 | + libsystemd_dep, |
| 99 | + thread_dep |
| 100 | + ], |
| 101 | + install: true, |
| 102 | + install_dir: libexecdir, |
| 103 | +) |
| 104 | + |
| 105 | +executable( |
| 106 | + 'rtkit-test', |
| 107 | + 'rtkit-test.c', 'rtkit.c', 'rtkit.h', config_h, |
| 108 | + dependencies: [dbus_dep, librt_dep], |
| 109 | + install: get_option('installed_tests'), |
| 110 | + install_dir: testsdir, |
| 111 | +) |
| 112 | + |
| 113 | +executable( |
| 114 | + 'rtkitctl', |
| 115 | + 'rtkitctl.c', 'rtkit.h', config_h, |
| 116 | + install: true, |
| 117 | + dependencies: [dbus_dep], |
| 118 | +) |
| 119 | + |
| 120 | +install_man('rtkitctl.8') |
| 121 | +install_data('org.freedesktop.RealtimeKit1.xml', install_dir: interfacedir) |
| 122 | +install_data('org.freedesktop.RealtimeKit1.conf', install_dir: rulesdir) |
| 123 | +install_data('org.freedesktop.RealtimeKit1.policy', install_dir: policydir) |
| 124 | + |
| 125 | +configure_file( |
| 126 | + input: 'org.freedesktop.RealtimeKit1.service.in', |
| 127 | + output: 'org.freedesktop.RealtimeKit1.service', |
| 128 | + configuration: config, |
| 129 | + install_dir: busservicedir, |
| 130 | +) |
| 131 | + |
| 132 | +configure_file( |
| 133 | + input: 'rtkit-daemon.service.in', |
| 134 | + output: 'rtkit-daemon.service', |
| 135 | + configuration: config, |
| 136 | + install_dir: systemunitdir, |
| 137 | +) |
0 commit comments