[go: up one dir, main page]

File: meson.build

package info (click to toggle)
recoll 1.43.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,468 kB
  • sloc: cpp: 103,827; python: 9,498; xml: 7,218; ansic: 6,447; sh: 1,212; perl: 130; makefile: 72
file content (569 lines) | stat: -rw-r--r-- 16,841 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
# Note: the project version comes from RECOLL-VERSION.txt and is set by setversion.sh when we
# bump it. We would like to simply set it into a variable at the top to facilitate the sed job, but
# meson wants the first statement to be "project". Also there are several "  version: " in the file,
# hence the comment hack below.
#
# 
# - BSD build:
#   * Use "meson setup -Db_lundef=false" else will get undefined environ during the
#     librecoll build.
#   * recent FreeBSD with qt6:
#       export QMAKE=qmake6
#       export MAKE="gmake"
#       meson setup -Db_lundef=false -Dwebengine=true -Dchm_include_dir=/usr/local/include -Daspell_include_dir=/usr/local/include build
#     gmake is needed by the qmake-generated Makefile apparently
#
#    iconv: on FreeBSD, the default method
#    improperly uses /usr/local/iconv/iconv.h but not /usr/local/lib/libiconv, which results in an
#    undefined libiconv_open (defined by the local .h but does not exist in /usr libc).
#    We use "libiconv = cc.find_library('libiconv', required:true,dirs:'/usr/local/lib')"
#    instead, which works and results in actually using libiconv instead of the libc bundled iconv

project(
    'recoll',
    ['cpp', 'c'],
    license: 'GPL 2+',
    # We'd like to use version: files('RECOLL-VERSION.txt') but this is a 0.57 feature. 
    # Ubuntu focal has 0.53 and is supported until 2025-04.
    version: '1.43.4', # VERSIONCOMMENT keep this here, used by setversion.sh
    # Note: follow_symlinks will be needed in the future but not supported by all the versions we
    # need at the moment
    default_options: ['cpp_std=c++17', 'buildtype=debugoptimized',
                       #'follow_symlinks=true'
                     ],
    meson_version: '>=0.53',
)

# Shared lib versions.
# 1.38.0 had 1.38.0 for soversion, which was a mistake, because the SONAME was xxx.1 For now
# this is not very important because we don't really package the lib users (python, kde stuff)
# independently, but the future rule should be to only change the soversion if the ABI changed.
#
# Linked binaries only depend on soversion, e.g. ldd recollindex: librecoll.so.39 which is a
# link to, e.g., .so.<version>
recoll_soversion = '39' # SONAMECOMMENT keep this here, used by setversion.sh

cpp = meson.get_compiler('cpp')
cc = meson.get_compiler('c')

libxml = dependency('libxml-2.0')
libxslt =  dependency('libxslt')
libz = dependency('zlib')
if get_option('libmagic')
    libmagic = dependency('libmagic', required:false)
    # Libmagic has no pkgconfig data on older debian systems
    if not libmagic.found()
        libmagic = cc.find_library('libmagic', required:true)
    endif
endif

# Check if anything needs Xapian. We also need to build the shared lib if this is the case.
# The only case where it is not needed is for building rclgrep alone.
if get_option('testmains') or get_option('python-module') or get_option('indexer') or get_option('xadump') or get_option('qtgui') or get_option('recollq')
    librecoll_needed = true
    librecolldeps = []
    xapian = dependency('xapian-core')
    librecolldeps += xapian
    if get_option('idxthreads')
        librecolldeps += dependency('threads')
    endif
    librecolldeps += libxml
    librecolldeps += libxslt
    librecolldeps += libz
    if get_option('libmagic')
        librecolldeps += libmagic
    endif
    # Note: we would like to remove the x11 dep from the lib to the indexer, but this is not
    # possible without separating the indexing code out of rcldb (it calls idxstatus->x11mon).
    if get_option('x11mon') and get_option('indexer')
        librecolldeps += dependency('x11')
    endif

    # Searching for iconv is a meson 0.60 feature. Hopefully, for now all the systems where the
    # meson build is used have iconv in libc. Otherwise look at glib search for iconv for how to do
    # it.
    if (build_machine.system() == 'freebsd') or (build_machine.system() == 'openbsd')
        libiconv = cc.find_library('libiconv', required:true, dirs: '/usr/local/lib')
        librecolldeps += libiconv
    else 
        librecolldeps += dependency('iconv', method : 'auto')
    endif
