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