2
0

meson.build 5.4 KB

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