else
    librecoll_needed = false
endif

recoll_datadir = get_option('prefix') / get_option('datadir') / 'recoll'

defineslist =     [
        '-DBUILDING_RECOLL',
        '-DREADFILE_ENABLE_ZLIB',
        '-DREADFILE_ENABLE_MINIZ',
        '-DREADFILE_ENABLE_MD5',
        '-DRECOLL_DATADIR="' + recoll_datadir + '"',
    ]
if get_option('appimage')
    defineslist += '-DRECOLL_APPIMAGE'
endif

add_project_arguments(
    defineslist,
    language: 'cpp',
)


recoll_conf = configuration_data()
recoll_conf.set_quoted('PACKAGE_VERSION', meson.project_version())
recoll_conf.set_quoted('FILE_PROG', get_option('file-command'))
recoll_conf.set('IDX_THREADS', get_option('idxthreads'))
recoll_conf.set('ENABLE_LIBMAGIC', get_option('libmagic'))
recoll_conf.set('DISABLE_X11MON', not get_option('x11mon'))
recoll_conf.set('RCL_USE_ASPELL', get_option('aspell'))
recoll_conf.set('PREVIEW_FORCETEXTBROWSER', not get_option('webpreview'))
# TBD: DEF_EXT4_BIRTH_TIME in python recoll setup.py
# For qtgui this was done by running qmake with DEFINE_BTIME=1 on the command line but the affected
# files actually include autoconfig.h so we're ok
recoll_conf.set('EXT4_BIRTH_TIME', get_option('ext4-birthtime'))
if cpp.compiles(
    '''
        #include <stdlib.h>
        #include <iconv.h>
        void tryit()
        {
            iconv_t ic;
            size_t isiz, osiz;
            const char *icp;
            char *ocp;
            ic = iconv_open("utf-8", "utf-8");
            iconv(ic, &icp, &isiz, &ocp, &osiz);
        }''',
    args: ['-Werror', '-O'], # -O needed, else warnings with _FORTIFY_SOURCE
    name: 'ICONV CONST',
)
    recoll_conf.set('ICONV_CONST', 'const')
elif cpp.compiles(
    '''
        #include <stdlib.h>
        #include <iconv.h>
        void tryit()
        {
            iconv_t ic;
            size_t isiz, osiz;
            char *icp;
            char *ocp;
            ic = iconv_open("utf-8", "utf-8");
            iconv(ic, &icp, &isiz, &ocp, &osiz);
        }''',
    args: ['-Werror', '-O'], # -O needed, else warnings with _FORTIFY_SOURCE
    name: 'ICONV NOT CONST',
)
    recoll_conf.set('ICONV_CONST', '')
endif

if cpp.compiles(
    '''#include<stdlib.h>
    char* func() {char t[10];return mkdtemp(t);}
    ''',
    name: 'mkdtemp',
    args: ['-Werror', '-O'], # -O needed, else warnings with _FORTIFY_SOURCE
)
    recoll_conf.set('HAVE_MKDTEMP', true)
endif
if cpp.has_header('features.h')
    recoll_conf.set('HAVE_FEATURES_H', true)
endif
if cpp.has_header('spawn.h')
    recoll_conf.set('HAVE_SPAWN_H', true)
    if cpp.has_function('posix_spawn', prefix: '#include <spawn.h>')
        recoll_conf.set10('HAVE_POSIX_SPAWN', true)
        recoll_conf.set('USE_POSIX_SPAWN', get_option('spawn'))
    endif
endif
malloc_include = ''
if cpp.has_header('malloc.h')
    malloc_include = '<malloc.h>'
    recoll_conf.set('HAVE_MALLOC_H', true)
