]> git.sesse.net Git - plocate/blob - meson.build
Split DatabaseBuilder into its own compilation unit.
[plocate] / meson.build
1 project('plocate', 'cpp', default_options: ['buildtype=debugoptimized','cpp_std=c++17'], version: '1.0.8-pre')
2
3 # Make the version available as a #define.
4 add_project_arguments('-DPLOCATE_VERSION="' + meson.project_version() + '"', language: 'cpp')
5
6 cxx = meson.get_compiler('cpp')
7 uringdep = dependency('liburing', required: false)
8 zstddep = dependency('libzstd')
9 threaddep = dependency('threads')
10 atomicdep = cxx.find_library('atomic', required: false)
11
12 if not uringdep.found()
13         add_project_arguments('-DWITHOUT_URING', language: 'cpp')
14 endif
15 if cxx.has_header('endian.h')
16         add_project_arguments('-DHAS_ENDIAN_H', language: 'cpp')
17 endif
18
19 # Function multiversioning is x86-only _and_ not available on certain targets
20 # (they need “ifunc”, indirect functions, a GNU extension).
21 code = '''__attribute__((target("default"))) void foo();
22 __attribute__((target("sse2"))) void foo();
23 void bar() { foo(); }'''
24 if cxx.compiles(code, name: 'function multiversioning')
25         add_project_arguments('-DHAS_FUNCTION_MULTIVERSIONING', language: 'cpp')
26 endif
27
28 executable('plocate', ['plocate.cpp', 'io_uring_engine.cpp', 'turbopfor.cpp', 'parse_trigrams.cpp', 'serializer.cpp', 'access_rx_cache.cpp', 'needle.cpp'],
29         dependencies: [uringdep, zstddep, threaddep, atomicdep],
30         install: true,
31         install_mode: ['rwxr-sr-x', 'root', 'mlocate'])
32 executable('plocate-build', ['plocate-build.cpp', 'database-builder.cpp'],
33         dependencies: [zstddep],
34         install: true,
35         install_dir: get_option('sbindir'))
36
37 conf_data = configuration_data()
38 conf_data.set('PROCESSED_BY_MESON', '1')
39 conf_data.set('sbindir', get_option('prefix') + '/' + get_option('sbindir'))
40 conf_data.set('locategroup', get_option('locategroup'))
41 update_script = configure_file(input: 'update-plocate.sh',
42                output: 'update-plocate.sh',
43                configuration: conf_data)
44
45 if get_option('install_cron')
46         install_data(update_script,
47                 install_dir: '/etc/cron.daily',
48                 rename: 'plocate')
49 endif
50 install_man('plocate.1')
51 install_man('plocate-build.8')
52
53 # Requires having TurboPFor checked out, so not built by default.
54 # Unless you have a recent Meson, there's no apparently good way
55 # of calling into that directory to run make, and we're not
56 # replicating their build system, so it has to be manual.
57 pfordir = meson.source_root() + '/TurboPFor-Integer-Compression'
58 if run_command('[', '-r', pfordir + '/libic.a', ']').returncode() == 0
59         turbopfordep = declare_dependency(
60                 include_directories: include_directories('TurboPFor-Integer-Compression'),
61                 dependencies: meson.get_compiler('cpp').find_library('ic', dirs: pfordir))
62         executable('bench', ['bench.cpp', 'io_uring_engine.cpp', 'turbopfor.cpp'],
63                 dependencies: [uringdep, turbopfordep],
64                 build_by_default: false,
65                 install: false)
66 endif