--- /dev/null
+#!/usr/bin/env python3
+# #############################################################################
+# Copyright (c) 2018-present 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).
+# #############################################################################
+import os
+import sys
+import shutil
+
+
+def usage():
+ print('usage: python3 CreateSymlink.py <src> <dst>')
+ print('Copy the file named src to a file named dst')
+ sys.exit(1)
+
+
+def main():
+ if len(sys.argv) < 3:
+ usage()
+ src = sys.argv[1]
+ dst = sys.argv[2]
+
+ if os.path.exists(dst):
+ print ('File already exists: %r' % (dst))
+ return
+
+ shutil.copy2(src, dst)
+
+
+if __name__ == '__main__':
+ main()
--- /dev/null
+#!/usr/bin/env python3
+# #############################################################################
+# Copyright (c) 2018-present 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).
+# #############################################################################
+import os
+import sys
+
+
+def usage():
+ print('usage: python3 CreateSymlink.py <src> <dst> [dst is dir: True or False]')
+ sys.exit(1)
+
+
+def main():
+ if len(sys.argv) < 3:
+ usage()
+ src = sys.argv[1]
+ dst = sys.argv[2]
+ is_dir = False
+ if len(sys.argv) == 4:
+ is_dir = bool(sys.argv[3])
+
+ if os.path.islink(dst) and os.readlink(dst) == src:
+ print ('File exists: %r -> %r' % (dst, src))
+ return
+
+ os.symlink(src, dst, is_dir)
+
+
+if __name__ == '__main__':
+ main()
--- /dev/null
+#!/usr/bin/env python3
+# #############################################################################
+# Copyright (c) 2018-present 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).
+# #############################################################################
+import re
+import sys
+
+
+def usage():
+ print('usage: python3 GetZstdLibraryVersion.py <path/to/zstd.h>')
+ sys.exit(1)
+
+
+def find_version(filepath):
+ version_file_data = None
+ with open(filepath) as fd:
+ version_file_data = fd.read()
+
+ patterns = r"""#\s*define\s+ZSTD_VERSION_MAJOR\s+([0-9]+)
+#\s*define\s+ZSTD_VERSION_MINOR\s+([0-9]+)
+#\s*define\s+ZSTD_VERSION_RELEASE\s+([0-9]+)
+"""
+ regex = re.compile(patterns, re.MULTILINE)
+ version_match = regex.search(version_file_data)
+ if version_match:
+ return version_match.groups()
+ raise RuntimeError("Unable to find version string.")
+
+
+def main():
+ if len(sys.argv) < 2:
+ usage()
+
+ filepath = sys.argv[1]
+ version_tup = find_version(filepath)
+ print('.'.join(version_tup))
+
+
+if __name__ == '__main__':
+ main()
--- /dev/null
+# #############################################################################
+# Copyright (c) 2018-present 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_source_dir = join_paths('..', '..', '..', '..')
+library_dir = join_paths(zstd_source_dir, 'lib')
+library_common_dir = join_paths(library_dir, 'common')
+programs_dir = join_paths(zstd_source_dir, 'programs')
+contrib_gen_html_dir = join_paths(zstd_source_dir, 'contrib', 'gen_html')
+
+gen_html_includes = include_directories(programs_dir,
+ library_dir,
+ library_common_dir,
+ contrib_gen_html_dir )
+
+gen_html = executable('gen_html',
+ join_paths(contrib_gen_html_dir, 'gen_html.cpp'),
+ include_directories: gen_html_includes,
+ install: false )
+
+# Update zstd manual
+zstd_manual_html = custom_target('zstd_manual.html',
+ output : 'zstd_manual.html',
+ command : [
+ gen_html,
+ zstd_version,
+ join_paths(meson.current_source_dir(), library_dir, 'zstd.h'),
+ '@OUTPUT@'
+ ],
+ install : true,
+ install_dir : zstd_docdir )
--- /dev/null
+# #############################################################################
+# 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).
+# #############################################################################
+
+subdir('pzstd')
+subdir('gen_html')
--- /dev/null
+# #############################################################################
+# Copyright (c) 2018-present 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_source_dir = join_paths('..', '..', '..', '..')
+library_dir = join_paths(zstd_source_dir, 'lib')
+library_common_dir = join_paths(library_dir, 'common')
+programs_dir = join_paths(zstd_source_dir, 'programs')
+contrib_pzstd_dir = join_paths(zstd_source_dir, 'contrib', 'pzstd')
+
+pzstd_includes = include_directories(programs_dir,
+ library_dir,
+ library_common_dir,
+ contrib_pzstd_dir)
+pzstd_sources = [join_paths(programs_dir, 'util.c'),
+ join_paths(contrib_pzstd_dir, 'main.cpp'),
+ join_paths(contrib_pzstd_dir, 'Options.cpp'),
+ join_paths(contrib_pzstd_dir, 'Pzstd.cpp'),
+ join_paths(contrib_pzstd_dir, 'SkippableFrame.cpp')]
+
+pzstd = executable('pzstd',
+ pzstd_sources,
+ cpp_args: [ '-DNDEBUG', '-Wno-shadow' ],
+ include_directories: pzstd_includes,
+ link_with: libzstd,
+ dependencies: [ thread_dep ],
+ install: true)
--- /dev/null
+# #############################################################################
+# 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_source_dir = join_paths('..', '..', '..')
+library_dir = join_paths(zstd_source_dir, 'lib')
+library_common_dir = join_paths(library_dir, 'common')
+library_compress_dir = join_paths(library_dir, 'compress')
+library_decompress_dir = join_paths(library_dir, 'decompress')
+library_dictbuilder_dir = join_paths(library_dir, 'dictBuilder')
+library_deprecated_dir = join_paths(library_dir, 'deprecated')
+library_legacy_dir = join_paths(library_dir, 'legacy')
+
+libzstd_includes = [include_directories(library_dir,
+ library_common_dir,
+ library_compress_dir,
+ library_decompress_dir,
+ library_dictbuilder_dir,
+ library_deprecated_dir)]
+
+libzstd_sources = [join_paths(library_common_dir, 'entropy_common.c'),
+ join_paths(library_common_dir, 'fse_decompress.c'),
+ join_paths(library_common_dir, 'threading.c'),
+ join_paths(library_common_dir, 'pool.c'),
+ join_paths(library_common_dir, 'zstd_common.c'),
+ join_paths(library_common_dir, 'error_private.c'),
+ join_paths(library_common_dir, 'xxhash.c'),
+ join_paths(library_compress_dir, 'hist.c'),
+ join_paths(library_compress_dir, 'fse_compress.c'),
+ join_paths(library_compress_dir, 'huf_compress.c'),
+ join_paths(library_compress_dir, 'zstd_compress.c'),
+ join_paths(library_compress_dir, 'zstdmt_compress.c'),
+ join_paths(library_compress_dir, 'zstd_fast.c'),
+ join_paths(library_compress_dir, 'zstd_double_fast.c'),
+ join_paths(library_compress_dir, 'zstd_lazy.c'),
+ join_paths(library_compress_dir, 'zstd_opt.c'),
+ join_paths(library_compress_dir, 'zstd_ldm.c'),
+ join_paths(library_decompress_dir, 'huf_decompress.c'),
+ join_paths(library_decompress_dir, 'zstd_decompress.c'),
+ join_paths(library_decompress_dir, 'zstd_decompress_block.c'),
+ join_paths(library_decompress_dir, 'zstd_ddict.c'),
+ join_paths(library_dictbuilder_dir, 'cover.c'),
+ join_paths(library_dictbuilder_dir, 'fastcover.c'),
+ join_paths(library_dictbuilder_dir, 'divsufsort.c'),
+ join_paths(library_dictbuilder_dir, 'zdict.c'),
+ join_paths(library_deprecated_dir, 'zbuff_common.c'),
+ join_paths(library_deprecated_dir, 'zbuff_compress.c'),
+ join_paths(library_deprecated_dir, 'zbuff_decompress.c')]
+
+if legacy_support == '0'
+ legacy_support = 'false'
+endif
+if legacy_support != 'false'
+ if legacy_support == 'true'
+ legacy_support = '1'
+ endif
+ legacy_int = legacy_support.to_int()
+ if legacy_int < 0 or legacy_int >= 8
+ legacy_int = 0
+ endif
+ add_project_arguments('-DZSTD_LEGACY_SUPPORT=@0@'.format(legacy_int),
+ language: 'c')
+ libzstd_includes += [ include_directories(library_legacy_dir) ]
+ # See ZSTD_LEGACY_SUPPORT of programs/README.md
+ message('Enable legacy support back to version 0.@0@'.format(legacy_int))
+ if legacy_int <= 1
+ libzstd_sources += join_paths(library_legacy_dir, 'zstd_v01.c')
+ endif
+ if legacy_int <= 2
+ libzstd_sources += join_paths(library_legacy_dir, 'zstd_v02.c')
+ endif
+ if legacy_int <= 3
+ libzstd_sources += join_paths(library_legacy_dir, 'zstd_v03.c')
+ endif
+ if legacy_int <= 4
+ libzstd_sources += join_paths(library_legacy_dir, 'zstd_v04.c')
+ endif
+ if legacy_int <= 5
+ libzstd_sources += join_paths(library_legacy_dir, 'zstd_v05.c')
+ endif
+ if legacy_int <= 6
+ libzstd_sources += join_paths(library_legacy_dir, 'zstd_v06.c')
+ endif
+ if legacy_int <= 7
+ libzstd_sources += join_paths(library_legacy_dir, 'zstd_v07.c')
+ endif
+endif
+
+if enable_multithread
+ message('Enable multi-threading support')
+ add_project_arguments('-DZSTD_MULTITHREAD', language: 'c')
+ libzstd_deps = [ thread_dep ]
+else
+ libzstd_deps = []
+endif
+
+libzstd = library('zstd',
+ libzstd_sources,
+ include_directories: libzstd_includes,
+ dependencies: libzstd_deps,
+ install: true,
+ soversion: '1')
+
+pkgconfig.generate(name: 'libzstd',
+ description: 'fast lossless compression algorithm library',
+ version: zstd_version,
+ filebase: 'libzstd',
+ libraries: [libzstd],
+ #subdirs: ['.']
+ )
+
+install_headers(join_paths(library_dir, 'zstd.h'),
+ join_paths(library_deprecated_dir, 'zbuff.h'),
+ join_paths(library_dictbuilder_dir, 'zdict.h'),
+ join_paths(library_dictbuilder_dir, 'cover.h'),
+ join_paths(library_common_dir, 'zstd_errors.h'))
-project('zstd', 'c', license: 'BSD')
-
-libm = meson.get_compiler('c').find_library('m', required: true)
-
-lib_dir = join_paths('..', '..', 'lib')
-common_dir = join_paths(lib_dir, 'common')
-compress_dir = join_paths(lib_dir, 'compress')
-decompress_dir = join_paths(lib_dir, 'decompress')
-dictbuilder_dir = join_paths(lib_dir, 'dictBuilder')
-deprecated_dir = join_paths(lib_dir, 'deprecated')
-
-libzstd_srcs = [
- join_paths(common_dir, 'entropy_common.c'),
- join_paths(common_dir, 'fse_decompress.c'),
- join_paths(common_dir, 'threading.c'),
- join_paths(common_dir, 'pool.c'),
- join_paths(common_dir, 'zstd_common.c'),
- join_paths(common_dir, 'error_private.c'),
- join_paths(common_dir, 'xxhash.c'),
- join_paths(compress_dir, 'fse_compress.c'),
- join_paths(compress_dir, 'hist.c'),
- join_paths(compress_dir, 'huf_compress.c'),
- join_paths(compress_dir, 'zstd_compress.c'),
- join_paths(compress_dir, 'zstd_fast.c'),
- join_paths(compress_dir, 'zstd_double_fast.c'),
- join_paths(compress_dir, 'zstd_lazy.c'),
- join_paths(compress_dir, 'zstd_opt.c'),
- join_paths(compress_dir, 'zstd_ldm.c'),
- join_paths(compress_dir, 'zstdmt_compress.c'),
- join_paths(decompress_dir, 'huf_decompress.c'),
- join_paths(decompress_dir, 'zstd_decompress.c'),
- join_paths(dictbuilder_dir, 'cover.c'),
- join_paths(dictbuilder_dir, 'divsufsort.c'),
- join_paths(dictbuilder_dir, 'zdict.c'),
- join_paths(deprecated_dir, 'zbuff_common.c'),
- join_paths(deprecated_dir, 'zbuff_compress.c'),
- join_paths(deprecated_dir, 'zbuff_decompress.c')
-]
-
-libzstd_includes = [include_directories(common_dir, dictbuilder_dir, compress_dir, lib_dir)]
-
-legacy = get_option('legacy_support')
-if legacy == '0'
- legacy = 'false'
-endif
-if legacy != 'false'
- if legacy == 'true'
- legacy = '1'
- endif
- #See ZSTD_LEGACY_SUPPORT of programs/README.md
- message('Enabling legacy support back to version 0.' + legacy)
- legacy_int = legacy.to_int()
- if legacy_int > 7
- legacy_int = 7
- endif
- libzstd_cflags = ['-DZSTD_LEGACY_SUPPORT=' + legacy]
+# #############################################################################
+# 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).
+# #############################################################################
- legacy_dir = join_paths(lib_dir, 'legacy')
- libzstd_includes += [include_directories(legacy_dir)]
- if legacy_int <= 1
- libzstd_srcs += join_paths(legacy_dir, 'zstd_v01.c')
- endif
- if legacy_int <= 2
- libzstd_srcs += join_paths(legacy_dir, 'zstd_v02.c')
- endif
- if legacy_int <= 3
- libzstd_srcs += join_paths(legacy_dir, 'zstd_v03.c')
- endif
- if legacy_int <= 4
- libzstd_srcs += join_paths(legacy_dir, 'zstd_v04.c')
- endif
- if legacy_int <= 5
- libzstd_srcs += join_paths(legacy_dir, 'zstd_v05.c')
- endif
- if legacy_int <= 6
- libzstd_srcs += join_paths(legacy_dir, 'zstd_v06.c')
- endif
- if legacy_int <= 7
- libzstd_srcs += join_paths(legacy_dir, 'zstd_v07.c')
+project('zstd',
+ ['c', 'cpp'],
+ license: 'BSD',
+ default_options : ['c_std=c99',
+ 'cpp_std=c++11',
+ 'buildtype=release'],
+ version: '1.3.7',
+ # for install_man
+ meson_version: '>=0.47.0')
+
+cc = meson.get_compiler('c')
+cxx = meson.get_compiler('cpp')
+pkgconfig = import('pkgconfig')
+python3 = import('python').find_installation()
+
+zstd_version = meson.project_version()
+
+# =============================================================================
+# Project directories
+# =============================================================================
+
+zstd_prefix = get_option('prefix')
+zstd_bindir = join_paths(zstd_prefix, get_option('bindir'))
+zstd_datadir = join_paths(zstd_prefix, get_option('datadir'))
+zstd_docdir = join_paths(zstd_datadir, 'doc', meson.project_name())
+zstd_mandir = join_paths(zstd_prefix, get_option('mandir'))
+
+zstd_source_dir = join_paths('..', '..')
+library_dir = join_paths(zstd_source_dir, 'lib')
+contrib_meson_dir = join_paths(zstd_source_dir, 'contrib', 'meson')
+
+# =============================================================================
+# Project options
+# =============================================================================
+
+legacy_support = get_option('legacy_support')
+enable_programs = get_option('build_programs')
+enable_tests = get_option('build_tests')
+enable_contrib = get_option('build_contrib')
+enable_multithread = get_option('multithread_support')
+enable_zlib = get_option('zlib_support')
+enable_lzma = get_option('lzma_support')
+
+# =============================================================================
+# Getting project version from zstd.h
+# =============================================================================
+
+GetZstdLibraryVersion_py = files('GetZstdLibraryVersion.py')
+zstd_h_file = join_paths(library_dir, 'zstd.h')
+r = run_command(python3, GetZstdLibraryVersion_py, zstd_h_file)
+if r.returncode() == 0
+ output = r.stdout().strip()
+ if output.version_compare('>@0@'.format(zstd_version))
+ zstd_version = output
+ message('Project version is now: @0@'.format(zstd_version))
endif
-else
- libzstd_cflags = []
endif
-if get_option('multithread')
- message('Enabling multi-threading support')
- add_global_arguments('-DZSTD_MULTITHREAD', language: 'c')
- libzstd_deps = [dependency('threads')]
-else
- libzstd_deps = []
+# =============================================================================
+# Dependencies
+# =============================================================================
+
+libm_dep = cc.find_library('m', required: true)
+thread_dep = dependency('threads', required: false)
+zlib_dep = dependency('zlib', required: false)
+lzma_dep = dependency('lzma', required: false)
+
+# =============================================================================
+# Compiler flags
+# =============================================================================
+
+if cxx.get_id() == 'gcc' or cxx.get_id() == 'clang'
+ common_flags = [ '-DXXH_NAMESPACE=ZSTD_' ]
+ zstd_compilation_flags = [ '-Wextra', '-Wundef', '-Wshadow', '-Wcast-align', '-Wcast-qual' ]
+ cc_common_flags = cc.get_supported_arguments(zstd_compilation_flags)
+ cc_common_flags += cc.get_supported_arguments(['-Wstrict-prototypes'])
+ cc_common_flags += common_flags
+ cxx_common_flags = cxx.get_supported_arguments(zstd_compilation_flags)
+ cxx_common_flags += common_flags
+ add_project_arguments(cc_common_flags, language : 'c')
+ add_project_arguments(cxx_common_flags, language : 'cpp')
+endif
+
+# =============================================================================
+# Subdirs
+# =============================================================================
+
+subdir('lib')
+if enable_programs
+ subdir('programs')
+endif
+
+if enable_tests
+ subdir('tests')
endif
-libzstd = library('zstd',
- libzstd_srcs,
- include_directories: libzstd_includes,
- c_args: libzstd_cflags,
- dependencies: libzstd_deps,
- install: true,
- soversion: '1',
- )
-
-programs_dir = join_paths('..', '..', 'programs')
-
-zstd = executable('zstd',
- join_paths(programs_dir, 'bench.c'),
- join_paths(programs_dir, 'datagen.c'),
- join_paths(programs_dir, 'dibio.c'),
- join_paths(programs_dir, 'fileio.c'),
- join_paths(programs_dir, 'zstdcli.c'),
- include_directories: libzstd_includes,
- c_args: ['-DZSTD_NODICT', '-DZSTD_NOBENCH'],
- link_with: libzstd,
- install: true)
-
-tests_dir = join_paths('..', '..', 'tests')
-datagen_c = join_paths(programs_dir, 'datagen.c')
-test_includes = libzstd_includes + [include_directories(programs_dir)]
-
-fullbench = executable('fullbench',
- datagen_c, join_paths(tests_dir, 'fullbench.c'),
- include_directories: test_includes,
- link_with: libzstd)
-test('fullbench', fullbench)
-
-fuzzer = executable('fuzzer',
- datagen_c, join_paths(tests_dir, 'fuzzer.c'),
- include_directories: test_includes,
- link_with: libzstd)
-test('fuzzer', fuzzer)
-
-if target_machine.system() != 'windows'
- paramgrill = executable('paramgrill',
- datagen_c, join_paths(tests_dir, 'paramgrill.c'),
- join_paths(programs_dir, 'bench.c'),
- include_directories: test_includes,
- link_with: libzstd,
- dependencies: libm)
- test('paramgrill', paramgrill)
-
- datagen = executable('datagen',
- datagen_c, join_paths(tests_dir, 'datagencli.c'),
- include_directories: test_includes,
- link_with: libzstd)
+if enable_contrib
+ subdir('contrib')
endif
-option('multithread', type: 'boolean', value: false)
+# #############################################################################
+# 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).
+# #############################################################################
+
+option('multithread_support', type: 'boolean', value: true,
+ description: 'Enable multithreading when pthread is detected')
option('legacy_support', type: 'string', value: '4',
- description: 'True or false, or 7 to 1 for v0.7+ to v0.1+.')
+ description: 'Support any legacy format: true or false, or 7 to 1 for v0.7+ to v0.1+')
+option('build_programs', type: 'boolean', value: true,
+ description: 'Enable programs build')
+option('build_contrib', type: 'boolean', value: false,
+ description: 'Enable contrib build')
+option('build_tests', type: 'boolean', value: false,
+ description: 'Enable tests build')
+option('use_static_runtime', type: 'boolean', value: false,
+ description: 'Link to static run-time libraries on MSVC')
+option('zlib_support', type: 'boolean', value: false,
+ description: 'Enable zlib support')
+option('lzma_support', type: 'boolean', value: false,
+ description: 'Enable lzma support')
--- /dev/null
+# #############################################################################
+# 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_source_dir = join_paths('..', '..', '..')
+programs_dir = join_paths(zstd_source_dir, 'programs')
+
+zstdcli_c_file = join_paths(programs_dir, 'zstdcli.c')
+util_c_file = join_paths(programs_dir, 'util.c')
+fileio_c_file = join_paths(programs_dir, 'fileio.c')
+zstd_programs_sources = [zstdcli_c_file,
+ util_c_file,
+ fileio_c_file,
+ join_paths(programs_dir, 'benchfn.c'),
+ join_paths(programs_dir, 'benchzstd.c'),
+ join_paths(programs_dir, 'datagen.c'),
+ join_paths(programs_dir, 'dibio.c')]
+
+zstd_c_args = []
+if enable_multithread
+ zstd_c_args += [ '-DZSTD_MULTITHREAD' ]
+endif
+
+zstd_deps = []
+if enable_zlib and zlib_dep.found()
+ zstd_deps += [ zlib_dep ]
+ zstd_c_args += [ '-DZSTD_GZCOMPRESS', '-DZSTD_GZDECOMPRESS' ]
+endif
+
+if enable_lzma and lzma_dep.found()
+ zstd_deps += [ lzma_dep ]
+ zstd_c_args += [ '-DZSTD_LZMACOMPRESS', '-DZSTD_LZMADECOMPRESS' ]
+endif
+
+zstd = executable('zstd',
+ zstd_programs_sources,
+ c_args: zstd_c_args,
+ include_directories: libzstd_includes,
+ link_with: libzstd,
+ dependencies: zstd_deps,
+ install: true)
+
+zstd_frugal_sources = [join_paths(programs_dir, 'zstdcli.c'),
+ util_c_file,
+ fileio_c_file]
+
+executable('zstd-frugal',
+ zstd_frugal_sources,
+ include_directories: libzstd_includes,
+ link_with: libzstd,
+ c_args: [ '-DZSTD_NOBENCH', '-DZSTD_NODICT' ],
+ install: true)
+
+# =============================================================================
+# Program symlinks
+# =============================================================================
+
+CreateSymlink_py = join_paths(meson.current_source_dir(), '..', 'CreateSymlink.py')
+
+foreach f : [ 'zstdcat', 'unzstd' ]
+ custom_target(f,
+ output : f,
+ input: zstd,
+ command : [python3, CreateSymlink_py, '@PLAINNAME@', '@OUTPUT@'],
+ build_always_stale: false,
+ install : true,
+ install_dir: zstd_bindir)
+endforeach
+
+if enable_multithread
+ custom_target('zstdmt',
+ output : 'zstdmt',
+ input: zstd,
+ command : [python3, CreateSymlink_py, '@PLAINNAME@', '@OUTPUT@'],
+ build_always_stale: false,
+ install : true,
+ install_dir: zstd_bindir)
+endif
+
+# =============================================================================
+# Manpages
+# =============================================================================
+
+zstd_man1_dir = join_paths(zstd_mandir, 'man1')
+zstd_1_file = join_paths(programs_dir, 'zstd.1')
+CopyFile_py = join_paths(meson.current_source_dir(), '..', 'CopyFile.py')
+
+custom_target('zstd.1',
+ output : 'zstd.1',
+ input: zstd_1_file,
+ command : [python3, CopyFile_py, '@INPUT@', '@OUTPUT@'],
+ build_always_stale: false,
+ install : true,
+ install_dir: zstd_man1_dir)
+
+foreach f : [ 'zstdcat.1', 'unzstd.1' ]
+ custom_target(f,
+ output : f,
+ input: zstd_1_file,
+ command : [python3, CreateSymlink_py, '@PLAINNAME@', '@OUTPUT@'],
+ install : true,
+ build_always_stale: false,
+ install_dir: zstd_man1_dir)
+endforeach
+
+install_man(join_paths(programs_dir, 'zstdgrep.1'),
+ join_paths(programs_dir, 'zstdless.1'))
--- /dev/null
+# #############################################################################
+# 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_source_dir = join_paths('..', '..', '..')
+programs_dir = join_paths(zstd_source_dir, 'programs')
+tests_dir = join_paths(zstd_source_dir, 'tests')
+
+datagen_c_file = join_paths(programs_dir, 'datagen.c')
+util_c_file = join_paths(programs_dir, 'util.c')
+benchfn_c_file = join_paths(programs_dir, 'benchfn.c')
+
+datagen_sources = [datagen_c_file,
+ join_paths(tests_dir, 'datagencli.c')]
+test_includes = libzstd_includes + [include_directories(programs_dir)]
+
+datagen = executable('datagen',
+ datagen_sources,
+ include_directories: test_includes,
+ link_with: libzstd,
+ install: false)
+test('datagen', datagen)
+
+fullbench_sources = [datagen_c_file,
+ util_c_file,
+ benchfn_c_file,
+ join_paths(programs_dir, 'benchzstd.c'),
+ join_paths(programs_dir, 'fullbench.c')]
+fullbench = executable('fullbench',
+ fullbench_sources,
+ include_directories: test_includes,
+ link_with: libzstd,
+ install: false)
+test('fullbench', fullbench)
+
+fuzzer_sources = [datagen_c_file,
+ util_c_file,
+ join_paths(tests_dir, 'fuzzer.c')]
+fuzzer = executable('fuzzer',
+ fuzzer_sources,
+ include_directories: test_includes,
+ link_with: libzstd,
+ install: false)
+test('fuzzer', fuzzer)
+
+paramgrill_sources = [benchfn_c_file
+ join_paths(programs_dir, 'benchzstd.c'),
+ datagen_c_file
+ util_c_file
+ join_paths(tests_dir, 'paramgrill.c')]
+if host_machine.system() != 'windows'
+ paramgrill = executable('paramgrill',
+ paramgrill_sources,
+ include_directories: test_includes,
+ link_with: libzstd,
+ dependencies: libm_dep,
+ install: false )
+ test('paramgrill', paramgrill)
+endif