NOTE: This commit only tested on Linux (Ubuntu 18.04). Windows build may not work as expected. * Use meson >= 0.47.0 cause we use install_man function * Add three helper Python script: * CopyFile.py: To copy file * CreateSymlink.py: To make symlink (both Windows and Unix) * GetZstdLibraryVersion.py: Parse lib/zstd.h to get zstd version These help emulating equivalent functions in CMake and Makefile. * Use subdir from meson to split meson.build * Add contrib build * Fix other build * Add new build options * build_programs: Enable programs build * build_contrib: Enable contrib build * build_tests: Enable tests build * use_static_runtime: Link to static run-time libraries on MSVC * zlib_support: Enable zlib support * lzma_support: Enable lzma support
114 lines
3.6 KiB
Meson
114 lines
3.6 KiB
Meson
# #############################################################################
|
|
# 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'))
|