endif
if cpp.has_header('malloc/malloc.h')
    malloc_include = '<malloc/malloc.h>'
    recoll_conf.set('HAVE_MALLOC_MALLOC_H', true)
endif
if malloc_include != ''
    if cpp.has_function('malloc_trim', prefix: '#include ' + malloc_include)
        recoll_conf.set('HAVE_MALLOC_TRIM', true)
    endif
endif
if cpp.has_function(
    'setrlimit',
    prefix: '''#include <sys/time.h>
       #include <sys/resource.h>''',
)
    recoll_conf.set('HAVE_SETRLIMIT', true)
endif
if cpp.has_function(
    'kqueue',
    prefix: '''#include <sys/event.h>
       #include <sys/time.h>''',
)
    recoll_conf.set('HAVE_KQUEUE', true)
endif

# Check for macOS (darwin)
if host_machine.system() == 'darwin' and get_option('fsevents')
    # Declare the Core Services framework dependency
    core_services = dependency('CoreServices', required: true)
    apple_core_services_found = true

    librecolldeps += core_services  # Add the CoreServices framework as a dependency
    
    recoll_conf.set('RCL_USE_FSEVENTS', true)
    recoll_conf.set('RCL_MONITOR', true)
else 
    apple_core_services_found = false
endif

recoll_conf.set('HAVE_VSNPRINTF', cpp.has_function('vsnprintf'))
recoll_conf.set(
    'HAVE_POSIX_FADVISE',
    cpp.has_function('posix_fadvise', prefix: '#include <fcntl.h>'),
)

if (
    get_option('inotify')
    and cpp.has_function(
        'inotify_add_watch',
        prefix: '#include <sys/inotify.h>',
    )
)
    recoll_conf.set('RCL_USE_INOTIFY', true)
    recoll_conf.set('RCL_MONITOR', true)
elif get_option('fam')
    libfam = dependency('libgamin', required:false)
    if libfam.found()
        recoll_conf.set('RCL_USE_FAM', true)
        recoll_conf.set('RCL_MONITOR', true)
        librecolldeps += libfam
    endif
endif
recoll_conf.set('RCL_SPLIT_CAMELCASE', get_option('camelcase'))
recoll_conf.set('USE_SIMDUTF', get_option('simdutf'))

cfile = configure_file(output: 'autoconfig.h', configuration: recoll_conf)

# Could not find a way to make this work for now.
# In case wasaparse.cpp/h need to be rebuilt just do it with:
#   ylwrap query/wasaparse.ypp
#bison = find_program('bison')
#wasaparse_cpp = custom_target('wasaparse.cpp',
#  output: ['wasaparse.cpp', 'wasaparse.h'],
#  input: 'query/wasaparse.ypp',
#  command: ['./ylwrap', '@INPUT@'],
#)

