meson.build 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. zstd_programs_sources = [join_paths(zstd_rootdir, 'programs/zstdcli.c'),
  12. join_paths(zstd_rootdir, 'programs/util.c'),
  13. join_paths(zstd_rootdir, 'programs/timefn.c'),
  14. join_paths(zstd_rootdir, 'programs/fileio.c'),
  15. join_paths(zstd_rootdir, 'programs/benchfn.c'),
  16. join_paths(zstd_rootdir, 'programs/benchzstd.c'),
  17. join_paths(zstd_rootdir, 'programs/datagen.c'),
  18. join_paths(zstd_rootdir, 'programs/dibio.c'),
  19. join_paths(zstd_rootdir, 'programs/zstdcli_trace.c'),
  20. # needed due to use of private symbol + -fvisibility=hidden
  21. join_paths(zstd_rootdir, 'lib/common/xxhash.c')]
  22. zstd_c_args = libzstd_debug_cflags
  23. if use_multi_thread
  24. zstd_c_args += [ '-DZSTD_MULTITHREAD' ]
  25. endif
  26. zstd_deps = [ libzstd_dep ]
  27. if use_zlib
  28. zstd_deps += [ zlib_dep ]
  29. zstd_c_args += [ '-DZSTD_GZCOMPRESS', '-DZSTD_GZDECOMPRESS' ]
  30. endif
  31. if use_lzma
  32. zstd_deps += [ lzma_dep ]
  33. zstd_c_args += [ '-DZSTD_LZMACOMPRESS', '-DZSTD_LZMADECOMPRESS' ]
  34. endif
  35. if use_lz4
  36. zstd_deps += [ lz4_dep ]
  37. zstd_c_args += [ '-DZSTD_LZ4COMPRESS', '-DZSTD_LZ4DECOMPRESS' ]
  38. endif
  39. export_dynamic_on_windows = false
  40. # explicit backtrace enable/disable for Linux & Darwin
  41. if not use_backtrace
  42. zstd_c_args += '-DBACKTRACE_ENABLE=0'
  43. elif use_debug and host_machine_os == os_windows # MinGW target
  44. zstd_c_args += '-DBACKTRACE_ENABLE=1'
  45. export_dynamic_on_windows = true
  46. endif
  47. if cc_id == compiler_msvc
  48. if default_library_type != 'static'
  49. zstd_programs_sources += [windows_mod.compile_resources(
  50. join_paths(zstd_rootdir, 'build/VS2010/zstd/zstd.rc'))]
  51. endif
  52. endif
  53. zstd = executable('zstd',
  54. zstd_programs_sources,
  55. c_args: zstd_c_args,
  56. dependencies: zstd_deps,
  57. export_dynamic: export_dynamic_on_windows, # Since Meson 0.45.0
  58. install: true)
  59. zstd_frugal_sources = [join_paths(zstd_rootdir, 'programs/zstdcli.c'),
  60. join_paths(zstd_rootdir, 'programs/timefn.c'),
  61. join_paths(zstd_rootdir, 'programs/util.c'),
  62. join_paths(zstd_rootdir, 'programs/fileio.c')]
  63. # Minimal target, with only zstd compression and decompression.
  64. # No bench. No legacy.
  65. executable('zstd-frugal',
  66. zstd_frugal_sources,
  67. dependencies: libzstd_dep,
  68. c_args: [ '-DZSTD_NOBENCH', '-DZSTD_NODICT', '-DZSTD_NOTRACE' ],
  69. install: true)
  70. install_data(join_paths(zstd_rootdir, 'programs/zstdgrep'),
  71. join_paths(zstd_rootdir, 'programs/zstdless'),
  72. install_dir: zstd_bindir)
  73. # =============================================================================
  74. # Programs and manpages installing
  75. # =============================================================================
  76. install_man(join_paths(zstd_rootdir, 'programs/zstd.1'),
  77. join_paths(zstd_rootdir, 'programs/zstdgrep.1'),
  78. join_paths(zstd_rootdir, 'programs/zstdless.1'))
  79. InstallSymlink_py = '../InstallSymlink.py'
  80. zstd_man1_dir = join_paths(zstd_mandir, 'man1')
  81. bin_EXT = host_machine_os == os_windows ? '.exe' : ''
  82. man1_EXT = meson.version().version_compare('>=0.49.0') ? '.1' : '.1.gz'
  83. foreach f : ['zstdcat', 'unzstd']
  84. meson.add_install_script(InstallSymlink_py, 'zstd' + bin_EXT, f + bin_EXT, zstd_bindir)
  85. meson.add_install_script(InstallSymlink_py, 'zstd' + man1_EXT, f + man1_EXT, zstd_man1_dir)
  86. endforeach
  87. if use_multi_thread
  88. meson.add_install_script(InstallSymlink_py, 'zstd' + bin_EXT, 'zstdmt' + bin_EXT, zstd_bindir)
  89. meson.add_install_script(InstallSymlink_py, 'zstd' + man1_EXT, 'zstdmt' + man1_EXT, zstd_man1_dir)
  90. endif