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