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'), |
f535537f |
21 | join_paths(zstd_rootdir, 'programs/lorem.c'), |
648db22b |
22 | join_paths(zstd_rootdir, 'programs/dibio.c'), |
23 | join_paths(zstd_rootdir, 'programs/zstdcli_trace.c')] |
24 | |
25 | zstd_deps = [ libzstd_internal_dep ] |
26 | zstd_c_args = libzstd_debug_cflags |
27 | |
28 | zstd_frugal_deps = [ libzstd_internal_dep ] |
29 | zstd_frugal_c_args = [ '-DZSTD_NOBENCH', '-DZSTD_NODICT', '-DZSTD_NOTRACE' ] |
30 | |
31 | if use_multi_thread |
32 | zstd_deps += [ thread_dep ] |
33 | zstd_c_args += [ '-DZSTD_MULTITHREAD' ] |
34 | zstd_frugal_deps += [ thread_dep ] |
35 | zstd_frugal_c_args += [ '-DZSTD_MULTITHREAD' ] |
36 | endif |
37 | |
38 | if use_zlib |
39 | zstd_deps += [ zlib_dep ] |
40 | zstd_c_args += [ '-DZSTD_GZCOMPRESS', '-DZSTD_GZDECOMPRESS' ] |
41 | endif |
42 | |
43 | if use_lzma |
44 | zstd_deps += [ lzma_dep ] |
45 | zstd_c_args += [ '-DZSTD_LZMACOMPRESS', '-DZSTD_LZMADECOMPRESS' ] |
46 | endif |
47 | |
48 | if use_lz4 |
49 | zstd_deps += [ lz4_dep ] |
50 | zstd_c_args += [ '-DZSTD_LZ4COMPRESS', '-DZSTD_LZ4DECOMPRESS' ] |
51 | endif |
52 | |
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) |
56 | if not have_execinfo |
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 |
61 | endif |
62 | |
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)] |
68 | endif |
69 | endif |
70 | |
71 | zstd = executable('zstd', |
72 | zstd_programs_sources, |
73 | c_args: zstd_c_args, |
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) |
78 | |
79 | if not 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 |
82 | subdir_done() |
83 | endif |
84 | |
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')] |
90 | |
91 | # Minimal target, with only zstd compression and decompression. |
92 | # No bench. No legacy. |
93 | executable('zstd-frugal', |
94 | zstd_frugal_sources, |
95 | dependencies: zstd_frugal_deps, |
96 | c_args: zstd_frugal_c_args, |
97 | install: true) |
98 | |
99 | install_data(join_paths(zstd_rootdir, 'programs/zstdgrep'), |
100 | join_paths(zstd_rootdir, 'programs/zstdless'), |
101 | install_dir: zstd_bindir) |
102 | |
103 | # ============================================================================= |
104 | # Programs and manpages installing |
105 | # ============================================================================= |
106 | |
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')) |
110 | |
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' |
115 | |
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) |
119 | endforeach |
120 | |
121 | if use_multi_thread |
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) |
124 | endif |