librecoll_sources = [
    'aspell/rclaspell.cpp',
    'bincimapmime/convert.cc',
    'bincimapmime/mime-parsefull.cc',
    'bincimapmime/mime-parseonlyheader.cc',
    'bincimapmime/mime-printbody.cc',
    'bincimapmime/mime.cc',
    'common/cjksplitter.cpp',
    'common/cnsplitter.cpp',
    'common/cstr.cpp',
    'common/firstmatchline.cpp',
    'common/kosplitter.cpp',
    'common/rclconfig.cpp',
    'common/rclinit.cpp',
    'common/rclutil.cpp',
    'common/syngroups.cpp',
    'common/textsplit.cpp',
    'common/unacpp.cpp',
    'common/webstore.cpp',
    'index/webqueuefetcher.cpp',
    'index/checkretryfailed.cpp',
    'index/exefetcher.cpp',
    'index/fetcher.cpp',
    'index/fsfetcher.cpp',
    'index/idxdiags.cpp',
    'index/idxstatus.cpp',
    'index/mimetype.cpp',
    'index/subtreelist.cpp',
    'internfile/extrameta.cpp',
    'internfile/htmlparse.cpp',
    'internfile/internfile.cpp',
    'internfile/mh_exec.cpp',
    'internfile/mh_execm.cpp',
    'internfile/mh_html.cpp',
    'internfile/mh_mail.cpp',
    'internfile/mh_mbox.cpp',
    'internfile/mh_text.cpp',
    'internfile/mh_xslt.cpp',
    'internfile/mimehandler.cpp',
    'internfile/myhtmlparse.cpp',
    'internfile/txtdcode.cpp',
    'internfile/uncomp.cpp',
    'query/docseq.cpp',
    'query/docseqdb.cpp',
    'query/docseqhist.cpp',
    'query/dynconf.cpp',
    'query/filtseq.cpp',
    'common/plaintorich.cpp',
    'query/qresultstore.cpp',
    'query/recollq.cpp',
    'query/reslistpager.cpp',
    'query/sortseq.cpp',
    'query/wasaparse.cpp',
    'query/wasaparseaux.cpp',
    'rcldb/daterange.cpp',
    'rcldb/expansiondbs.cpp',
    'rcldb/rclabstract.cpp',
    'rcldb/rclabsfromtext.cpp',
    'rcldb/rcldb.cpp',
    'rcldb/rclndb.cpp',
    'rcldb/rcldoc.cpp',
    'rcldb/rcldups.cpp',
    'rcldb/rclndb.cpp',
    'rcldb/rclquery.cpp',
    'rcldb/rclterms.cpp',
    'rcldb/rclvalues.cpp',
    'rcldb/searchdata.cpp',
    'rcldb/searchdatatox.cpp',
    'rcldb/searchdataxml.cpp',
    'rcldb/stemdb.cpp',
    'rcldb/stoplist.cpp',
    'rcldb/synfamily.cpp',
    'unac/unac.cpp',
    'utils/appformime.cpp',
    'utils/base64.cpp',
    'utils/cancelcheck.cpp',
    'utils/chrono.cpp',
    'utils/circache.cpp',
    'utils/closefrom.cpp',
    'utils/cmdtalk.cpp',
    'utils/conftree.cpp',
    'utils/copyfile.cpp',
    'utils/cpuconf.cpp',
    'utils/ecrontab.cpp',
    'utils/execmd.cpp',
    'utils/fileudi.cpp',
    'utils/fstreewalk.cpp',
    'utils/hldata.cpp',
    'utils/idfile.cpp',
    'utils/listmem.cpp',
    'utils/log.cpp',
    'utils/md5.cpp',
    'utils/md5ut.cpp',
    'utils/mimeparse.cpp',
    'utils/miniz.cpp',
    'utils/netcon.cpp',
    'utils/pathut.cpp',
    'utils/powerstatus.cpp',
    'utils/pxattr.cpp',
    'utils/rclionice.cpp',
    'utils/readfile.cpp',
    'utils/smallut.cpp',
    'utils/strmatcher.cpp',
    'utils/transcode.cpp',
    'utils/utf8iter.cpp',
    'utils/wipedir.cpp',
    'utils/x11mon.cpp',
    'utils/zlibut.cpp',
]

if host_machine.system() == 'darwin'
    librecoll_sources += 'internfile/finderxattr.cpp'
endif
librecoll_incdir = include_directories(
    'aspell',
    'bincimapmime',
    'common',
    'index',
    'internfile',
    'rcldb',
    'unac',
    'utils',
    'xaposix',
)

if librecoll_needed
    librecoll = library(
        'librecoll',
        librecoll_sources,
        name_prefix: '',
        soversion: recoll_soversion,
        version: meson.project_version(),
        include_directories: librecoll_incdir,
        dependencies: librecolldeps,
        install: true,
    )
    librecoll_headers = files(
    'common/plaintorich.h',
    'common/rclconfig.h',
    'common/rclinit.h',
    'common/rclutil.h',
    'index/idxstatus.h',
    'internfile/Filter.h',
    'internfile/internfile.h',
    'internfile/mimehandler.h',
    'query/docseq.h',
    'query/docseqdb.h',
    'query/qresultstore.h',
    'query/reslistpager.h',
    'query/wasatorcl.h',
    'rcldb/rcldb.h',
    'rcldb/rcldoc.h',
    'rcldb/rclquery.h',
    'rcldb/searchdata.h',
    'utils/hldata.h',
    'utils/log.h',
    'utils/pathut.h',
    'utils/readfile.h',
    'utils/smallut.h',
    )
    install_headers(librecoll_headers, subdir: 'recoll')
