]> git.sesse.net Git - plocate/blob - meson.build
Proof-of-concept of using ICU for strength-zero searches.
[plocate] / meson.build
1 project('plocate', 'cpp', default_options: ['buildtype=debugoptimized','cpp_std=c++17'], version: '1.1.16-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'), get_option('dbpath'))
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 icudep = dependency('icu-i18n')
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, icudep],
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, icudep],
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, icudep],
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 fs = import('fs')
60 meson.add_install_script('mkdir.sh', fs.parent(dbfile))
61
62 if get_option('install_cron')
63         install_data(update_script,
64                 install_dir: '/etc/cron.daily',
65                 rename: 'plocate')
66 endif
67 install_man('plocate.1')
68 install_man('plocate-build.8')
69
70 updatedb_man = configure_file(input: 'updatedb.8.in',
71                output: updatedb_progname + '.8',
72                configuration: conf_data)
73 install_man(updatedb_man)
74
75 updatedb_conf_man = configure_file(input: 'updatedb.conf.5.in',
76                output: 'updatedb.conf.5',
77                configuration: conf_data)
78 install_man(updatedb_conf_man)
79
80 if get_option('install_systemd')
81         unitdir = get_option('systemunitdir')
82         if unitdir == ''
83                 systemd = dependency('systemd', required: false)
84                 if systemd.found()
85                         unitdir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
86                 endif
87         endif
88         if unitdir != ''
89                 updatedb_service = configure_file(input: 'plocate-updatedb.service.in',
90                         output: 'plocate-updatedb.service',
91                         configuration: conf_data)
92                 install_data(updatedb_service, install_dir: unitdir)
93                 install_data('plocate-updatedb.timer', install_dir: unitdir)
94         endif
95 endif
96
97 # Requires having TurboPFor checked out, so not built by default.
98 # Unless you have a recent Meson, there's no apparently good way
99 # of calling into that directory to run make, and we're not
100 # replicating their build system, so it has to be manual.
101 pfordir = meson.source_root() + '/TurboPFor-Integer-Compression'
102 if run_command('[', '-r', pfordir + '/libic.a', ']').returncode() == 0
103         turbopfordep = declare_dependency(
104                 include_directories: include_directories('TurboPFor-Integer-Compression'),
105                 dependencies: meson.get_compiler('cpp').find_library('ic', dirs: pfordir))
106         executable('bench', ['bench.cpp', 'io_uring_engine.cpp', 'turbopfor.cpp', 'complete_pread.cpp'],
107                 dependencies: [uringdep, turbopfordep],
108                 build_by_default: false,
109                 install: false)
110 endif