1# ############################################################################# 2# Copyright (c) 2018-present Dima Krasner <dima@dimakrasner.com> 3# lzutao <taolzu(at)gmail.com> 4# All rights reserved. 5# 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# ############################################################################# 10 11zstd_rootdir = '../../..' 12 13zstd_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/benchfn.c'), 18 join_paths(zstd_rootdir, 'programs/benchzstd.c'), 19 join_paths(zstd_rootdir, 'programs/datagen.c'), 20 join_paths(zstd_rootdir, 'programs/dibio.c'), 21 join_paths(zstd_rootdir, 'programs/zstdcli_trace.c'), 22 # needed due to use of private symbol + -fvisibility=hidden 23 join_paths(zstd_rootdir, 'lib/common/xxhash.c')] 24 25zstd_c_args = libzstd_debug_cflags 26if use_multi_thread 27 zstd_c_args += [ '-DZSTD_MULTITHREAD' ] 28endif 29 30zstd_deps = [ libzstd_dep ] 31if use_zlib 32 zstd_deps += [ zlib_dep ] 33 zstd_c_args += [ '-DZSTD_GZCOMPRESS', '-DZSTD_GZDECOMPRESS' ] 34endif 35 36if use_lzma 37 zstd_deps += [ lzma_dep ] 38 zstd_c_args += [ '-DZSTD_LZMACOMPRESS', '-DZSTD_LZMADECOMPRESS' ] 39endif 40 41if use_lz4 42 zstd_deps += [ lz4_dep ] 43 zstd_c_args += [ '-DZSTD_LZ4COMPRESS', '-DZSTD_LZ4DECOMPRESS' ] 44endif 45 46export_dynamic_on_windows = false 47# explicit backtrace enable/disable for Linux & Darwin 48if not use_backtrace 49 zstd_c_args += '-DBACKTRACE_ENABLE=0' 50elif use_debug and host_machine_os == os_windows # MinGW target 51 zstd_c_args += '-DBACKTRACE_ENABLE=1' 52 export_dynamic_on_windows = true 53endif 54 55if cc_id == compiler_msvc 56 if default_library_type != 'static' 57 zstd_programs_sources += [windows_mod.compile_resources( 58 join_paths(zstd_rootdir, 'build/VS2010/zstd/zstd.rc'))] 59 endif 60endif 61 62zstd = executable('zstd', 63 zstd_programs_sources, 64 c_args: zstd_c_args, 65 dependencies: zstd_deps, 66 export_dynamic: export_dynamic_on_windows, # Since Meson 0.45.0 67 install: true) 68 69zstd_frugal_sources = [join_paths(zstd_rootdir, 'programs/zstdcli.c'), 70 join_paths(zstd_rootdir, 'programs/timefn.c'), 71 join_paths(zstd_rootdir, 'programs/util.c'), 72 join_paths(zstd_rootdir, 'programs/fileio.c')] 73 74# Minimal target, with only zstd compression and decompression. 75# No bench. No legacy. 76executable('zstd-frugal', 77 zstd_frugal_sources, 78 dependencies: libzstd_dep, 79 c_args: [ '-DZSTD_NOBENCH', '-DZSTD_NODICT', '-DZSTD_NOTRACE' ], 80 install: true) 81 82install_data(join_paths(zstd_rootdir, 'programs/zstdgrep'), 83 join_paths(zstd_rootdir, 'programs/zstdless'), 84 install_dir: zstd_bindir) 85 86# ============================================================================= 87# Programs and manpages installing 88# ============================================================================= 89 90install_man(join_paths(zstd_rootdir, 'programs/zstd.1'), 91 join_paths(zstd_rootdir, 'programs/zstdgrep.1'), 92 join_paths(zstd_rootdir, 'programs/zstdless.1')) 93 94InstallSymlink_py = '../InstallSymlink.py' 95zstd_man1_dir = join_paths(zstd_mandir, 'man1') 96bin_EXT = host_machine_os == os_windows ? '.exe' : '' 97man1_EXT = meson.version().version_compare('>=0.49.0') ? '.1' : '.1.gz' 98 99foreach f : ['zstdcat', 'unzstd'] 100 meson.add_install_script(InstallSymlink_py, 'zstd' + bin_EXT, f + bin_EXT, zstd_bindir) 101 meson.add_install_script(InstallSymlink_py, 'zstd' + man1_EXT, f + man1_EXT, zstd_man1_dir) 102endforeach 103 104if use_multi_thread 105 meson.add_install_script(InstallSymlink_py, 'zstd' + bin_EXT, 'zstdmt' + bin_EXT, zstd_bindir) 106 meson.add_install_script(InstallSymlink_py, 'zstd' + man1_EXT, 'zstdmt' + man1_EXT, zstd_man1_dir) 107endif 108