aboutsummaryrefslogtreecommitdiff
path: root/build/meson/programs/meson.build
blob: e103a629539c94e9673f887c83d815f4bf077bd2 (plain)
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
# #############################################################################
# Copyright (c) 2018-present     Dima Krasner <dima@dimakrasner.com>
#                                lzutao <taolzu(at)gmail.com>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################

zstd_rootdir = '../../..'

zstd_programs_sources = [join_paths(zstd_rootdir, 'programs/zstdcli.c'),
  join_paths(zstd_rootdir, 'programs/util.c'),
  join_paths(zstd_rootdir, 'programs/timefn.c'),
  join_paths(zstd_rootdir, 'programs/fileio.c'),
  join_paths(zstd_rootdir, 'programs/fileio_asyncio.c'),
  join_paths(zstd_rootdir, 'programs/benchfn.c'),
  join_paths(zstd_rootdir, 'programs/benchzstd.c'),
  join_paths(zstd_rootdir, 'programs/datagen.c'),
  join_paths(zstd_rootdir, 'programs/lorem.c'),
  join_paths(zstd_rootdir, 'programs/dibio.c'),
  join_paths(zstd_rootdir, 'programs/zstdcli_trace.c')]

zstd_deps = [ libzstd_internal_dep ]
zstd_c_args = libzstd_debug_cflags

zstd_frugal_deps = [ libzstd_internal_dep ]
zstd_frugal_c_args = [ '-DZSTD_NOBENCH', '-DZSTD_NODICT', '-DZSTD_NOTRACE' ]

if use_multi_thread
  zstd_deps += [ thread_dep ]
  zstd_c_args += [ '-DZSTD_MULTITHREAD' ]
  zstd_frugal_deps += [ thread_dep ]
  zstd_frugal_c_args += [ '-DZSTD_MULTITHREAD' ]
endif

if use_zlib
  zstd_deps += [ zlib_dep ]
  zstd_c_args += [ '-DZSTD_GZCOMPRESS', '-DZSTD_GZDECOMPRESS' ]
endif

if use_lzma
  zstd_deps += [ lzma_dep ]
  zstd_c_args += [ '-DZSTD_LZMACOMPRESS', '-DZSTD_LZMADECOMPRESS' ]
endif

if use_lz4
  zstd_deps += [ lz4_dep ]
  zstd_c_args += [ '-DZSTD_LZ4COMPRESS', '-DZSTD_LZ4DECOMPRESS' ]
endif

export_dynamic_on_windows = false
# explicit backtrace enable/disable for Linux & Darwin
have_execinfo = cc.has_header('execinfo.h', required: use_backtrace)
if not have_execinfo
  zstd_c_args += '-DBACKTRACE_ENABLE=0'
elif use_debug and host_machine_os == os_windows  # MinGW target
  zstd_c_args += '-DBACKTRACE_ENABLE=1'
  export_dynamic_on_windows = true
endif

if cc_id == compiler_msvc
  if default_library_type != 'static'
    zstd_programs_sources += [windows_mod.compile_resources(
      join_paths(zstd_rootdir, 'build/VS2010/zstd/zstd.rc'),
      include_directories: libzstd_includes)]
  endif
endif

zstd = executable('zstd',
  zstd_programs_sources,
  c_args: zstd_c_args,
  dependencies: zstd_deps,
  export_dynamic: export_dynamic_on_windows, # Since Meson 0.45.0
  build_by_default: bin_programs,
  install: bin_programs)

if not bin_programs
  # we generate rules to build the programs, but don't install anything
  # so do not continue to installing scripts and manpages
  subdir_done()
endif

zstd_frugal_sources = [join_paths(zstd_rootdir, 'programs/zstdcli.c'),
  join_paths(zstd_rootdir, 'programs/timefn.c'),
  join_paths(zstd_rootdir, 'programs/util.c'),
  join_paths(zstd_rootdir, 'programs/fileio.c'),
  join_paths(zstd_rootdir, 'programs/fileio_asyncio.c')]

# Minimal target, with only zstd compression and decompression.
# No bench. No legacy.
executable('zstd-frugal',
  zstd_frugal_sources,
  dependencies: zstd_frugal_deps,
  c_args: zstd_frugal_c_args,
  install: true)

install_data(join_paths(zstd_rootdir, 'programs/zstdgrep'),
  join_paths(zstd_rootdir, 'programs/zstdless'),
  install_dir: zstd_bindir)

# =============================================================================
# Programs and manpages installing
# =============================================================================

install_man(join_paths(zstd_rootdir, 'programs/zstd.1'),
  join_paths(zstd_rootdir, 'programs/zstdgrep.1'),
  join_paths(zstd_rootdir, 'programs/zstdless.1'))

InstallSymlink_py = '../InstallSymlink.py'
zstd_man1_dir = join_paths(zstd_mandir, 'man1')
bin_EXT = host_machine_os == os_windows ? '.exe' : ''
man1_EXT = meson.version().version_compare('>=0.49.0') ? '.1' : '.1.gz'

foreach f : ['zstdcat', 'unzstd']
  meson.add_install_script(InstallSymlink_py, 'zstd' + bin_EXT, f + bin_EXT, zstd_bindir)
  meson.add_install_script(InstallSymlink_py, 'zstd' + man1_EXT, f + man1_EXT, zstd_man1_dir)
endforeach

if use_multi_thread
  meson.add_install_script(InstallSymlink_py, 'zstd' + bin_EXT, 'zstdmt' + bin_EXT, zstd_bindir)
  meson.add_install_script(InstallSymlink_py, 'zstd' + man1_EXT, 'zstdmt' + man1_EXT, zstd_man1_dir)
endif