1project('libevdev', 'c', 2 version: '1.10.0', # change autotools version too 3 license: 'MIT/Expat', 4 default_options: [ 'c_std=gnu99', 'warning_level=2' ], 5 meson_version: '>= 0.47.0') 6 7libevdev_version = meson.project_version().split('.') 8 9dir_src = join_paths(meson.source_root(), 'libevdev') 10dir_src_test = join_paths(meson.source_root(), 'test') 11 12# Include directories 13includes_include = include_directories('include') 14 15# DO NOT MODIFY THIS 16# Use symbol versioning instead. 17libevdev_lt_c=5 18libevdev_lt_r=0 19libevdev_lt_a=3 20 21# convert to soname 22libevdev_so_version = '@0@.@1@.@2@'.format((libevdev_lt_c - libevdev_lt_a), 23 libevdev_lt_a, libevdev_lt_r) 24 25 26# Compiler setup 27cc = meson.get_compiler('c') 28cppflags = ['-Wno-unused-parameter', '-fvisibility=hidden'] 29cflags = cppflags + ['-Wmissing-prototypes', '-Wstrict-prototypes'] 30add_project_arguments(cflags, language: 'c') 31add_project_arguments(cppflags, language: 'cpp') 32 33# config.h 34config_h = configuration_data() 35config_h.set('_GNU_SOURCE', '1') 36 37# Dependencies 38pkgconfig = import('pkgconfig') 39dep_lm = cc.find_library('m') 40 41input_h = join_paths(meson.source_root(), 'include', 'linux', host_machine.system(), 'input.h') 42uinput_h = join_paths(meson.source_root(), 'include', 'linux', host_machine.system(), 'uinput.h') 43input_event_codes_h = join_paths(meson.source_root(), 'include', 'linux', host_machine.system(), 'input-event-codes.h') 44 45# event-names.h 46make_event_names = find_program('libevdev/make-event-names.py') 47event_names_h = configure_file(input: 'libevdev/libevdev.h', 48 output: 'event-names.h', 49 command: [make_event_names, input_h, input_event_codes_h], 50 capture: true) 51 52 53# libevdev.so 54install_headers('libevdev/libevdev.h', 55 'libevdev/libevdev-uinput.h', 56 subdir: 'libevdev-1.0/libevdev') 57src_libevdev = [ 58 event_names_h, 59 'libevdev/libevdev.h', 60 'libevdev/libevdev-int.h', 61 'libevdev/libevdev-util.h', 62 'libevdev/libevdev-uinput.c', 63 'libevdev/libevdev-uinput.h', 64 'libevdev/libevdev-uinput-int.h', 65 'libevdev/libevdev.c', 66 'libevdev/libevdev-names.c', 67 'include/linux/input.h', 68 'include/linux/uinput.h', 69 input_event_codes_h, 70 input_h, 71 uinput_h 72] 73 74mapfile = join_paths(dir_src, 'libevdev.sym') 75version_flag = '-Wl,--version-script,@0@'.format(mapfile) 76lib_libevdev = library('evdev', 77 src_libevdev, 78 include_directories: [includes_include], 79 dependencies: [], 80 version: libevdev_so_version, 81 link_args: version_flag, 82 link_depends: mapfile, 83 install: true 84) 85 86dep_libevdev = declare_dependency(link_with: lib_libevdev) 87 88pkgconfig.generate( 89 filebase: 'libevdev', 90 name: 'libevdev', 91 description: 'Handler library for evdev events', 92 version: meson.project_version(), 93 libraries: lib_libevdev, 94 subdirs: 'libevdev-1.0', 95) 96 97man_config = configuration_data() 98man_config.set('PACKAGE_VERSION', meson.project_version()) 99manpage = configure_file(input: 'doc/libevdev.man.in', 100 output: 'libevdev.3', 101 configuration: man_config) 102install_man(manpage) 103 104 105# tools 106executable('libevdev-events', 107 sources: ['tools/libevdev-events.c'], 108 include_directories: [includes_include], 109 dependencies: dep_libevdev, 110 install: false) 111executable('touchpad-edge-detector', 112 sources: ['tools/touchpad-edge-detector.c'], 113 include_directories: [includes_include], 114 dependencies: [dep_libevdev, dep_lm], 115 install: true) 116executable('mouse-dpi-tool', 117 sources: ['tools/mouse-dpi-tool.c'], 118 include_directories: [includes_include], 119 dependencies: dep_libevdev, 120 install: true) 121executable('libevdev-tweak-device', 122 sources: ['tools/libevdev-tweak-device.c'], 123 include_directories: [includes_include], 124 dependencies: dep_libevdev, 125 install: true) 126install_man('tools/libevdev-tweak-device.1', 127 'tools/touchpad-edge-detector.1') 128 129# tests 130dep_check = dependency('check', version: '>= 0.9.9', 131 required: get_option('tests')) 132if dep_check.found() 133 executable('test-link', 134 sources: ['test/test-link.c'], 135 include_directories: [includes_include], 136 dependencies: dep_libevdev, 137 install: false) 138 executable('test-compile-pedantic', 139 sources: ['test/test-compile-pedantic.c'], 140 c_args: ['-pedantic', '-Werror', '-std=c89'], 141 include_directories: [includes_include], 142 dependencies: dep_libevdev, 143 install: false) 144 145 src_common = [ 146 'test/test-common-uinput.c', 147 'test/test-common-uinput.h', 148 'test/test-common.c', 149 'test/test-common.h', 150 'test/test-main.c', 151 ] 152 test_event_codes = executable('test-event-codes', 153 sources: src_common + [ 154 'test/test-event-codes.c', 155 'test/test-event-names.c', 156 'test/test-context.c', 157 ], 158 include_directories: [includes_include], 159 dependencies: [dep_libevdev, dep_check], 160 install: false) 161 test('test-event-codes', test_event_codes, suite: 'library') 162 163 test_internals = executable('test-internals', 164 sources: src_common + [ 165 'test/test-int-queue.c', 166 ], 167 include_directories: [includes_include], 168 dependencies: [dep_libevdev, dep_check], 169 install: false) 170 test('test-internals', test_internals, suite: 'library') 171 172 test_uinput = executable('test-uinput', 173 sources: src_common + [ 174 'test/test-uinput.c', 175 ], 176 include_directories: [includes_include], 177 dependencies: [dep_libevdev, dep_check], 178 install: false) 179 test('test-uinput', test_uinput, suite: 'library') 180 181 test_libevdev = executable('test-libevdev', 182 sources: src_common + [ 183 'test/test-libevdev-init.c', 184 'test/test-libevdev-has-event.c', 185 'test/test-libevdev-events.c', 186 ], 187 include_directories: [includes_include], 188 dependencies: [dep_libevdev, dep_check], 189 install: false) 190 test('test-libevdev', test_libevdev, suite: 'library') 191 192 test_kernel = executable('test-kernel', 193 sources: src_common + [ 194 'test/test-kernel.c', 195 ], 196 include_directories: [includes_include], 197 dependencies: [dep_libevdev, dep_check], 198 install: false) 199 test('test-kernel', test_kernel, suite: 'kernel') 200 201 202 valgrind = find_program('valgrind', required: false) 203 if valgrind.found() 204 valgrind_env = environment() 205 valgrind_env.set('CK_TIMEOUT_MULTIPLIER', '10') 206 valgrind_env.set('CK_FORK', 'no') 207 valgrind_env.set('RUNNING_ON_VALGRIND', '1') 208 valgrind_suppressions_file = join_paths(dir_src_test, 'valgrind.suppressions') 209 add_test_setup('valgrind', 210 exe_wrapper: [ valgrind, 211 '--leak-check=full', 212 '--gen-suppressions=all', 213 '--error-exitcode=3', 214 '--suppressions=' + valgrind_suppressions_file ], 215 env: valgrind_env, 216 timeout_multiplier: 100) 217 else 218 message('valgrind not found, disabling valgrind test suite') 219 endif 220 221 test_static_link = find_program('test/test-static-symbols-leak.sh') 222 test('static-symbols-leak', test_static_link, 223 args: [meson.current_build_dir()], 224 suite: 'static') 225endif 226 227doxygen = find_program('doxygen', required: get_option('documentation')) 228if doxygen.found() 229 doxygen = find_program('doxygen') 230 231 src_doxygen = files( 232 # source files 233 join_paths(dir_src, 'libevdev.h'), 234 join_paths(dir_src, 'libevdev-uinput.h'), 235 # style files 236 'doc/style/bootstrap.css', 237 'doc/style/customdoxygen.css', 238 'doc/style/doxy-boot.js', 239 'doc/style/dynsections.js', 240 'doc/style/footer.html', 241 'doc/style/header.html', 242 'doc/style/layout.xml', 243 'doc/style/libevdevdoxygen.css', 244 'doc/style/LICENSE', 245 'doc/style/README.md', 246 'doc/style/style.css', 247 ) 248 doxyfiles = [] 249 foreach f: src_doxygen 250 df = configure_file(input: f, 251 output: '@PLAINNAME@', 252 copy: true) 253 doxyfiles += [df] 254 endforeach 255 256 doc_config = configuration_data() 257 doc_config.set('PACKAGE_NAME', meson.project_name()) 258 doc_config.set('PACKAGE_VERSION', meson.project_version()) 259 doc_config.set('builddir', meson.current_build_dir()) 260 doc_config.set('top_srcdir', meson.source_root()) 261 doc_config.set('srcdir', join_paths(meson.source_root(), 'doc')) 262 263 doxyfile = configure_file(input: 'doc/libevdev.doxygen.in', 264 output: 'libevdev.doxygen', 265 configuration: doc_config) 266 custom_target('doxygen', 267 input: [doxyfiles, doxyfile] + src_doxygen, 268 output: ['.'], 269 command: [doxygen, doxyfile], 270 install: false, 271 build_by_default: true) 272endif 273 274# Coverity breaks because it doesn't define _Float128 correctly, you'll end 275# up with a bunch of messages in the form: 276# "/usr/include/stdlib.h", line 133: error #20: identifier "_Float128" is 277# undefined 278# extern _Float128 strtof128 (const char *__restrict __nptr, 279# ^ 280# We don't use float128 ourselves, it gets pulled in from math.h or 281# something, so let's just define it as uint128 and move on. 282# Unfortunately we can't detect the coverity build at meson configure 283# time, we only know it fails at runtime. So make this an option instead, to 284# be removed when coverity fixes this again. 285if get_option('coverity') 286 config_h.set('_Float128', '__uint128_t') 287 config_h.set('_Float32', 'int') 288 config_h.set('_Float32x', 'int') 289 config_h.set('_Float64', 'long') 290 config_h.set('_Float64x', 'long') 291endif 292 293############ output files ############ 294configure_file(output: 'config.h', configuration: config_h) 295