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