endif

if get_option('indexer')

    recollindex_sources = [
        'index/checkindexed.cpp',
        'index/fsindexer.cpp',
        'index/indexer.cpp',
        'index/rclmonprc.cpp',
        'index/rclmonrcv.cpp',
        'index/rclmonrcv_fsevents.cpp',
        'index/rclmonrcv_inotify.cpp',
        'index/rclmonrcv_fam.cpp',
        'index/rclmonrcv_win32.cpp',
        'index/recollindex.cpp',
        'index/webqueue.cpp',
    ]

    recollindexdeps = []
    recollindexdeps += dependency('threads')
    if(apple_core_services_found)
        recollindexdeps += core_services
    endif
    recollindex = executable(
        'recollindex',
        recollindex_sources,
        include_directories: librecoll_incdir,
        dependencies: recollindexdeps,
        link_with: librecoll,
        install: true,
    )

endif

############# Recollq
if get_option('recollq')

    recollq_sources = [
        'query/recollqmain.cpp',
    ]

    recollq = executable(
        'recollq',
        recollq_sources,
        include_directories: librecoll_incdir,
        link_with: librecoll,
        install: true,
    )

endif

############# Xadump
if get_option('xadump')

    xadump_sources = [
        'query/xadump.cpp',
    ]

    xadumpdeps = []
    xadumpdeps += declare_dependency(
        link_with: librecoll,
    )
    xadumpdeps += xapian
    xadump = executable(
        'xadump',
        xadump_sources,
        include_directories: librecoll_incdir,
        dependencies: xadumpdeps,
        install: true,
    )

endif

py_mod = import('python')
python = py_mod.find_installation(
    'python3',
)
py3_dep = dependency('python3', required: true)

if get_option('python-module')
    subdir('python/recoll')
endif   
if get_option('python-aspell')
    subdir('python/pyaspell')
endif
if get_option('python-chm')
    subdir('python/pychm')
endif
if get_option('testmains')
    subdir('testmains')
endif
if get_option('rclgrep')
    subdir('rclgrep')
endif
if get_option('qtgui')
    subdir('qtgui')
endif
if get_option('catch')
   subdir('catch')
endif

manfiles = files(
'doc/man/recoll.1',
'doc/man/recoll.conf.5',
'doc/man/recollindex.1',
'doc/man/recollq.1',
'doc/man/xadump.1',
)
install_man(manfiles)

example_files = files(
'desktop/recollindex.desktop',
'index/rclmon.sh',
'index/recollindex.service',
'index/recollindex@.service',
'sampleconf/backends',
'sampleconf/fields',
'sampleconf/fragment-buttons.xml',
'sampleconf/mimeconf',
'sampleconf/mimemap',
'sampleconf/mimeview',
'sampleconf/recoll-common.css',
'sampleconf/recoll-common.qss',
'sampleconf/recoll-dark.css',
'sampleconf/recoll-dark.qss',
'sampleconf/recoll.conf',
'sampleconf/recoll.qss',
)
install_data(example_files, install_dir: get_option('datadir') / 'recoll' / 'examples')

install_subdir(
    'filters',
    install_dir: get_option('datadir') / 'recoll',
    exclude_directories: '__pycache__',
    exclude_files: ['recfiltcommon', 'injectcommon.sh',],
)

doc_files = files(
'doc/user/docbook-xsl.css',
'doc/user/usermanual.html',
)
install_data(doc_files, install_dir: get_option('datadir') / 'recoll' / 'doc')

if get_option('indexer') and get_option('systemd')
   install_data('index/recollindex@.service', install_dir: get_option('systemd-system-unit-dir'))
   install_data('index/recollindex.service', install_dir: get_option('systemd-user-unit-dir'))
endif