1 # #############################################################################
2 # Copyright (c) 2018-present Dima Krasner <dima@dimakrasner.com>
3 # lzutao <taolzu(at)gmail.com>
6 # This source code is licensed under both the BSD-style license (found in the
7 # LICENSE file in the root directory of this source tree) and the GPLv2 (found
8 # in the COPYING file in the root directory of this source tree).
9 # #############################################################################
11 zstd_rootdir = '../../..'
13 zstd_programs_sources = [join_paths(zstd_rootdir, 'programs/zstdcli.c'),
14 join_paths(zstd_rootdir, 'programs/util.c'),
15 join_paths(zstd_rootdir, 'programs/timefn.c'),
16 join_paths(zstd_rootdir, 'programs/fileio.c'),
17 join_paths(zstd_rootdir, 'programs/fileio_asyncio.c'),
18 join_paths(zstd_rootdir, 'programs/benchfn.c'),
19 join_paths(zstd_rootdir, 'programs/benchzstd.c'),
20 join_paths(zstd_rootdir, 'programs/datagen.c'),
21 join_paths(zstd_rootdir, 'programs/lorem.c'),
22 join_paths(zstd_rootdir, 'programs/dibio.c'),
23 join_paths(zstd_rootdir, 'programs/zstdcli_trace.c')]
25 zstd_deps = [ libzstd_internal_dep ]
26 zstd_c_args = libzstd_debug_cflags
28 zstd_frugal_deps = [ libzstd_internal_dep ]
29 zstd_frugal_c_args = [ '-DZSTD_NOBENCH', '-DZSTD_NODICT', '-DZSTD_NOTRACE' ]
32 zstd_deps += [ thread_dep ]
33 zstd_c_args += [ '-DZSTD_MULTITHREAD' ]
34 zstd_frugal_deps += [ thread_dep ]
35 zstd_frugal_c_args += [ '-DZSTD_MULTITHREAD' ]
39 zstd_deps += [ zlib_dep ]
40 zstd_c_args += [ '-DZSTD_GZCOMPRESS', '-DZSTD_GZDECOMPRESS' ]
44 zstd_deps += [ lzma_dep ]
45 zstd_c_args += [ '-DZSTD_LZMACOMPRESS', '-DZSTD_LZMADECOMPRESS' ]
49 zstd_deps += [ lz4_dep ]
50 zstd_c_args += [ '-DZSTD_LZ4COMPRESS', '-DZSTD_LZ4DECOMPRESS' ]
53 export_dynamic_on_windows = false
54 # explicit backtrace enable/disable for Linux & Darwin
55 have_execinfo = cc.has_header('execinfo.h', required: use_backtrace)
57 zstd_c_args += '-DBACKTRACE_ENABLE=0'
58 elif use_debug and host_machine_os == os_windows # MinGW target
59 zstd_c_args += '-DBACKTRACE_ENABLE=1'
60 export_dynamic_on_windows = true
63 if cc_id == compiler_msvc
64 if default_library_type != 'static'
65 zstd_programs_sources += [windows_mod.compile_resources(
66 join_paths(zstd_rootdir, 'build/VS2010/zstd/zstd.rc'),
67 include_directories: libzstd_includes)]
71 zstd = executable('zstd',
72 zstd_programs_sources,
74 dependencies: zstd_deps,
75 export_dynamic: export_dynamic_on_windows, # Since Meson 0.45.0
76 build_by_default: bin_programs,
77 install: bin_programs)
80 # we generate rules to build the programs, but don't install anything
81 # so do not continue to installing scripts and manpages
85 zstd_frugal_sources = [join_paths(zstd_rootdir, 'programs/zstdcli.c'),
86 join_paths(zstd_rootdir, 'programs/timefn.c'),
87 join_paths(zstd_rootdir, 'programs/util.c'),
88 join_paths(zstd_rootdir, 'programs/fileio.c'),
89 join_paths(zstd_rootdir, 'programs/fileio_asyncio.c')]
91 # Minimal target, with only zstd compression and decompression.
92 # No bench. No legacy.
93 executable('zstd-frugal',
95 dependencies: zstd_frugal_deps,
96 c_args: zstd_frugal_c_args,
99 install_data(join_paths(zstd_rootdir, 'programs/zstdgrep'),
100 join_paths(zstd_rootdir, 'programs/zstdless'),
101 install_dir: zstd_bindir)
103 # =============================================================================
104 # Programs and manpages installing
105 # =============================================================================
107 install_man(join_paths(zstd_rootdir, 'programs/zstd.1'),
108 join_paths(zstd_rootdir, 'programs/zstdgrep.1'),
109 join_paths(zstd_rootdir, 'programs/zstdless.1'))
111 InstallSymlink_py = '../InstallSymlink.py'
112 zstd_man1_dir = join_paths(zstd_mandir, 'man1')
113 bin_EXT = host_machine_os == os_windows ? '.exe' : ''
114 man1_EXT = meson.version().version_compare('>=0.49.0') ? '.1' : '.1.gz'
116 foreach f : ['zstdcat', 'unzstd']
117 meson.add_install_script(InstallSymlink_py, 'zstd' + bin_EXT, f + bin_EXT, zstd_bindir)
118 meson.add_install_script(InstallSymlink_py, 'zstd' + man1_EXT, f + man1_EXT, zstd_man1_dir)
122 meson.add_install_script(InstallSymlink_py, 'zstd' + bin_EXT, 'zstdmt' + bin_EXT, zstd_bindir)
123 meson.add_install_script(InstallSymlink_py, 'zstd' + man1_EXT, 'zstdmt' + man1_EXT, zstd_man1_dir)