1# #############################################################################
2# Copyright (c) 2018-present    lzutao <taolzu(at)gmail.com>
3# All rights reserved.
4#
5# This source code is licensed under both the BSD-style license (found in the
6# LICENSE file in the root directory of this source tree) and the GPLv2 (found
7# in the COPYING file in the root directory of this source tree).
8# #############################################################################
9
10lz4_root_dir = '../../..'
11
12lz4_includes = include_directories(join_paths(lz4_root_dir, 'programs'))
13lz4_sources = [join_paths(lz4_root_dir, 'programs/bench.c'),
14  join_paths(lz4_root_dir, 'programs/datagen.c'),
15  join_paths(lz4_root_dir, 'programs/lz4cli.c'),
16  join_paths(lz4_root_dir, 'programs/lz4io.c')]
17lz4_c_args = []
18
19export_dynamic_on_windows = false
20# explicit backtrace enable/disable for Linux & Darwin
21if not use_backtrace
22  lz4_c_args += '-DBACKTRACE_ENABLE=0'
23elif use_debug and host_machine_os == os_windows  # MinGW target
24  lz4_c_args += '-DBACKTRACE_ENABLE=1'
25  export_dynamic_on_windows = true
26endif
27
28lz4_deps = [ liblz4_dep ]
29
30lz4 = executable('lz4',
31  lz4_sources,
32  include_directories: lz4_includes,
33  c_args: lz4_c_args,
34  dependencies: lz4_deps,
35  export_dynamic: export_dynamic_on_windows, # Since Meson 0.45.0
36  install: true)
37
38# =============================================================================
39# Programs and manpages installing
40# =============================================================================
41
42install_man(join_paths(lz4_root_dir, 'programs/lz4.1'))
43
44InstallSymlink_py = '../InstallSymlink.py'
45lz4_man1_dir = join_paths(lz4_mandir, 'man1')
46bin_EXT = host_machine_os == os_windows ? '.exe' : ''
47man1_EXT = meson.version().version_compare('>=0.49.0') ? '.1' : '.1.gz'
48
49foreach f : ['lz4c', 'lz4cat', 'unlz4']
50  meson.add_install_script(InstallSymlink_py, 'lz4' + bin_EXT, f + bin_EXT, lz4_bindir)
51  meson.add_install_script(InstallSymlink_py, 'lz4' + man1_EXT, f + man1_EXT, lz4_man1_dir)
52endforeach
53