648db22b |
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 | |
11 | zstd_rootdir = '../../..' |
12 | |
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/dibio.c'), |
22 | join_paths(zstd_rootdir, 'programs/zstdcli_trace.c')] |
23 | |
24 | zstd_deps = [ libzstd_internal_dep ] |
25 | zstd_c_args = libzstd_debug_cflags |
26 | |
27 | zstd_frugal_deps = [ libzstd_internal_dep ] |
28 | zstd_frugal_c_args = [ '-DZSTD_NOBENCH', '-DZSTD_NODICT', '-DZSTD_NOTRACE' ] |
29 | |
30 | if use_multi_thread |
31 | zstd_deps += [ thread_dep ] |
32 | zstd_c_args += [ '-DZSTD_MULTITHREAD' ] |
33 | zstd_frugal_deps += [ thread_dep ] |
34 | zstd_frugal_c_args += [ '-DZSTD_MULTITHREAD' ] |
35 | endif |
36 | |
37 | if use_zlib |
38 | zstd_deps += [ zlib_dep ] |
39 | zstd_c_args += [ '-DZSTD_GZCOMPRESS', '-DZSTD_GZDECOMPRESS' ] |
40 | endif |
41 | |
42 | if use_lzma |
43 | zstd_deps += [ lzma_dep ] |
44 | zstd_c_args += [ '-DZSTD_LZMACOMPRESS', '-DZSTD_LZMADECOMPRESS' ] |
45 | endif |
46 | |
47 | if use_lz4 |
48 | zstd_deps += [ lz4_dep ] |
49 | zstd_c_args += [ '-DZSTD_LZ4COMPRESS', '-DZSTD_LZ4DECOMPRESS' ] |
50 | endif |
51 | |
52 | export_dynamic_on_windows = false |
53 | # explicit backtrace enable/disable for Linux & Darwin |
54 | have_execinfo = cc.has_header('execinfo.h', required: use_backtrace) |
55 | if not have_execinfo |
56 | zstd_c_args += '-DBACKTRACE_ENABLE=0' |
57 | elif use_debug and host_machine_os == os_windows # MinGW target |
58 | zstd_c_args += '-DBACKTRACE_ENABLE=1' |
59 | export_dynamic_on_windows = true |
60 | endif |
61 | |
62 | if cc_id == compiler_msvc |
63 | if default_library_type != 'static' |
64 | zstd_programs_sources += [windows_mod.compile_resources( |
65 | join_paths(zstd_rootdir, 'build/VS2010/zstd/zstd.rc'), |
66 | include_directories: libzstd_includes)] |
67 | endif |
68 | endif |
69 | |
70 | zstd = executable('zstd', |
71 | zstd_programs_sources, |
72 | c_args: zstd_c_args, |
73 | dependencies: zstd_deps, |
74 | export_dynamic: export_dynamic_on_windows, # Since Meson 0.45.0 |
75 | build_by_default: bin_programs, |
76 | install: bin_programs) |
77 | |
78 | if not bin_programs |
79 | # we generate rules to build the programs, but don't install anything |
80 | # so do not continue to installing scripts and manpages |
81 | subdir_done() |
82 | endif |
83 | |
84 | zstd_frugal_sources = [join_paths(zstd_rootdir, 'programs/zstdcli.c'), |
85 | join_paths(zstd_rootdir, 'programs/timefn.c'), |
86 | join_paths(zstd_rootdir, 'programs/util.c'), |
87 | join_paths(zstd_rootdir, 'programs/fileio.c'), |
88 | join_paths(zstd_rootdir, 'programs/fileio_asyncio.c')] |
89 | |
90 | # Minimal target, with only zstd compression and decompression. |
91 | # No bench. No legacy. |
92 | executable('zstd-frugal', |
93 | zstd_frugal_sources, |
94 | dependencies: zstd_frugal_deps, |
95 | c_args: zstd_frugal_c_args, |
96 | install: true) |
97 | |
98 | install_data(join_paths(zstd_rootdir, 'programs/zstdgrep'), |
99 | join_paths(zstd_rootdir, 'programs/zstdless'), |
100 | install_dir: zstd_bindir) |
101 | |
102 | # ============================================================================= |
103 | # Programs and manpages installing |
104 | # ============================================================================= |
105 | |
106 | install_man(join_paths(zstd_rootdir, 'programs/zstd.1'), |
107 | join_paths(zstd_rootdir, 'programs/zstdgrep.1'), |
108 | join_paths(zstd_rootdir, 'programs/zstdless.1')) |
109 | |
110 | InstallSymlink_py = '../InstallSymlink.py' |
111 | zstd_man1_dir = join_paths(zstd_mandir, 'man1') |
112 | bin_EXT = host_machine_os == os_windows ? '.exe' : '' |
113 | man1_EXT = meson.version().version_compare('>=0.49.0') ? '.1' : '.1.gz' |
114 | |
115 | foreach f : ['zstdcat', 'unzstd'] |
116 | meson.add_install_script(InstallSymlink_py, 'zstd' + bin_EXT, f + bin_EXT, zstd_bindir) |
117 | meson.add_install_script(InstallSymlink_py, 'zstd' + man1_EXT, f + man1_EXT, zstd_man1_dir) |
118 | endforeach |
119 | |
120 | if use_multi_thread |
121 | meson.add_install_script(InstallSymlink_py, 'zstd' + bin_EXT, 'zstdmt' + bin_EXT, zstd_bindir) |
122 | meson.add_install_script(InstallSymlink_py, 'zstd' + man1_EXT, 'zstdmt' + man1_EXT, zstd_man1_dir) |
123 | endif |