]> git.ipfire.org Git - thirdparty/zstd.git/blame - build/meson/lib/meson.build
[meson] Explicitly disable assembly for non clang/gcc copmilers
[thirdparty/zstd.git] / build / meson / lib / meson.build
CommitLineData
9a721e52
LT
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
0a0683f5 11zstd_rootdir = '../../..'
9a721e52 12
0a0683f5
LT
13libzstd_includes = [include_directories(join_paths(zstd_rootdir,'lib'),
14 join_paths(zstd_rootdir, 'lib/common'),
15 join_paths(zstd_rootdir, 'lib/compress'),
16 join_paths(zstd_rootdir, 'lib/decompress'),
698f261b 17 join_paths(zstd_rootdir, 'lib/dictBuilder'))]
9a721e52 18
0a0683f5
LT
19libzstd_sources = [join_paths(zstd_rootdir, 'lib/common/entropy_common.c'),
20 join_paths(zstd_rootdir, 'lib/common/fse_decompress.c'),
21 join_paths(zstd_rootdir, 'lib/common/threading.c'),
22 join_paths(zstd_rootdir, 'lib/common/pool.c'),
23 join_paths(zstd_rootdir, 'lib/common/zstd_common.c'),
24 join_paths(zstd_rootdir, 'lib/common/error_private.c'),
25 join_paths(zstd_rootdir, 'lib/common/xxhash.c'),
26 join_paths(zstd_rootdir, 'lib/compress/hist.c'),
27 join_paths(zstd_rootdir, 'lib/compress/fse_compress.c'),
28 join_paths(zstd_rootdir, 'lib/compress/huf_compress.c'),
29 join_paths(zstd_rootdir, 'lib/compress/zstd_compress.c'),
1dc98de2
EP
30 join_paths(zstd_rootdir, 'lib/compress/zstd_compress_literals.c'),
31 join_paths(zstd_rootdir, 'lib/compress/zstd_compress_sequences.c'),
7ce89187 32 join_paths(zstd_rootdir, 'lib/compress/zstd_compress_superblock.c'),
0a0683f5
LT
33 join_paths(zstd_rootdir, 'lib/compress/zstdmt_compress.c'),
34 join_paths(zstd_rootdir, 'lib/compress/zstd_fast.c'),
35 join_paths(zstd_rootdir, 'lib/compress/zstd_double_fast.c'),
36 join_paths(zstd_rootdir, 'lib/compress/zstd_lazy.c'),
37 join_paths(zstd_rootdir, 'lib/compress/zstd_opt.c'),
38 join_paths(zstd_rootdir, 'lib/compress/zstd_ldm.c'),
39 join_paths(zstd_rootdir, 'lib/decompress/huf_decompress.c'),
40 join_paths(zstd_rootdir, 'lib/decompress/zstd_decompress.c'),
41 join_paths(zstd_rootdir, 'lib/decompress/zstd_decompress_block.c'),
42 join_paths(zstd_rootdir, 'lib/decompress/zstd_ddict.c'),
43 join_paths(zstd_rootdir, 'lib/dictBuilder/cover.c'),
44 join_paths(zstd_rootdir, 'lib/dictBuilder/fastcover.c'),
45 join_paths(zstd_rootdir, 'lib/dictBuilder/divsufsort.c'),
a423305e 46 join_paths(zstd_rootdir, 'lib/dictBuilder/zdict.c')]
9a721e52 47
29e44bc5
ES
48# really we need anything that defines __GNUC__ as that is what ZSTD_ASM_SUPPORTED is gated on
49# but these are the two compilers that are supported in tree and actually handle this correctly
c4f5116e 50# Otherwise, explicitly disable assmebly.
29e44bc5
ES
51if [compiler_gcc, compiler_clang].contains(cc_id)
52 libzstd_sources += join_paths(zstd_rootdir, 'lib/decompress/huf_decompress_amd64.S')
c4f5116e
NT
53else
54 add_project_arguments('-DZSTD_DISABLE_ASM', language: 'c')
29e44bc5
ES
55endif
56
0a0683f5 57# Explicit define legacy support
24bc513e 58add_project_arguments('-DZSTD_LEGACY_SUPPORT=@0@'.format(legacy_level),
0a0683f5
LT
59 language: 'c')
60
24bc513e 61if legacy_level == 0
0a0683f5
LT
62 message('Legacy support: DISABLED')
63else
64 # See ZSTD_LEGACY_SUPPORT of lib/README.md
24bc513e 65 message('Enable legacy support back to version 0.@0@'.format(legacy_level))
0a0683f5
LT
66
67 libzstd_includes += [ include_directories(join_paths(zstd_rootdir, 'lib/legacy')) ]
68 foreach i : [1, 2, 3, 4, 5, 6, 7]
24bc513e 69 if legacy_level <= i
0a0683f5 70 libzstd_sources += join_paths(zstd_rootdir, 'lib/legacy/zstd_v0@0@.c'.format(i))
9a721e52 71 endif
0a0683f5 72 endforeach
9a721e52
LT
73endif
74
0a0683f5 75libzstd_deps = []
24bc513e 76if use_multi_thread
0a0683f5
LT
77 message('Enable multi-threading support')
78 add_project_arguments('-DZSTD_MULTITHREAD', language: 'c')
79 libzstd_deps = [ thread_dep ]
80endif
81
82libzstd_c_args = []
83if cc_id == compiler_msvc
84 if default_library_type != 'static'
85 libzstd_sources += [windows_mod.compile_resources(
86 join_paths(zstd_rootdir, 'build/VS2010/libzstd-dll/libzstd-dll.rc'))]
87 libzstd_c_args += ['-DZSTD_DLL_EXPORT=1',
88 '-DZSTD_HEAPMODE=0',
89 '-D_CONSOLE',
90 '-D_CRT_SECURE_NO_WARNINGS']
91 else
92 libzstd_c_args += ['-DZSTD_HEAPMODE=0',
93 '-D_CRT_SECURE_NO_WARNINGS']
94 endif
9a721e52
LT
95endif
96
0a0683f5
LT
97mingw_ansi_stdio_flags = []
98if host_machine_os == os_windows and cc_id == compiler_gcc
99 mingw_ansi_stdio_flags = [ '-D__USE_MINGW_ANSI_STDIO' ]
100endif
101libzstd_c_args += mingw_ansi_stdio_flags
102
103libzstd_debug_cflags = []
24bc513e
LT
104if use_debug
105 libzstd_c_args += '-DDEBUGLEVEL=@0@'.format(debug_level)
0a0683f5
LT
106 if cc_id == compiler_gcc or cc_id == compiler_clang
107 libzstd_debug_cflags = ['-Wstrict-aliasing=1', '-Wswitch-enum',
108 '-Wdeclaration-after-statement', '-Wstrict-prototypes',
188c7482 109 '-Wundef', '-Wpointer-arith', '-Wvla',
0a0683f5
LT
110 '-Wformat=2', '-Winit-self', '-Wfloat-equal', '-Wwrite-strings',
111 '-Wredundant-decls', '-Wmissing-prototypes', '-Wc++-compat']
112 endif
113endif
114libzstd_c_args += cc.get_supported_arguments(libzstd_debug_cflags)
115
9a721e52 116libzstd = library('zstd',
0a0683f5
LT
117 libzstd_sources,
118 include_directories: libzstd_includes,
119 c_args: libzstd_c_args,
9748608a 120 gnu_symbol_visibility: 'hidden',
0a0683f5
LT
121 dependencies: libzstd_deps,
122 install: true,
fa2fc274 123 version: zstd_libversion)
0a0683f5
LT
124
125libzstd_dep = declare_dependency(link_with: libzstd,
126 include_directories: libzstd_includes)
9a721e52 127
787a72cd
LT
128pkgconfig.generate(libzstd,
129 name: 'libzstd',
0a0683f5 130 filebase: 'libzstd',
0a0683f5
LT
131 description: 'fast lossless compression algorithm library',
132 version: zstd_libversion,
133 url: 'http://www.zstd.net/')
9a721e52 134
0a0683f5 135install_headers(join_paths(zstd_rootdir, 'lib/zstd.h'),
09149bea
NT
136 join_paths(zstd_rootdir, 'lib/zdict.h'),
137 join_paths(zstd_rootdir, 'lib/zstd_errors.h'))