]> git.sesse.net Git - plocate/blob - meson.build
Release plocate 1.1.22.
[plocate] / meson.build
1 project('plocate', 'cpp', default_options: ['buildtype=debugoptimized','cpp_std=c++17'], version: '1.1.17-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
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', get_option('locategroup')])
37 executable('plocate-build', ['plocate-build.cpp', 'database-builder.cpp'],
38         dependencies: [zstddep],
39         install: true,
40         install_dir: get_option('sbindir'))
41 updatedb_progname = get_option('updatedb_progname')
42 executable(updatedb_progname, ['updatedb.cpp', 'database-builder.cpp', 'conf.cpp', 'lib.cpp', 'bind-mount.cpp', 'complete_pread.cpp'],
43         dependencies: [zstddep, threaddep],
44         install: true,
45         install_dir: get_option('sbindir'))
46
47 conf_data = configuration_data()
48 conf_data.set('PROCESSED_BY_MESON', '1')
49 conf_data.set('sbindir', join_paths(get_option('prefix'), get_option('sbindir')))
50 conf_data.set('groupname', get_option('locategroup'))
51 conf_data.set('dbfile', dbfile)
52 conf_data.set('updatedb_conf', '/etc/updatedb.conf')
53 conf_data.set('updatedb_progname', updatedb_progname)
54 update_script = configure_file(input: 'update-plocate.sh',
55                output: 'update-plocate.sh',
56                configuration: conf_data)
57
58 fs = import('fs')
59 meson.add_install_script('mkdir.sh', fs.parent(dbfile))
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         unitdir = get_option('systemunitdir')
81         if unitdir == ''
82                 systemd = dependency('systemd', required: false)
83                 if systemd.found()
84                         unitdir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
85                 endif
86         endif
87         if unitdir != ''
88                 updatedb_service = configure_file(input: 'plocate-updatedb.service.in',
89                         output: 'plocate-updatedb.service',
90                         configuration: conf_data)
91                 install_data(updatedb_service, install_dir: unitdir)
92                 install_data('plocate-updatedb.timer', install_dir: unitdir)
93         endif
94 endif
95
96 # Requires having TurboPFor checked out, so not built by default.
97 # Unless you have a recent Meson, there's no apparently good way
98 # of calling into that directory to run make, and we're not
99 # replicating their build system, so it has to be manual.
100 pfordir = meson.source_root() + '/TurboPFor-Integer-Compression'
101 if run_command('[', '-r', pfordir + '/libic.a', ']').returncode() == 0
102         turbopfordep = declare_dependency(
103                 include_directories: include_directories('TurboPFor-Integer-Compression'),
104                 dependencies: meson.get_compiler('cpp').find_library('ic', dirs: pfordir))
105         executable('bench', ['bench.cpp', 'io_uring_engine.cpp', 'turbopfor.cpp', 'complete_pread.cpp'],
106                 dependencies: [uringdep, turbopfordep],
107                 build_by_default: false,
108                 install: false)
109 endif