From 63e93f58b1d1294d3e11df4adafe9ad2914c936b Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Thu, 2 May 2024 06:05:17 +0200 Subject: [PATCH 01/25] WIP: meson build --- meson.build | 382 ++++++++++++++++++++++++++++++++++++++ meson_options.txt | 188 +++++++++++++++++++ src/common/meson.build | 400 ++++++++++++++++++++++++++++++++++++++++ src/liblzma/meson.build | 360 ++++++++++++++++++++++++++++++++++++ src/meson.build | 6 + 5 files changed, 1336 insertions(+) create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 src/common/meson.build create mode 100644 src/liblzma/meson.build create mode 100644 src/meson.build diff --git a/meson.build b/meson.build new file mode 100644 index 000000000..598fabbd8 --- /dev/null +++ b/meson.build @@ -0,0 +1,382 @@ +## SPDX-License-Identifier: 0BSD +## Author: Vincent Torri + +project( + 'XZ Utils', + 'c', + version: '5.6.99', + license: '0BSD', + license_files: [ + 'COPYING', + 'COPYING.0BSD', + 'COPYING.GPLv2', + 'COPYING.GPLv3', + 'COPYING.LGPLv2.1' + ], + default_options: [ + 'b_ndebug=if-release', + 'buildtype=debug', + 'c_std=c99', + 'libdir=lib', + 'warning_level=3', + ], + meson_version: '>= 1.1.0', +) + +v_array = meson.project_version().split('.') +v_maj = v_array[0] + +# config.h + +config_dir = [include_directories('.')] + +config_h = configuration_data() +config_h.set_quoted('PACKAGE', 'xz') +config_h.set_quoted('PACKAGE_BUGREPORT', 'xz@tukaani.org') +config_h.set_quoted('PACKAGE_NAME', meson.project_name()) +config_h.set_quoted('PACKAGE_URL', 'https://tukaani.org/xz/') + +# host + +config_h.set10('WORDS_BIGENDIAN', host_machine.endian() == 'big', + description: 'Define to 1 if the processor stores words with the most significant byte first.' +) + +host_os = host_machine.system() + +cygwin = 'cygwin' +windows = 'windows' +linux = 'linux' +sunos = 'sunos' +asm_os = [ 'linux', 'dragonfly', 'freebsd', 'netbsd', 'openbsd', 'windows', 'cygwin' ] +sys_cygwin = cygwin.contains(host_os) +sys_windows = windows.contains(host_os) + +COND_W32 = sys_cygwin or sys_windows + +# binaries +cc = meson.get_compiler('c') + +# try mimic AC_USE_SYSTEM_EXTENSIONS +if host_machine.system() == 'linux' + add_global_arguments('-D_GNU_SOURCE', language: 'c') +elif host_machine.system() == 'sunos' + add_global_arguments('-D__EXTENSIONS__', language: 'c') + add_global_arguments('-D_POSIX_PTHREAD_SEMANTICS', language: 'c') +else + add_global_arguments('-D_TANDEM_SOURCE', language: 'c') + add_global_arguments('-D_ALL_SOURCE', language: 'c') +endif + +lzma_c_args = [] +cflags_try = [] + +if cc.get_argument_syntax() == 'gcc' + cflags_try += [ + '-Wvla', + '-Wformat=2', + '-Winit-self', + '-Wmissing-include-dirs', + '-Wshift-overflow=2', + '-Wstrict-overflow=3', + '-Walloc-zero', + '-Wduplicated-cond', + '-Wfloat-equal', + '-Wundef', + '-Wshadow', + '-Wpointer-arith', + '-Wbad-function-cast', + '-Wwrite-strings', + '-Wdate-time', + '-Wsign-conversion', + '-Wfloat-conversion', + '-Wlogical-op', + '-Waggregate-return', + '-Wstrict-prototypes', + '-Wold-style-definition', + '-Wmissing-prototypes', + '-Wmissing-declarations', + '-Wredundant-decls', +# + '-Wc99-compat', + '-Wc11-extensions', + '-Wc2x-compat', + '-Wc2x-extensions', + '-Wpre-c2x-compat', + '-Warray-bounds-pointer-arithmetic', + '-Wassign-enum', + '-Wconditional-uninitialized', + '-Wdocumentation', + '-Wduplicate-enum', + '-Wempty-translation-unit', + '-Wflexible-array-extensions', + '-Wmissing-variable-declarations', + '-Wnewline-eof', + '-Wshift-sign-overflow', + '-Wstring-conversion', + ] + + foreach cf : cflags_try + if cc.has_argument(cf) + lzma_c_args += cf + endif + endforeach +endif + +config_h.set10('HAVE_VISIBILITY', cc.has_function_attribute('visibility'), + description: 'Define to 1 if the compiler supports simple visibility declarations.' +) + +ctor_fct_src = ''' +__attribute__((__constructor__)) +static void my_constructor_func(void) { return; } +int main() { return 0; } +''' +if cc.compiles(ctor_fct_src, name : 'constructor attribute for functions') + config_h.set10('HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR', true, + description: 'Define to 1 if __attribute__((__constructor__)) is supported for functions.' + ) +endif + +cc.has_type('uint32_t', prefix: '#include ') + +time_fcts = [ + [ 'futimens', [ '#include ' ] ], + [ 'futimes', [ '#include ' ] ], + [ 'futimesat', [ '#include ', '#include ' ] ], + [ 'utimes', [ '#include ' ] ], + [ '_futime', [ '#include ' ] ], + [ 'utime', [ '#include ', '#include ' ] ], +] +foreach f : time_fcts + if cc.has_function(f[0], prefix : f[1]) + config_h.set10('HAVE_' + f[0].to_upper(), true, + description: 'Define to 1 if the ' + f[0] + '() function is available.' + ) + break + endif +endforeach + +if cc.has_function('posix_advice', prefix : '#include ') + config_h.set10('HAVE_POSIX_ADVICE', true, + description: 'Define to 1 if the posix_advice() function is available.' + ) +endif + +### Filters + +## encoders +encoder_msg = '' +decoder_msg = '' + +supported_filters = [ + 'lzma1', + 'lzma2', + 'delta', + 'x86', + 'powerpc', + 'ia64', + 'arm', + 'armthumb', + 'arm64', + 'sparc', + 'riscv', +] + +simple_filters = [ + 'x86', + 'powerpc', + 'ia64', + 'arm', + 'armthumb', + 'arm64', + 'sparc', + 'riscv', +] + +# FIXME foreach i in array; set_variable(f'have_@i@', true) endforeach + +foreach f : supported_filters + if get_option('encoders').contains(f) == true + config_h.set10('HAVE_ENCODER_' + f.underscorify().to_upper(), true, + description: 'Define to 1 if ' + f + ' encoder is enabled.' + ) + encoder_msg += f + ' ' + endif + if get_option('decoders').contains(f) == true + config_h.set10('HAVE_DECODER_' + f.underscorify().to_upper(), true, + description: 'Define to 1 if ' + f + ' decoder is enabled.' + ) + decoder_msg += f + ' ' + endif +endforeach + +have_encoder_simple_filters = false +have_decoder_simple_filters = false +foreach f : simple_filters + if get_option('encoders').contains(f) == true + have_encoder_simple_filters = true + endif + if get_option('decoders').contains(f) == true + have_decoder_simple_filters = true + endif +endforeach + +if (get_option('encoders').contains('lzma2') == true and get_option('encoders').contains('lzma1') == false) or (get_option('decoders').contains('lzma2') == true and get_option('decoders').contains('lzma1') == false) + error('LZMA2 requires that LZMA1 is also enabled') +endif + +if get_option('encoders').length() > 0 + config_h.set10('HAVE_ENCODERS', true, + description: 'Define to 1 if at least one encoder has been enabled.' + ) +endif + +if get_option('decoders').length() > 0 + config_h.set10('HAVE_DECODERS', true, + description: 'Define to 1 if at least one decoder has been enabled.' + ) +endif + +### Match finders + +match_finder_msg = '' + +match_finders = [ + 'hc3', + 'hc4', + 'bt2', + 'bt3', + 'bt4' +] + +if get_option('encoders').contains('lzma2') == true or get_option('encoders').contains('lzma1') == true + if get_option('match-finders').length() == 0 + error('at least one match finder is required for an LZ-based encoder') + endif + + foreach m : match_finders + if get_option('match-finders').contains(m) == true + config_h.set10('HAVE_MF_' + m.underscorify().to_upper(), true, + description: 'Define to 1 to enable ' + m + ' match finder.' + ) + match_finder_msg += m + ' ' + endif + endforeach +endif + +### Integrity checks + +check_msg = '' + +checks = [ + 'crc32', + 'crc64', + 'sha256' +] + +foreach c : checks + if get_option('checks').contains(c) == true + config_h.set10('HAVE_CHECK_' + c.underscorify().to_upper(), true, + description: 'Define to 1 if ' + c + ' integrity check is enabled.' + ) + check_msg += c + ' ' + endif +endforeach + +if get_option('checks').contains('crc32') == false + error('For now, the CRC32 check must always be enabled') +endif + +### microLZMA + +if get_option('microlzma') == true +endif + +### .lz (lzip) format support + +have_lzip = false +if get_option('encoders').contains('lzma1') == false + lzip_msg = 'no (LZMA1 disabled)' +elif get_option('lzip-decoder') == true + lzip_msg = 'yes' + have_lzip = true + config_h.set10('HAVE_LZIP_DECODER', true, + description: 'Define to 1 if .lz (lzip) decompression support is enabled.' + ) +else + lzip_msg = 'no' +endif + +### assembler optimizations + +have_assembler_x86 = false +if get_option('assembler') == true + if asm_os.contains(host_os) and host_machine.cpu_family() == 'x86' + have_assembler_x86 = true + endif +endif + +### size optimization + +if get_option('small') == true + config_h.set10('HAVE_SMALL', true, + description: 'Define to 1 if optimizing for size.' + ) +endif + +### threading + +have_threads = false + +if get_option('threads') == true + if sys_windows == true + if host_machine.cpu_family() == 'x86' + config_h.set10('MYTHREAD_WIN95', true, + description: 'Define to 1 when using Windows 95 (and thus XP) compatible threads. This avoids use of features that were added in Windows Vista.' + ) + else + config_h.set10('MYTHREAD_VISTA', true, + description: 'Define to 1 when using Windows Vista compatible threads. This uses features that are not available on Windows XP.' + ) + endif + have_threads = true + else + pthread_dep = dependency('threads') + if pthread_dep.found() + config_h.set10('MYTHREAD_POSIX', true, + description: 'Define to 1 when using POSIX threads (pthreads).' + ) + have_threads = true + endif + endif +endif + + +### subdirectories + +subdir('src') + +configure_file(output: 'config.h', configuration: config_h) + +# summary + +summary( + { + 'OS': host_os, + 'endianness': host_machine.endian(), + 'assembler': get_option('assembler').to_string('yes', 'no'), + 'encoders': encoder_msg, + 'decoders': decoder_msg, + 'match finders': match_finder_msg, + 'checks': check_msg, + 'external sha256': get_option('external-sha256').to_string('yes', 'no'), + 'microLZMA': get_option('microlzma').to_string('yes', 'no'), + 'lzip decompression': lzip_msg, + 'small': get_option('small').to_string('yes', 'no'), + 'threads': have_threads.to_string('yes', 'no'), + 'fast unaligned access': fast_unaligned_access.to_string('yes', 'no'), + 'unsafe type punning': get_option('unsafe-type-punning').to_string('yes', 'no') + }, + section: 'Configuration Options Summary:', +) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 000000000..d9d5f374e --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,188 @@ +## SPDX-License-Identifier: 0BSD +## Author: Vincent Torri + +# [ ] debug - not used : done by meson +# [ ] arm64-crc32 +# [X] assembler +# [ ] assume-ram +# [X] checks +# [ ] clmul-crc +# [X] decoders +# [ ] doc +# [ ] doxygen +# [X] encoders +# [X] external-sha256 +# [X] lzip-decoder +# [ ] lzmadec +# [ ] lzmainfo +# [ ] lzma-links +# [X] match-finders +# [X] microlzma +# [ ] path-for-scripts +# [ ] sandbox +# [X] small +# [ ] symbol-versions +# [ ] scripts +# [X] threads +# [X] unaligned-access +# [X] unsafe-type-punning +# [ ] werror - not used : done by meson +# [ ] xz +# [ ] xzdec + +option('arm64-crc32', + type : 'boolean', + value : true, + description : 'use ARM64 CRC32 instructions' +) + +option('assembler', + type : 'boolean', + value : true, + description : 'use assembler optimizations' +) + +option('assume-ram', + type : 'integer', + value : 128, + description : 'how much RAM to assume if the real amount is unknown' +) + +option('checks', + type : 'array', + choices : [ 'crc32', 'crc64', 'sha256' ], + value : [ 'crc32', 'crc64', 'sha256' ], + description : 'list of integrity checks to build' +) + +option('clmul-crc', + type : 'boolean', + value : true, + description : 'use carryless multiplication for CRC calculation' +) + +option('decoders', + type : 'array', + choices : [ 'lzma1', 'lzma2', 'delta', 'x86', 'powerpc', 'ia64', 'arm', 'armthumb', 'arm64', 'sparc', 'riscv' ], + value : [ 'lzma1', 'lzma2', 'delta', 'x86', 'powerpc', 'ia64', 'arm', 'armthumb', 'arm64', 'sparc', 'riscv' ], + description : 'list of decoders to build' +) + +option('doc', + type : 'boolean', + value : true, + description : 'install documentation files' +) + +option('encoders', + type : 'array', + choices : [ 'lzma1', 'lzma2', 'delta', 'x86', 'powerpc', 'ia64', 'arm', 'armthumb', 'arm64', 'sparc', 'riscv' ], + value : [ 'lzma1', 'lzma2', 'delta', 'x86', 'powerpc', 'ia64', 'arm', 'armthumb', 'arm64', 'sparc', 'riscv' ], + description : 'list of encoders to build' +) + +option('external-sha256', + type : 'boolean', + value : false, + description : 'use SHA-256 code from the operating system' +) + +option('lzip-decoder', + type : 'boolean', + value : true, + description : 'decompression support for .lz (lzip) files' +) + +option('lzmadec', + type : 'boolean', + value : true, + description : 'build lzmadec' +) + +option('lzmainfo', + type : 'boolean', + value : true, + description : 'build lzmainfo' +) + +option('lzma-links', + type : 'boolean', + value : true, + description : 'create symlinks for LZMA Utils compatibility' +) + +option('match-finders', + type : 'array', + choices : [ 'hc3', 'hc4', 'bt2', 'bt3', 'bt4' ], + value : [ 'hc3', 'hc4', 'bt2', 'bt3', 'bt4' ], + description : 'list of match finders to build' +) + +option('microlzma', + type : 'boolean', + value : true, + description : 'build MicroLZMA encoder and decoder, needed by specific applications' +) + +option('path-for-scripts', + type : 'string', + value : '', + description : 'if not empty, the path will be added to PATH. If empty and on solaris, the path is /usr/xpg4/bin' +) + +option('sandbox', + type : 'combo', + choices : [ 'auto', 'no', 'capsicum', 'pledge', 'landlock' ], + value : 'auto', + description : 'sandboxing method' +) + +option('scripts', + type : 'boolean', + value : true, + description : 'install the scripts xzdiff, xzgrep, xzless, xzmore, and their symlinks' +) + +option('small', + type : 'boolean', + value : false, + description : 'make liblzma smaller and a little slower' +) + +option( + 'symbol-versions', + type: 'feature', + value: 'auto', + description: 'use symbol versioning for liblzma. Enabled by default on GNU/Linux, other GNU-based systems, and FreeBSD', +) + +option('threads', + type : 'boolean', + value : true, + description : 'threading support' +) + +option( + 'unaligned-access', + type: 'feature', + value: 'auto', + description: '*fast* unaligned memory access with 16-bit, 32-bit, and 64-bit integers. Enabled by default on x86, x86-64, 32/64-bit big endian PowerPC, 64-bit little endian PowerPC and some ARM, ARM64, and RISC-V systems.' +) + +option('unsafe-type-punning', + type : 'boolean', + value : false, + description : 'use ARM64 CRC32 instructions' +) + +option('xz', + type : 'boolean', + value : true, + description : 'build the xz tool' +) + +option('xzdec', + type : 'boolean', + value : true, + description : 'build xzdec' +) diff --git a/src/common/meson.build b/src/common/meson.build new file mode 100644 index 000000000..9e137e605 --- /dev/null +++ b/src/common/meson.build @@ -0,0 +1,400 @@ +# SPDX-License-Identifier: 0BSD + +# [X] tuklib_common.m4 +# [X] tuklib_cpucores.m4 +# [X] tuklib_integer.m4 +# [X] tuklib_mbstr.m4 +# [X] tuklib_physmem.m4 +# [X] tuklib_progname.m4 + +# tuklib_common.m4 + +## requires c99, host, AC_USE_SYSTEM_EXTENSIONS +## nothing to do, here (already in toplevel meson.build) + +# tuklib_cpucores.m4 + +have_sys_param_h = cc.has_header('sys/param.h') + +cpu_special_src = ''' +#if defined(_WIN32) || defined(__CYGWIN__) +int main(void) { return 0; } +#else +compile error +#endif +''' + +cpu_sched_getaffinity_src = ''' +#include +int +main(void) +{ + cpu_set_t cpu_mask; + sched_getaffinity(0, sizeof(cpu_mask), &cpu_mask); + return CPU_COUNT(&cpu_mask); +} +''' + +cpu_cpuset_src = ''' +#include +#include + +int +main(void) +{ + cpuset_t set; + cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, + sizeof(set), &set); + return 0; +} +''' + +cpu_sysctl_src = ''' +#ifdef __QNX__ +compile error +#endif +#ifdef HAVE_SYS_PARAM_H +# include +#endif +#include +int +main(void) +{ +#ifdef HW_NCPUONLINE + /* This is preferred on OpenBSD, see tuklib_cpucores.c. */ + int name[2] = { CTL_HW, HW_NCPUONLINE }; +#else + int name[2] = { CTL_HW, HW_NCPU }; +#endif + int cpus; + size_t cpus_size = sizeof(cpus); + sysctl(name, 2, &cpus, &cpus_size, NULL, 0); + return 0; +} +''' + +cpu_sysconf_src = ''' +#include +int +main(void) +{ + long i; +#ifdef _SC_NPROCESSORS_ONLN + /* Many systems using sysconf() */ + i = sysconf(_SC_NPROCESSORS_ONLN); +#else + /* IRIX */ + i = sysconf(_SC_NPROC_ONLN); +#endif + return 0; +} +''' + +cpu_pstat_getdynamic_src = ''' +#include +#include + +int +main(void) +{ + struct pst_dynamic pst; + pstat_getdynamic(&pst, sizeof(pst), 1, 0); + (void)pst.psd_proc_cnt; + return 0; +} +''' + +if cc.compiles(cpu_special_src, name : 'number of cpu cores on Windows or Cygwin') +# nothing to do, here +elif cc.compiles(cpu_sched_getaffinity_src, name : 'number of cpu cores with sched_getaffinity()') + config_h.set10('TUKLIB_CPUCORES_SCHED_GETAFFINITY', true) +elif cc.compiles(cpu_cpuset_src, name : 'number of cpu cores with cpuset()') + config_h.set10('TUKLIB_CPUCORES_CPUSET', true) +elif cc.compiles(cpu_sysctl_src, args : have_sys_param_h ? '-DHAVE_SYS_PARAM_H' : '', name : 'number of cpu cores with sysctl()') + config_h.set10('TUKLIB_CPUCORES_SYSCTL', true) +elif cc.compiles(cpu_sysconf_src, name : 'number of cpu cores with sysconf()') + config_h.set10('TUKLIB_CPUCORES_SYSCONF', true) +elif cc.compiles(cpu_pstat_getdynamic_src, name : 'number of cpu cores with pstat_getdynamic()') + config_h.set10('TUKLIB_CPUCORES_PSTAT_GETDYNAMIC', true) +endif + +# tuklib_integer.m4 + +bswap_src = ''' +int main() +{ + __builtin_bswap16(1); + __builtin_bswap32(1); + __builtin_bswap64(1); + return 0; +} +''' +res = cc.links(bswap_src, name: '__builtin_bswap16/32/64') +if res == true + config_h.set10('HAVE___BUILTIN_BSWAPXX', true, + description: 'Define to 1 if the GNU C extensions __builtin_bswap16/32/64 are supported.' + ) +else + have_byteswap_h = false + have_sys_endian_h = false + have_sys_byteorder_h = false + bswap_headers = [ + 'byteswap.h', + 'sys/endian.h', + 'sys/byteorder.h' + ] + foreach h : bswap_headers + if cc.has_header(h) + config_h.set10('HAVE_' + h.underscorify().to_upper(), true) + set_variable(f'have_' + h.underscorify(), true) + endif + endforeach + + if have_byteswap_h == true + bswap_fcts = [ + 'bswap_16', + 'bswap_32', + 'bswap_64' + ] + foreach f : bswap_fcts + bswap_src = ''' +#include +int main() +{ + @0@(42); + return 0; +} +''' + res = cc.links(bswap_src.format(f), name: f) + if res == true + config_h.set10('HAVE_' + f.to_upper(), true, + description: 'Define to 1 if ' + f + '() is available.' + ) + endif + endforeach + endif +endif + +fast_unaligned_access = false +if get_option('unaligned-access').auto() == true + unaligned_access_cpus = [ + 'ppc', + 'ppc64', + 'x86', + 'x86_64', + ] + foreach cpu : unaligned_access_cpus + if host_machine.cpu_family() == cpu + config_h.set10('TUKLIB_FAST_UNALIGNED_ACCESS', true, + description: 'Define to 1 if the system supports fast unaligned access to 16-bit, 32-bit, and 64-bit integers.' + ) + fast_unaligned_access = true + break + endif + endforeach + + if fast_unaligned_access == false + unaligned_access_cpus = [ + 'aarch64', + 'arm', + 'riscv32', + 'riscv64', + ] + foreach cpu : unaligned_access_cpus + if host_machine.cpu_family() == cpu + ua_src = ''' +#if !defined(__ARM_FEATURE_UNALIGNED) \ + && !defined(__riscv_misaligned_fast) \ + && !defined(_MSC_VER) +compile error +#endif +int main(void) { return 0; } +''' + res = cc.compiles(ua_src, name: 'fast unaligned access for ' + cpu) + if res == true + config_h.set10('TUKLIB_FAST_UNALIGNED_ACCESS', true, + description: 'Define to 1 if the system supports fast unaligned access to 16-bit, 32-bit, and 64-bit integers.' + ) + fast_unaligned_access = true + break + endif + endif + endforeach + endif +elif get_option('unaligned-access').enabled() == true + config_h.set10('TUKLIB_FAST_UNALIGNED_ACCESS', true, + description: 'Define to 1 if the system supports fast unaligned access to 16-bit, 32-bit, and 64-bit integers.' + ) + fast_unaligned_access = true +endif + +if get_option('unsafe-type-punning') == true + config_h.set10('HAVE___BUILTIN_ASSUME_ALIGNED', true, + description: 'Define to 1 if the GNU C extension __builtin_assume_aligned is supported.' + ) +endif + +# tuklib_mbstr.m4 + +### FIXME : mbrtowc is supported in C99 spec and on Windows +if cc.has_header('wchar.h') + config_h.set10('HAVE_WCHAR_H', true, + description: 'Define to 1 if the header file is available.' + ) + + res = cc.has_type('mbstate_t', + prefix : '#include ' + ) + + if res == true + if cc.has_function('mbrtowc', + prefix : '#include ' + ) + config_h.set10('HAVE_MBRTOWC', true, + description: 'Define to 1 if the mbrtowc() function is available.' + ) + endif + endif + + if cc.has_function('wcwidth', + args : '-D_XOPEN_SOURCE', + prefix : '#include ' + ) + config_h.set10('HAVE_WCWIDTH', true, + description: 'Define to 1 if the wcwidth() function is available.' + ) + endif +endif + +# tuklib_physmem.m4 + + +physmem_special_src = ''' +#if defined(_WIN32) || defined(__CYGWIN__) || defined(__OS2__) \ + || defined(__DJGPP__) || defined(__VMS) \ + || defined(AMIGA) || defined(__AROS__) || defined(__QNX__) +int main(void) { return 0; } +#else +compile error +#endif +''' + +physmem_aix_src = ''' +#include + +int +main(void) +{ + (void)_system_configuration.physmem; + return 0; +} +''' + +physmem_sysconf_src = ''' +#include +int +main(void) +{ + long i; + i = sysconf(_SC_PAGESIZE); + i = sysconf(_SC_PHYS_PAGES); + return 0; +} +''' + +physmem_sysctl_src = ''' +#ifdef HAVE_SYS_PARAM_H +# include +#endif +#include +int +main(void) +{ + int name[2] = { CTL_HW, HW_PHYSMEM }; + unsigned long mem; + size_t mem_ptr_size = sizeof(mem); + sysctl(name, 2, &mem, &mem_ptr_size, NULL, 0); + return 0; +} +''' + +physmem_getsysinfo_src = ''' +#include +#include + +int +main(void) +{ + int memkb; + int start = 0; + getsysinfo(GSI_PHYSMEM, (caddr_t)&memkb, sizeof(memkb), &start); + return 0; +} +''' + +physmem_pstat_getstatic_src = ''' +#include +#include + +int +main(void) +{ + struct pst_static pst; + pstat_getstatic(&pst, sizeof(pst), 1, 0); + (void)pst.physical_memory; + (void)pst.page_size; + return 0; +} +''' + +physmem_getinvent_r_src = ''' +#include +int +main(void) +{ + inv_state_t *st = NULL; + setinvent_r(&st); + getinvent_r(st); + endinvent_r(st); + return 0; +} +''' + +physmem_sysinfo_src = ''' +#include +int +main(void) +{ + struct sysinfo si; + sysinfo(&si); + return 0; +} +''' + +if cc.compiles(physmem_special_src, name : 'physical memory on some special OSes') +# nothing to do, here +elif cc.compiles(physmem_aix_src, name : 'physical memory on AIX') + config_h.set10('TUKLIB_PHYSMEM_AIX', true) +elif cc.compiles(physmem_sysconf_src, name : 'physical memory with sysconf()') + config_h.set10('TUKLIB_PHYSMEM_SYSCONF', true) +elif cc.compiles(physmem_sysctl_src, args : have_sys_param_h ? '-DHAVE_SYS_PARAM_H' : '', name : 'physical memory with sysctl()') + config_h.set10('TUKLIB_PHYSMEM_SYSCTL', true) +elif cc.compiles(physmem_getsysinfo_src, name : 'physical memory with getsysinfo()') + config_h.set10('TUKLIB_PHYSMEM_GETSYSINFO', true) +elif cc.compiles(physmem_pstat_getstatic_src, name : 'physical memory with pstat_getstatic()') + config_h.set10('TUKLIB_PHYSMEM_PSTAT_GETSTATIC', true) +elif cc.compiles(physmem_getinvent_r_src, name : 'physical memory with getinvent_r()') + config_h.set10('TUKLIB_PHYSMEM_GETINVENT_R', true) +elif cc.compiles(physmem_sysinfo_src, name : 'physical memory with sysinfo()') + config_h.set10('TUKLIB_PHYSMEM_SYSINFO', true) +endif + +# tuklib_progname.m4 + +if cc.has_function('program_invocation_name', + prefix : '#include ' + ) + config_h.set10('HAVE_PROGRAM_INVOCATION_NAME', true, + description: 'Define to 1 if the program_invocation_name() function is available.' + ) +endif diff --git a/src/liblzma/meson.build b/src/liblzma/meson.build new file mode 100644 index 000000000..f3ff32494 --- /dev/null +++ b/src/liblzma/meson.build @@ -0,0 +1,360 @@ +## SPDX-License-Identifier: 0BSD +## Author: Vincent Torri + +lzma_src = [ + '../common/tuklib_physmem.c', +] + +if have_threads == true + lzma_src += [ + '../common/tuklib_cpucores.c', + ] +endif + +# common/Makefile.inc + +lzma_src += [ + 'common/common.c', + 'common/block_util.c', + 'common/easy_preset.c', + 'common/filter_common.c', + 'common/hardware_physmem.c', + 'common/index.c', + 'common/stream_flags_common.c', + 'common/string_conversion.c', + 'common/vli_size.c', +] + +if have_threads == true + lzma_src += [ + 'common/hardware_cputhreads.c', + 'common/outqueue.c', + ] +endif + +if get_option('encoders').length() > 0 + lzma_src += [ + 'common/alone_encoder.c', + 'common/block_buffer_encoder.c', + 'common/block_encoder.c', + 'common/block_header_encoder.c', + 'common/easy_buffer_encoder.c', + 'common/easy_encoder.c', + 'common/easy_encoder_memusage.c', + 'common/filter_buffer_encoder.c', + 'common/filter_encoder.c', + 'common/filter_flags_encoder.c', + 'common/index_encoder.c', + 'common/stream_buffer_encoder.c', + 'common/stream_encoder.c', + 'common/stream_flags_encoder.c', + 'common/vli_encoder.c', + ] + + if have_threads == true + lzma_src += [ + 'common/stream_encoder_mt.c', + ] + endif + + if get_option('microlzma') == true + lzma_src += [ + 'common/microlzma_encoder.c', + ] + endif +endif + +if get_option('decoders').length() > 0 + lzma_src += [ + 'common/alone_decoder.c', + 'common/auto_decoder.c', + 'common/block_buffer_decoder.c', + 'common/block_decoder.c', + 'common/block_header_decoder.c', + 'common/easy_decoder_memusage.c', + 'common/file_info.c', + 'common/filter_buffer_decoder.c', + 'common/filter_decoder.c', + 'common/filter_flags_decoder.c', + 'common/index_decoder.c', + 'common/index_hash.c', + 'common/stream_buffer_decoder.c', + 'common/stream_decoder.c', + 'common/stream_flags_decoder.c', + 'common/vli_decoder.c' + ] + + if have_threads == true + lzma_src += [ + 'common/stream_decoder_mt.c', + ] + endif + + if get_option('microlzma') == true + lzma_src += [ + 'common/microlzma_decoder.c' + ] + endif + + if have_lzip == true + lzma_src += 'common/lzip_decoder.c' + endif +endif + +# check/Makefile.inc + +lzma_src += [ + 'check/check.c' +] + +if get_option('small') == true + lzma_src += [ + 'check/crc32_small.c' + ] +else + lzma_src += [ + 'check/crc32_table.c' + ] + + if have_assembler_x86 == true + lzma_src += [ + 'check/crc32_x86.S' + ] + else + lzma_src += [ + 'check/crc32_fast.c' + ] + endif +endif + +if get_option('checks').contains('crc64') == true + if get_option('small') == true + lzma_src += [ + 'check/crc64_small.c' + ] + else + lzma_src += [ + 'check/crc64_table.c' + ] + + if have_assembler_x86 == true + lzma_src += [ + 'check/crc64_x86.S' + ] + else + lzma_src += [ + 'check/crc64_fast.c' + ] + endif + endif +endif + +if get_option('checks').contains('sha256') == true and get_option('external-sha256') == false + lzma_src += [ + 'check/sha256.c' + ] +endif + +if get_option('encoders').contains('lzma1') == true or + get_option('decoders').contains('lzma1') == true or + get_option('encoders').contains('lzma2') == true or + get_option('decoders').contains('lzma2') == true + + # lz/Makefile.inc + if get_option('encoders').contains('lzma1') == true or + get_option('encoders').contains('lzma2') == true + lzma_src += [ + 'lz/lz_encoder.c', + 'lz/lz_encoder_mf.c' + ] + endif + + if get_option('decoders').contains('lzma1') == true or + get_option('decoders').contains('lzma2') == true + lzma_src += [ + 'lz/lz_decoder.c' + ] + endif +endif + +if get_option('encoders').contains('lzma1') == true or + get_option('decoders').contains('lzma1') == true + + # lzma/Makefile.inc + lzma_src += [ + 'lzma/lzma_encoder_presets.c' + ] + + if get_option('encoders').contains('lzma1') == true + lzma_src += [ + 'lzma/lzma_encoder.c', + 'lzma/lzma_encoder_optimum_fast.c', + 'lzma/lzma_encoder_optimum_normal.c' + ] + + if get_option('small') == false + lzma_src += [ + 'lzma/fastpos_table.c' + ] + endif + endif + + if get_option('decoders').contains('lzma1') == true + lzma_src += [ + 'lzma/lzma_decoder.c' + ] + endif + + if get_option('encoders').contains('lzma2') == true + lzma_src += [ + 'lzma/lzma2_encoder.c' + ] + endif + + if get_option('decoders').contains('lzma2') == true + lzma_src += [ + 'lzma/lzma2_decoder.c' + ] + endif + + # rangecoder/Makefile.inc + if get_option('encoders').contains('lzma1') == true + lzma_src += [ + 'rangecoder/price_table.c' + ] + endif +endif + +if get_option('encoders').contains('delta') == true or + get_option('decoders').contains('delta') == true + + # delta/Makefile.inc + lzma_src += [ + 'delta/delta_common.c' + ] + + if get_option('encoders').contains('delta') == true + lzma_src += [ + 'delta/delta_encoder.c' + ] + endif + + if get_option('decoders').contains('delta') == true + lzma_src += [ + 'delta/delta_decoder.c' + ] + endif +endif + +if have_encoder_simple_filters == true or have_decoder_simple_filters == true + + # simple/Makefile.inc + lzma_src += [ + 'simple/simple_coder.c' + ] + + if have_encoder_simple_filters == true + lzma_src += [ + 'simple/simple_encoder.c' + ] + endif + + if have_decoder_simple_filters == true + lzma_src += [ + 'simple/simple_decoder.c' + ] + endif + + foreach f : simple_filters + if get_option('encoders').contains(f) == true or + get_option('decoders').contains(f) == true + lzma_src += [ + 'simple/' + f + '.c' + ] + endif + endforeach +endif + +# resource file + +win_mod = import('windows') + +if sys_windows == true + liblzma_rc = win_mod.compile_resources(files('liblzma_w32res.rc'), + args : [ '-DHAVE_CONFIG_H', '-DTUKLIB_SYMBOL_PREFIX=lzma_' ], + depend_files : files('../common/common_w32res.rc'), + include_directories : [ '../src/common/', config_dir ]) + lzma_src += [ liblzma_rc ] +endif + +lzma_c_args += [ + '-DHAVE_CONFIG_H', + '-DHAVE_STDBOOL_H', + '-DHAVE_INTTYPES_H', + '-DHAVE_STDINT_H', +] + +lzma_incdir = [ + config_dir, + '../common', + 'api', + 'check', + 'common', + 'delta', + 'lz', + 'lzma', + 'rangecoder', + 'simple', +] + +lzma_deps = [] + +if sys_windows == false and have_threads == true + lzma_deps += pthread_dep +endif + +lzma_lib = library('lzma', lzma_src, + c_args : lzma_c_args, + dependencies : lzma_deps, + gnu_symbol_visibility : 'hidden', + include_directories : lzma_incdir, + install : true, + link_args : sys_windows ? '-Wl,--output-def,liblzma.def.in' : '', + version : meson.project_version(), +) + +# pc file + +pkg_mod = import('pkgconfig') + +pkg_mod.generate( + lzma_lib, + description : 'General purpose data compression library', + name : 'liblzma', + url : 'https://tukaani.org/xz/', +) + +install_headers('api/lzma.h', + install_dir: get_option('prefix') / get_option('includedir') +) + +lzma_headers = files([ + 'api/lzma/base.h', + 'api/lzma/bcj.h', + 'api/lzma/block.h', + 'api/lzma/check.h', + 'api/lzma/container.h', + 'api/lzma/delta.h', + 'api/lzma/filter.h', + 'api/lzma/hardware.h', + 'api/lzma/index.h', + 'api/lzma/index_hash.h', + 'api/lzma/lzma12.h', + 'api/lzma/stream_flags.h', + 'api/lzma/version.h', + 'api/lzma/vli.h', +]) + +install_headers(lzma_headers, + install_dir: get_option('prefix') / get_option('includedir') / 'lzma' +) diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 000000000..7b93d765a --- /dev/null +++ b/src/meson.build @@ -0,0 +1,6 @@ +## SPDX-License-Identifier: 0BSD +## Author: Vincent Torri + +subdir('common') +subdir('liblzma') +# subdir('xzdec') \ No newline at end of file From fc52493cced9470318026574d94420c86227bcb7 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Thu, 2 May 2024 16:18:43 +0200 Subject: [PATCH 02/25] improve meson code --- meson.build | 32 +++++++++++++------------------- src/common/meson.build | 2 +- src/liblzma/meson.build | 6 ++---- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/meson.build b/meson.build index 598fabbd8..7f653b841 100644 --- a/meson.build +++ b/meson.build @@ -15,9 +15,7 @@ project( ], default_options: [ 'b_ndebug=if-release', - 'buildtype=debug', - 'c_std=c99', - 'libdir=lib', + 'c_std=c11', 'warning_level=3', ], meson_version: '>= 1.1.0', @@ -59,13 +57,13 @@ cc = meson.get_compiler('c') # try mimic AC_USE_SYSTEM_EXTENSIONS if host_machine.system() == 'linux' - add_global_arguments('-D_GNU_SOURCE', language: 'c') + add_project_arguments('-D_GNU_SOURCE', language: 'c') elif host_machine.system() == 'sunos' - add_global_arguments('-D__EXTENSIONS__', language: 'c') - add_global_arguments('-D_POSIX_PTHREAD_SEMANTICS', language: 'c') + add_project_arguments('-D__EXTENSIONS__', language: 'c') + add_project_arguments('-D_POSIX_PTHREAD_SEMANTICS', language: 'c') else - add_global_arguments('-D_TANDEM_SOURCE', language: 'c') - add_global_arguments('-D_ALL_SOURCE', language: 'c') + add_project_arguments('-D_TANDEM_SOURCE', language: 'c') + add_project_arguments('-D_ALL_SOURCE', language: 'c') endif lzma_c_args = [] @@ -116,11 +114,7 @@ if cc.get_argument_syntax() == 'gcc' '-Wstring-conversion', ] - foreach cf : cflags_try - if cc.has_argument(cf) - lzma_c_args += cf - endif - endforeach + lzma_c_args += cc.get_supported_arguments(cflags_try) endif config_h.set10('HAVE_VISIBILITY', cc.has_function_attribute('visibility'), @@ -197,13 +191,13 @@ simple_filters = [ # FIXME foreach i in array; set_variable(f'have_@i@', true) endforeach foreach f : supported_filters - if get_option('encoders').contains(f) == true + if get_option('encoders').contains(f) config_h.set10('HAVE_ENCODER_' + f.underscorify().to_upper(), true, description: 'Define to 1 if ' + f + ' encoder is enabled.' ) encoder_msg += f + ' ' endif - if get_option('decoders').contains(f) == true + if get_option('decoders').contains(f) config_h.set10('HAVE_DECODER_' + f.underscorify().to_upper(), true, description: 'Define to 1 if ' + f + ' decoder is enabled.' ) @@ -214,15 +208,15 @@ endforeach have_encoder_simple_filters = false have_decoder_simple_filters = false foreach f : simple_filters - if get_option('encoders').contains(f) == true + if get_option('encoders').contains(f) have_encoder_simple_filters = true endif - if get_option('decoders').contains(f) == true + if get_option('decoders').contains(f) have_decoder_simple_filters = true endif endforeach -if (get_option('encoders').contains('lzma2') == true and get_option('encoders').contains('lzma1') == false) or (get_option('decoders').contains('lzma2') == true and get_option('decoders').contains('lzma1') == false) +if (get_option('encoders').contains('lzma2') and not get_option('encoders').contains('lzma1')) or (get_option('decoders').contains('lzma2') and not get_option('decoders').contains('lzma1')) error('LZMA2 requires that LZMA1 is also enabled') endif @@ -342,7 +336,7 @@ if get_option('threads') == true endif have_threads = true else - pthread_dep = dependency('threads') + pthread_dep = dependency('threads', required : false) if pthread_dep.found() config_h.set10('MYTHREAD_POSIX', true, description: 'Define to 1 when using POSIX threads (pthreads).' diff --git a/src/common/meson.build b/src/common/meson.build index 9e137e605..a8c18760c 100644 --- a/src/common/meson.build +++ b/src/common/meson.build @@ -130,7 +130,7 @@ int main() } ''' res = cc.links(bswap_src, name: '__builtin_bswap16/32/64') -if res == true +if res config_h.set10('HAVE___BUILTIN_BSWAPXX', true, description: 'Define to 1 if the GNU C extensions __builtin_bswap16/32/64 are supported.' ) diff --git a/src/liblzma/meson.build b/src/liblzma/meson.build index f3ff32494..d4eb10e22 100644 --- a/src/liblzma/meson.build +++ b/src/liblzma/meson.build @@ -334,9 +334,7 @@ pkg_mod.generate( url : 'https://tukaani.org/xz/', ) -install_headers('api/lzma.h', - install_dir: get_option('prefix') / get_option('includedir') -) +install_headers('api/lzma.h') lzma_headers = files([ 'api/lzma/base.h', @@ -356,5 +354,5 @@ lzma_headers = files([ ]) install_headers(lzma_headers, - install_dir: get_option('prefix') / get_option('includedir') / 'lzma' + subdir: 'lzma' ) From 72f696e5426cfa3e6ee9e294108e051d39890253 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Fri, 3 May 2024 05:58:32 +0200 Subject: [PATCH 03/25] remove '== true' or '== false', use 'in' instead of 'contains()' --- meson.build | 35 +++++++++--------- src/common/meson.build | 22 +++++------ src/liblzma/meson.build | 81 ++++++++++++++++++++--------------------- 3 files changed, 66 insertions(+), 72 deletions(-) diff --git a/meson.build b/meson.build index 7f653b841..db0e8a67e 100644 --- a/meson.build +++ b/meson.build @@ -191,13 +191,13 @@ simple_filters = [ # FIXME foreach i in array; set_variable(f'have_@i@', true) endforeach foreach f : supported_filters - if get_option('encoders').contains(f) + if f in get_option('encoders') config_h.set10('HAVE_ENCODER_' + f.underscorify().to_upper(), true, description: 'Define to 1 if ' + f + ' encoder is enabled.' ) encoder_msg += f + ' ' endif - if get_option('decoders').contains(f) + if f in get_option('decoders') config_h.set10('HAVE_DECODER_' + f.underscorify().to_upper(), true, description: 'Define to 1 if ' + f + ' decoder is enabled.' ) @@ -208,15 +208,16 @@ endforeach have_encoder_simple_filters = false have_decoder_simple_filters = false foreach f : simple_filters - if get_option('encoders').contains(f) + if f in get_option('encoders') have_encoder_simple_filters = true endif - if get_option('decoders').contains(f) + if f in get_option('decoders') have_decoder_simple_filters = true endif endforeach -if (get_option('encoders').contains('lzma2') and not get_option('encoders').contains('lzma1')) or (get_option('decoders').contains('lzma2') and not get_option('decoders').contains('lzma1')) +if ('lzma2' in get_option('encoders') and not ('lzma1' in get_option('encoders'))) or + ('lzma2' in get_option('decoders') and not ('lzma1' in get_option('decoders'))) error('LZMA2 requires that LZMA1 is also enabled') endif @@ -244,13 +245,13 @@ match_finders = [ 'bt4' ] -if get_option('encoders').contains('lzma2') == true or get_option('encoders').contains('lzma1') == true +if 'lzma1' in get_option('encoders') or 'lzma2' in get_option('encoders') if get_option('match-finders').length() == 0 error('at least one match finder is required for an LZ-based encoder') endif foreach m : match_finders - if get_option('match-finders').contains(m) == true + if m in get_option('match-finders') config_h.set10('HAVE_MF_' + m.underscorify().to_upper(), true, description: 'Define to 1 to enable ' + m + ' match finder.' ) @@ -269,8 +270,12 @@ checks = [ 'sha256' ] +if not ('crc32' in get_option('checks')) + error('For now, the CRC32 check must always be enabled') +endif + foreach c : checks - if get_option('checks').contains(c) == true + if c in get_option('checks') config_h.set10('HAVE_CHECK_' + c.underscorify().to_upper(), true, description: 'Define to 1 if ' + c + ' integrity check is enabled.' ) @@ -278,10 +283,6 @@ foreach c : checks endif endforeach -if get_option('checks').contains('crc32') == false - error('For now, the CRC32 check must always be enabled') -endif - ### microLZMA if get_option('microlzma') == true @@ -290,9 +291,9 @@ endif ### .lz (lzip) format support have_lzip = false -if get_option('encoders').contains('lzma1') == false +if not ('lzma1' in get_option('encoders')) lzip_msg = 'no (LZMA1 disabled)' -elif get_option('lzip-decoder') == true +elif get_option('lzip-decoder') lzip_msg = 'yes' have_lzip = true config_h.set10('HAVE_LZIP_DECODER', true, @@ -305,15 +306,15 @@ endif ### assembler optimizations have_assembler_x86 = false -if get_option('assembler') == true - if asm_os.contains(host_os) and host_machine.cpu_family() == 'x86' +if get_option('assembler') + if host_os in asm_os and host_machine.cpu_family() == 'x86' have_assembler_x86 = true endif endif ### size optimization -if get_option('small') == true +if get_option('small') config_h.set10('HAVE_SMALL', true, description: 'Define to 1 if optimizing for size.' ) diff --git a/src/common/meson.build b/src/common/meson.build index a8c18760c..214691940 100644 --- a/src/common/meson.build +++ b/src/common/meson.build @@ -150,7 +150,7 @@ else endif endforeach - if have_byteswap_h == true + if have_byteswap_h bswap_fcts = [ 'bswap_16', 'bswap_32', @@ -165,8 +165,7 @@ int main() return 0; } ''' - res = cc.links(bswap_src.format(f), name: f) - if res == true + if cc.links(bswap_src.format(f), name: f) config_h.set10('HAVE_' + f.to_upper(), true, description: 'Define to 1 if ' + f + '() is available.' ) @@ -176,7 +175,7 @@ int main() endif fast_unaligned_access = false -if get_option('unaligned-access').auto() == true +if get_option('unaligned-access').auto() unaligned_access_cpus = [ 'ppc', 'ppc64', @@ -193,7 +192,7 @@ if get_option('unaligned-access').auto() == true endif endforeach - if fast_unaligned_access == false + if not fast_unaligned_access unaligned_access_cpus = [ 'aarch64', 'arm', @@ -210,8 +209,7 @@ compile error #endif int main(void) { return 0; } ''' - res = cc.compiles(ua_src, name: 'fast unaligned access for ' + cpu) - if res == true + if cc.compiles(ua_src, name: 'fast unaligned access for ' + cpu) config_h.set10('TUKLIB_FAST_UNALIGNED_ACCESS', true, description: 'Define to 1 if the system supports fast unaligned access to 16-bit, 32-bit, and 64-bit integers.' ) @@ -221,14 +219,14 @@ int main(void) { return 0; } endif endforeach endif -elif get_option('unaligned-access').enabled() == true +elif get_option('unaligned-access').enabled() config_h.set10('TUKLIB_FAST_UNALIGNED_ACCESS', true, description: 'Define to 1 if the system supports fast unaligned access to 16-bit, 32-bit, and 64-bit integers.' ) fast_unaligned_access = true endif -if get_option('unsafe-type-punning') == true +if get_option('unsafe-type-punning') config_h.set10('HAVE___BUILTIN_ASSUME_ALIGNED', true, description: 'Define to 1 if the GNU C extension __builtin_assume_aligned is supported.' ) @@ -246,10 +244,8 @@ if cc.has_header('wchar.h') prefix : '#include ' ) - if res == true - if cc.has_function('mbrtowc', - prefix : '#include ' - ) + if cc.has_type('mbstate_t', prefix : '#include ') + if cc.has_function('mbrtowc', prefix : '#include ') config_h.set10('HAVE_MBRTOWC', true, description: 'Define to 1 if the mbrtowc() function is available.' ) diff --git a/src/liblzma/meson.build b/src/liblzma/meson.build index d4eb10e22..2fe701734 100644 --- a/src/liblzma/meson.build +++ b/src/liblzma/meson.build @@ -5,7 +5,7 @@ lzma_src = [ '../common/tuklib_physmem.c', ] -if have_threads == true +if have_threads lzma_src += [ '../common/tuklib_cpucores.c', ] @@ -25,7 +25,7 @@ lzma_src += [ 'common/vli_size.c', ] -if have_threads == true +if have_threads lzma_src += [ 'common/hardware_cputhreads.c', 'common/outqueue.c', @@ -51,13 +51,13 @@ if get_option('encoders').length() > 0 'common/vli_encoder.c', ] - if have_threads == true + if have_threads lzma_src += [ 'common/stream_encoder_mt.c', ] endif - if get_option('microlzma') == true + if get_option('microlzma') lzma_src += [ 'common/microlzma_encoder.c', ] @@ -84,19 +84,19 @@ if get_option('decoders').length() > 0 'common/vli_decoder.c' ] - if have_threads == true + if have_threads lzma_src += [ 'common/stream_decoder_mt.c', ] endif - if get_option('microlzma') == true + if get_option('microlzma') lzma_src += [ 'common/microlzma_decoder.c' ] endif - if have_lzip == true + if have_lzip lzma_src += 'common/lzip_decoder.c' endif endif @@ -107,7 +107,7 @@ lzma_src += [ 'check/check.c' ] -if get_option('small') == true +if get_option('small') lzma_src += [ 'check/crc32_small.c' ] @@ -116,7 +116,7 @@ else 'check/crc32_table.c' ] - if have_assembler_x86 == true + if have_assembler_x86 lzma_src += [ 'check/crc32_x86.S' ] @@ -127,8 +127,8 @@ else endif endif -if get_option('checks').contains('crc64') == true - if get_option('small') == true +if 'crc64' in get_option('checks') + if get_option('small') lzma_src += [ 'check/crc64_small.c' ] @@ -137,7 +137,7 @@ if get_option('checks').contains('crc64') == true 'check/crc64_table.c' ] - if have_assembler_x86 == true + if have_assembler_x86 lzma_src += [ 'check/crc64_x86.S' ] @@ -149,125 +149,123 @@ if get_option('checks').contains('crc64') == true endif endif -if get_option('checks').contains('sha256') == true and get_option('external-sha256') == false +if ('sha256' in get_option('checks')) and (not get_option('external-sha256')) lzma_src += [ 'check/sha256.c' ] endif -if get_option('encoders').contains('lzma1') == true or - get_option('decoders').contains('lzma1') == true or - get_option('encoders').contains('lzma2') == true or - get_option('decoders').contains('lzma2') == true +if ('lzma1' in get_option('encoders')) or + ('lzma1' in get_option('decoders')) or + ('lzma2' in get_option('encoders')) or + ('lzma2' in get_option('decoders')) # lz/Makefile.inc - if get_option('encoders').contains('lzma1') == true or - get_option('encoders').contains('lzma2') == true + if ('lzma1' in get_option('encoders')) or + ('lzma2' in get_option('encoders')) lzma_src += [ 'lz/lz_encoder.c', 'lz/lz_encoder_mf.c' ] endif - if get_option('decoders').contains('lzma1') == true or - get_option('decoders').contains('lzma2') == true + if ('lzma1' in get_option('encoders')) or + ('lzma2' in get_option('encoders')) lzma_src += [ 'lz/lz_decoder.c' ] endif endif -if get_option('encoders').contains('lzma1') == true or - get_option('decoders').contains('lzma1') == true +if ('lzma1' in get_option('encoders')) or ('lzma1' in get_option('decoders')) # lzma/Makefile.inc lzma_src += [ 'lzma/lzma_encoder_presets.c' ] - if get_option('encoders').contains('lzma1') == true + if 'lzma1' in get_option('encoders') lzma_src += [ 'lzma/lzma_encoder.c', 'lzma/lzma_encoder_optimum_fast.c', 'lzma/lzma_encoder_optimum_normal.c' ] - if get_option('small') == false + if not get_option('small') lzma_src += [ 'lzma/fastpos_table.c' ] endif endif - if get_option('decoders').contains('lzma1') == true + if 'lzma1' in get_option('decoders') lzma_src += [ 'lzma/lzma_decoder.c' ] endif - if get_option('encoders').contains('lzma2') == true + if 'lzma2' in get_option('encoders') lzma_src += [ 'lzma/lzma2_encoder.c' ] endif - if get_option('decoders').contains('lzma2') == true + if 'lzma2' in get_option('decoders') lzma_src += [ 'lzma/lzma2_decoder.c' ] endif # rangecoder/Makefile.inc - if get_option('encoders').contains('lzma1') == true + if 'lzma1' in get_option('encoders') lzma_src += [ 'rangecoder/price_table.c' ] endif endif -if get_option('encoders').contains('delta') == true or - get_option('decoders').contains('delta') == true +if ('delta' in get_option('encoders')) or ('delta' in get_option('decoders')) # delta/Makefile.inc lzma_src += [ 'delta/delta_common.c' ] - if get_option('encoders').contains('delta') == true + if 'delta' in get_option('encoders') lzma_src += [ 'delta/delta_encoder.c' ] endif - if get_option('decoders').contains('delta') == true + if 'delta' in get_option('decoders') lzma_src += [ 'delta/delta_decoder.c' ] endif endif -if have_encoder_simple_filters == true or have_decoder_simple_filters == true +if have_encoder_simple_filters or have_decoder_simple_filters # simple/Makefile.inc lzma_src += [ 'simple/simple_coder.c' ] - if have_encoder_simple_filters == true + if have_encoder_simple_filters lzma_src += [ 'simple/simple_encoder.c' ] endif - if have_decoder_simple_filters == true + if have_decoder_simple_filters lzma_src += [ 'simple/simple_decoder.c' ] endif foreach f : simple_filters - if get_option('encoders').contains(f) == true or - get_option('decoders').contains(f) == true + if (f in get_option('encoders')) or + (f in get_option('decoders')) lzma_src += [ 'simple/' + f + '.c' ] @@ -279,7 +277,7 @@ endif win_mod = import('windows') -if sys_windows == true +if sys_windows liblzma_rc = win_mod.compile_resources(files('liblzma_w32res.rc'), args : [ '-DHAVE_CONFIG_H', '-DTUKLIB_SYMBOL_PREFIX=lzma_' ], depend_files : files('../common/common_w32res.rc'), @@ -309,7 +307,7 @@ lzma_incdir = [ lzma_deps = [] -if sys_windows == false and have_threads == true +if (not sys_windows) and have_threads lzma_deps += pthread_dep endif @@ -353,6 +351,5 @@ lzma_headers = files([ 'api/lzma/vli.h', ]) -install_headers(lzma_headers, - subdir: 'lzma' +install_headers(lzma_headers, subdir: 'lzma' ) From 8f0731e245f0af8fd023877f774006d4346cc2fa Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Fri, 3 May 2024 06:19:35 +0200 Subject: [PATCH 04/25] remove now useless 'res', formatting --- src/common/meson.build | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/common/meson.build b/src/common/meson.build index 214691940..e4b38520f 100644 --- a/src/common/meson.build +++ b/src/common/meson.build @@ -240,16 +240,11 @@ if cc.has_header('wchar.h') description: 'Define to 1 if the header file is available.' ) - res = cc.has_type('mbstate_t', - prefix : '#include ' - ) - - if cc.has_type('mbstate_t', prefix : '#include ') - if cc.has_function('mbrtowc', prefix : '#include ') - config_h.set10('HAVE_MBRTOWC', true, - description: 'Define to 1 if the mbrtowc() function is available.' - ) - endif + if cc.has_type('mbstate_t', prefix : '#include ') and + cc.has_function('mbrtowc', prefix : '#include ') + config_h.set10('HAVE_MBRTOWC', true, + description: 'Define to 1 if the mbrtowc() function is available.' + ) endif if cc.has_function('wcwidth', From 7056bbc2f62cb4c6e045ec93bcaca0faa9451dde Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Fri, 3 May 2024 06:28:51 +0200 Subject: [PATCH 05/25] remove uselesss match_finders array, + fix --- meson.build | 23 ++++++----------------- src/common/meson.build | 3 +-- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/meson.build b/meson.build index db0e8a67e..4d06cbbef 100644 --- a/meson.build +++ b/meson.build @@ -216,8 +216,7 @@ foreach f : simple_filters endif endforeach -if ('lzma2' in get_option('encoders') and not ('lzma1' in get_option('encoders'))) or - ('lzma2' in get_option('decoders') and not ('lzma1' in get_option('decoders'))) +if ('lzma2' in get_option('encoders') and not ('lzma1' in get_option('encoders'))) or('lzma2' in get_option('decoders') and not ('lzma1' in get_option('decoders'))) error('LZMA2 requires that LZMA1 is also enabled') endif @@ -237,26 +236,16 @@ endif match_finder_msg = '' -match_finders = [ - 'hc3', - 'hc4', - 'bt2', - 'bt3', - 'bt4' -] - if 'lzma1' in get_option('encoders') or 'lzma2' in get_option('encoders') if get_option('match-finders').length() == 0 error('at least one match finder is required for an LZ-based encoder') endif - foreach m : match_finders - if m in get_option('match-finders') - config_h.set10('HAVE_MF_' + m.underscorify().to_upper(), true, - description: 'Define to 1 to enable ' + m + ' match finder.' - ) - match_finder_msg += m + ' ' - endif + foreach m : get_option('match-finders') + config_h.set10('HAVE_MF_' + m.underscorify().to_upper(), true, + description: 'Define to 1 to enable ' + m + ' match finder.' + ) + match_finder_msg += m + ' ' endforeach endif diff --git a/src/common/meson.build b/src/common/meson.build index e4b38520f..d01853b1b 100644 --- a/src/common/meson.build +++ b/src/common/meson.build @@ -240,8 +240,7 @@ if cc.has_header('wchar.h') description: 'Define to 1 if the header file is available.' ) - if cc.has_type('mbstate_t', prefix : '#include ') and - cc.has_function('mbrtowc', prefix : '#include ') + if cc.has_type('mbstate_t', prefix : '#include ') and cc.has_function('mbrtowc', prefix : '#include ') config_h.set10('HAVE_MBRTOWC', true, description: 'Define to 1 if the mbrtowc() function is available.' ) From d8238215f5cdb8225ab4660d1f63c66bf76b59d5 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Fri, 3 May 2024 06:32:16 +0200 Subject: [PATCH 06/25] remove uselesss checks array --- meson.build | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/meson.build b/meson.build index 4d06cbbef..6f40b2fd8 100644 --- a/meson.build +++ b/meson.build @@ -253,23 +253,15 @@ endif check_msg = '' -checks = [ - 'crc32', - 'crc64', - 'sha256' -] - if not ('crc32' in get_option('checks')) error('For now, the CRC32 check must always be enabled') endif -foreach c : checks - if c in get_option('checks') - config_h.set10('HAVE_CHECK_' + c.underscorify().to_upper(), true, - description: 'Define to 1 if ' + c + ' integrity check is enabled.' - ) - check_msg += c + ' ' - endif +foreach c : get_option('checks') + config_h.set10('HAVE_CHECK_' + c.underscorify().to_upper(), true, + description: 'Define to 1 if ' + c + ' integrity check is enabled.' + ) + check_msg += c + ' ' endforeach ### microLZMA From 3f290102fa92bb1dbd08402979902499687b2b7c Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Fri, 3 May 2024 06:41:03 +0200 Subject: [PATCH 07/25] remove outer if --- src/liblzma/meson.build | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/liblzma/meson.build b/src/liblzma/meson.build index 2fe701734..d72b085df 100644 --- a/src/liblzma/meson.build +++ b/src/liblzma/meson.build @@ -155,26 +155,18 @@ if ('sha256' in get_option('checks')) and (not get_option('external-sha256')) ] endif -if ('lzma1' in get_option('encoders')) or - ('lzma1' in get_option('decoders')) or - ('lzma2' in get_option('encoders')) or - ('lzma2' in get_option('decoders')) - - # lz/Makefile.inc - if ('lzma1' in get_option('encoders')) or - ('lzma2' in get_option('encoders')) - lzma_src += [ - 'lz/lz_encoder.c', - 'lz/lz_encoder_mf.c' - ] - endif +# lz/Makefile.inc +if ('lzma1' in get_option('encoders')) or ('lzma2' in get_option('encoders')) + lzma_src += [ + 'lz/lz_encoder.c', + 'lz/lz_encoder_mf.c' + ] + endif - if ('lzma1' in get_option('encoders')) or - ('lzma2' in get_option('encoders')) - lzma_src += [ - 'lz/lz_decoder.c' - ] - endif +if ('lzma1' in get_option('decoders')) or ('lzma2' in get_option('decoders')) + lzma_src += [ + 'lz/lz_decoder.c' + ] endif if ('lzma1' in get_option('encoders')) or ('lzma1' in get_option('decoders')) From 070a65dc3c61a13447ec2de54c7f0fa7eea86087 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Sat, 4 May 2024 06:36:43 +0200 Subject: [PATCH 08/25] change project name to 'xz-utils' to avoid space in the dist tarball (warning from meson) --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 6f40b2fd8..e7a660c43 100644 --- a/meson.build +++ b/meson.build @@ -2,7 +2,7 @@ ## Author: Vincent Torri project( - 'XZ Utils', + 'xz-utils', 'c', version: '5.6.99', license: '0BSD', From 132cde1b031a0308a5408f7acca4ccaa9800dd36 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Sat, 4 May 2024 09:17:04 +0200 Subject: [PATCH 09/25] use get_option() instead of array --- meson.build | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/meson.build b/meson.build index e7a660c43..abc61ef2c 100644 --- a/meson.build +++ b/meson.build @@ -163,20 +163,6 @@ endif encoder_msg = '' decoder_msg = '' -supported_filters = [ - 'lzma1', - 'lzma2', - 'delta', - 'x86', - 'powerpc', - 'ia64', - 'arm', - 'armthumb', - 'arm64', - 'sparc', - 'riscv', -] - simple_filters = [ 'x86', 'powerpc', @@ -190,19 +176,18 @@ simple_filters = [ # FIXME foreach i in array; set_variable(f'have_@i@', true) endforeach -foreach f : supported_filters - if f in get_option('encoders') - config_h.set10('HAVE_ENCODER_' + f.underscorify().to_upper(), true, - description: 'Define to 1 if ' + f + ' encoder is enabled.' - ) - encoder_msg += f + ' ' - endif - if f in get_option('decoders') - config_h.set10('HAVE_DECODER_' + f.underscorify().to_upper(), true, - description: 'Define to 1 if ' + f + ' decoder is enabled.' - ) - decoder_msg += f + ' ' - endif +foreach f : get_option('encoders') + config_h.set10('HAVE_ENCODER_' + f.underscorify().to_upper(), true, + description: 'Define to 1 if ' + f + ' encoder is enabled.' + ) + encoder_msg += f + ' ' +endforeach + +foreach f : get_option('encoders') + config_h.set10('HAVE_DECODER_' + f.underscorify().to_upper(), true, + description: 'Define to 1 if ' + f + ' decoder is enabled.' + ) + decoder_msg += f + ' ' endforeach have_encoder_simple_filters = false From fc9655e12959cd6295660ed4107179f38ce48c15 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Sat, 4 May 2024 12:35:54 +0200 Subject: [PATCH 10/25] fix copy-paste typo --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index abc61ef2c..568c311ea 100644 --- a/meson.build +++ b/meson.build @@ -183,7 +183,7 @@ foreach f : get_option('encoders') encoder_msg += f + ' ' endforeach -foreach f : get_option('encoders') +foreach f : get_option('decoders') config_h.set10('HAVE_DECODER_' + f.underscorify().to_upper(), true, description: 'Define to 1 if ' + f + ' decoder is enabled.' ) From 0ffc20d22329d3227c9773d5e1c347986ff85161 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Thu, 9 May 2024 07:19:32 +0200 Subject: [PATCH 11/25] fix posix_fadvise() detection --- meson.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 568c311ea..15071a2b8 100644 --- a/meson.build +++ b/meson.build @@ -151,9 +151,9 @@ foreach f : time_fcts endif endforeach -if cc.has_function('posix_advice', prefix : '#include ') - config_h.set10('HAVE_POSIX_ADVICE', true, - description: 'Define to 1 if the posix_advice() function is available.' +if cc.has_function('posix_fadvise', prefix : '#include ') + config_h.set10('HAVE_POSIX_FADVISE', true, + description: 'Define to 1 if the posix_fadvise() function is available.' ) endif From aca1aa28d993d98a066e91940d46aba28079c4bf Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Thu, 9 May 2024 07:40:04 +0200 Subject: [PATCH 12/25] change tarball name to 'xz' as recommended in PACKAGERS file --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 15071a2b8..7b6ed796d 100644 --- a/meson.build +++ b/meson.build @@ -2,7 +2,7 @@ ## Author: Vincent Torri project( - 'xz-utils', + 'xz', 'c', version: '5.6.99', license: '0BSD', From ae73fa4619a4b450574ae2bfa9efc9e4fa26ee43 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Thu, 16 May 2024 01:03:23 +0200 Subject: [PATCH 13/25] add xzdec and lzmadec + a couple of improvements --- meson.build | 7 ++++ meson_options.txt | 4 +- src/common/meson.build | 34 +++++++--------- src/liblzma/meson.build | 5 ++- src/meson.build | 2 +- src/xzdec/meson.build | 89 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 117 insertions(+), 24 deletions(-) create mode 100644 src/xzdec/meson.build diff --git a/meson.build b/meson.build index 7b6ed796d..9fc80df9b 100644 --- a/meson.build +++ b/meson.build @@ -341,3 +341,10 @@ summary( }, section: 'Configuration Options Summary:', ) +summary( + { + 'xzdec': get_option('xzdec'), + 'lzmadec': get_option('lzmadec'), + }, + section: 'Tools', +) diff --git a/meson_options.txt b/meson_options.txt index d9d5f374e..4a18a095f 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -13,7 +13,7 @@ # [X] encoders # [X] external-sha256 # [X] lzip-decoder -# [ ] lzmadec +# [X] lzmadec # [ ] lzmainfo # [ ] lzma-links # [X] match-finders @@ -28,7 +28,7 @@ # [X] unsafe-type-punning # [ ] werror - not used : done by meson # [ ] xz -# [ ] xzdec +# [X] xzdec option('arm64-crc32', type : 'boolean', diff --git a/src/common/meson.build b/src/common/meson.build index d01853b1b..ed3d3a756 100644 --- a/src/common/meson.build +++ b/src/common/meson.build @@ -182,15 +182,12 @@ if get_option('unaligned-access').auto() 'x86', 'x86_64', ] - foreach cpu : unaligned_access_cpus - if host_machine.cpu_family() == cpu - config_h.set10('TUKLIB_FAST_UNALIGNED_ACCESS', true, - description: 'Define to 1 if the system supports fast unaligned access to 16-bit, 32-bit, and 64-bit integers.' - ) - fast_unaligned_access = true - break - endif - endforeach + if host_machine.cpu_family() in unaligned_access_cpus + config_h.set10('TUKLIB_FAST_UNALIGNED_ACCESS', true, + description: 'Define to 1 if the system supports fast unaligned access to 16-bit, 32-bit, and 64-bit integers.' + ) + fast_unaligned_access = true + endif if not fast_unaligned_access unaligned_access_cpus = [ @@ -199,9 +196,8 @@ if get_option('unaligned-access').auto() 'riscv32', 'riscv64', ] - foreach cpu : unaligned_access_cpus - if host_machine.cpu_family() == cpu - ua_src = ''' + if host_machine.cpu_family() in unaligned_access_cpus + ua_src = ''' #if !defined(__ARM_FEATURE_UNALIGNED) \ && !defined(__riscv_misaligned_fast) \ && !defined(_MSC_VER) @@ -209,15 +205,13 @@ compile error #endif int main(void) { return 0; } ''' - if cc.compiles(ua_src, name: 'fast unaligned access for ' + cpu) - config_h.set10('TUKLIB_FAST_UNALIGNED_ACCESS', true, - description: 'Define to 1 if the system supports fast unaligned access to 16-bit, 32-bit, and 64-bit integers.' - ) - fast_unaligned_access = true - break - endif + if cc.compiles(ua_src, name: 'fast unaligned access for ' + host_machine.cpu_family()) + config_h.set10('TUKLIB_FAST_UNALIGNED_ACCESS', true, + description: 'Define to 1 if the system supports fast unaligned access to 16-bit, 32-bit, and 64-bit integers.' + ) + fast_unaligned_access = true endif - endforeach + endif endif elif get_option('unaligned-access').enabled() config_h.set10('TUKLIB_FAST_UNALIGNED_ACCESS', true, diff --git a/src/liblzma/meson.build b/src/liblzma/meson.build index d72b085df..71fb40136 100644 --- a/src/liblzma/meson.build +++ b/src/liblzma/meson.build @@ -273,7 +273,8 @@ if sys_windows liblzma_rc = win_mod.compile_resources(files('liblzma_w32res.rc'), args : [ '-DHAVE_CONFIG_H', '-DTUKLIB_SYMBOL_PREFIX=lzma_' ], depend_files : files('../common/common_w32res.rc'), - include_directories : [ '../src/common/', config_dir ]) + include_directories : [ '../src/common/', config_dir ] + ) lzma_src += [ liblzma_rc ] endif @@ -313,6 +314,8 @@ lzma_lib = library('lzma', lzma_src, version : meson.project_version(), ) +lzma_dep = declare_dependency(link_with: lzma_lib) + # pc file pkg_mod = import('pkgconfig') diff --git a/src/meson.build b/src/meson.build index 7b93d765a..ed97c2282 100644 --- a/src/meson.build +++ b/src/meson.build @@ -3,4 +3,4 @@ subdir('common') subdir('liblzma') -# subdir('xzdec') \ No newline at end of file +subdir('xzdec') diff --git a/src/xzdec/meson.build b/src/xzdec/meson.build new file mode 100644 index 000000000..292655253 --- /dev/null +++ b/src/xzdec/meson.build @@ -0,0 +1,89 @@ +## SPDX-License-Identifier: 0BSD +## Author: Vincent Torri + +if get_option('xzdec') + xzdec_src = [ + '../common/tuklib_exit.c', + '../common/tuklib_progname.c', + 'xzdec.c' + ] + + xzdec_cargs = [ + '-DHAVE_CONFIG_H', + '-DHAVE_STDBOOL_H', + '-DHAVE_INTTYPES_H', + '-DHAVE_STDINT_H', + '-DTUKLIB_GETTEXT=0' + ] + + xzdec_incdir = [ + '../common', + config_dir, + ] + + if sys_windows + xzdec_rc = win_mod.compile_resources(files('xzdec_w32res.rc'), + args : xzdec_cargs, + depend_files : files('../common/common_w32res.rc'), + include_directories : [ '../src/common/', config_dir ] + ) + xzdec_src += [ xzdec_rc ] + endif + + executable('xzdec', xzdec_src, + c_args: xzdec_cargs, + dependencies: lzma_dep, + include_directories : xzdec_incdir, + install: true, + ) + + install_man(files('xzdec.1')) +endif + +if get_option('lzmadec') + lzmadec_src = [ + '../common/tuklib_exit.c', + '../common/tuklib_progname.c', + 'xzdec.c' + ] + + lzmadec_cargs = [ + '-DHAVE_CONFIG_H', + '-DHAVE_STDBOOL_H', + '-DHAVE_INTTYPES_H', + '-DHAVE_STDINT_H', + '-DTUKLIB_GETTEXT=0' + ] + + lzmadec_incdir = [ + '../common', + config_dir, + ] + + if sys_windows + lzmadec_rc = win_mod.compile_resources(files('lzmadec_w32res.rc'), + args : [ xzdec_cargs, '-DLZMADEC' ], + depend_files : files('../common/common_w32res.rc'), + include_directories : [ '../src/common/', config_dir ] + ) + lzmadec_src += [ lzmadec_rc ] + endif + + executable('lzmadec', lzmadec_src, + c_args: lzmadec_cargs, + dependencies: lzma_dep, + include_directories : lzmadec_incdir, + install: true, + ) + + if get_option('xzdec') + install_symlink('lzmadec.1', + install_dir: get_option('datadir') / 'man' / 'man1', + pointing_to: 'xzdec.1', + ) + else + fs = import('fs') + fs.copyfile('xzdec.1', 'lzmadec.1') + install_man(files('lzmadec.1')) + endif +endif From 0f2859d48db619f6e9ccfad8bed7613394b02a82 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Thu, 16 May 2024 12:37:15 +0200 Subject: [PATCH 14/25] add xz tool + some fixes --- meson.build | 6 ++-- meson_options.txt | 4 +-- src/meson.build | 4 +++ src/xz/meson.build | 65 +++++++++++++++++++++++++++++++++++++++++++ src/xzdec/meson.build | 22 +++++++-------- 5 files changed, 86 insertions(+), 15 deletions(-) create mode 100644 src/xz/meson.build diff --git a/meson.build b/meson.build index 9fc80df9b..e4dee8a03 100644 --- a/meson.build +++ b/meson.build @@ -341,10 +341,12 @@ summary( }, section: 'Configuration Options Summary:', ) + summary( { - 'xzdec': get_option('xzdec'), - 'lzmadec': get_option('lzmadec'), + 'xzdec': get_option('xzdec').to_string('yes', 'no'), + 'lzmadec': get_option('lzmadec').to_string('yes', 'no'), + 'xz': get_option('xz').to_string('yes', 'no') + ((get_option('assume-ram') > 0) ? ' (' + get_option('assume-ram').to_string() + ' MiB)' : ''), }, section: 'Tools', ) diff --git a/meson_options.txt b/meson_options.txt index 4a18a095f..329b4638a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -4,7 +4,7 @@ # [ ] debug - not used : done by meson # [ ] arm64-crc32 # [X] assembler -# [ ] assume-ram +# [X] assume-ram # [X] checks # [ ] clmul-crc # [X] decoders @@ -45,7 +45,7 @@ option('assembler', option('assume-ram', type : 'integer', value : 128, - description : 'how much RAM to assume if the real amount is unknown' + description : 'how much RAM in MiB to assume if the real amount is unknown' ) option('checks', diff --git a/src/meson.build b/src/meson.build index ed97c2282..9b80f928d 100644 --- a/src/meson.build +++ b/src/meson.build @@ -4,3 +4,7 @@ subdir('common') subdir('liblzma') subdir('xzdec') + +if get_option('xz') + subdir('xz') +endif diff --git a/src/xz/meson.build b/src/xz/meson.build new file mode 100644 index 000000000..bbe7089a3 --- /dev/null +++ b/src/xz/meson.build @@ -0,0 +1,65 @@ +## SPDX-License-Identifier: 0BSD +## Author: Vincent Torri + +if get_option('assume-ram') <= 0 + error('option "assume-ram" accepts only positive integers') +endif + +config_h.set('ASSUME_RAM', get_option('assume-ram')) + +# FIXME -DLOCALEDIR=\"$(localedir)\" +xz_cargs = [ + '-DHAVE_CONFIG_H', + '-DHAVE_STDBOOL_H', + '-DHAVE_INTTYPES_H', + '-DHAVE_STDINT_H', +] + +xz_incdir = [ + '../common', + config_dir, +] + +xz_src = [ + 'args.c', + 'coder.c', + 'file_io.c', + 'hardware.c', + 'main.c', + 'message.c', + 'mytime.c', + 'options.c', + 'sandbox.c', + 'signals.c', + 'suffix.c', + 'util.c', + '../common/tuklib_open_stdxxx.c', + '../common/tuklib_progname.c', + '../common/tuklib_exit.c', + '../common/tuklib_mbstr_width.c', + '../common/tuklib_mbstr_fw.c', +] + +if get_option('decoders').length() > 0 + xz_src += [ + 'list.c' + ] +endif + +if sys_windows + xz_rc = win_mod.compile_resources(files('xz_w32res.rc'), + args : xz_cargs, + depend_files : files('../common/common_w32res.rc'), + include_directories : [ '../src/common/', config_dir ] + ) + xz_src += [ xz_rc ] +endif + +executable('xz', xz_src, + c_args: xz_cargs, + dependencies: lzma_dep, + include_directories : xz_incdir, + install: true, +) + +install_man(files('xz.1')) diff --git a/src/xzdec/meson.build b/src/xzdec/meson.build index 292655253..871041965 100644 --- a/src/xzdec/meson.build +++ b/src/xzdec/meson.build @@ -1,21 +1,21 @@ ## SPDX-License-Identifier: 0BSD ## Author: Vincent Torri -if get_option('xzdec') +xzdec_cargs = [ + '-DHAVE_CONFIG_H', + '-DHAVE_STDBOOL_H', + '-DHAVE_INTTYPES_H', + '-DHAVE_STDINT_H', + '-DTUKLIB_GETTEXT=0' +] + +if get_option('decoders').length() > 0 and get_option('xzdec') xzdec_src = [ '../common/tuklib_exit.c', '../common/tuklib_progname.c', 'xzdec.c' ] - xzdec_cargs = [ - '-DHAVE_CONFIG_H', - '-DHAVE_STDBOOL_H', - '-DHAVE_INTTYPES_H', - '-DHAVE_STDINT_H', - '-DTUKLIB_GETTEXT=0' - ] - xzdec_incdir = [ '../common', config_dir, @@ -40,7 +40,7 @@ if get_option('xzdec') install_man(files('xzdec.1')) endif -if get_option('lzmadec') +if 'lzma1' in get_option('decoders') and get_option('lzmadec') lzmadec_src = [ '../common/tuklib_exit.c', '../common/tuklib_progname.c', @@ -84,6 +84,6 @@ if get_option('lzmadec') else fs = import('fs') fs.copyfile('xzdec.1', 'lzmadec.1') - install_man(files('lzmadec.1')) + install_man('lzmadec.1') endif endif From 96e2d962ba531e7e2d4e953ed0bef12a8dbe7f45 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Fri, 17 May 2024 01:01:21 +0200 Subject: [PATCH 15/25] remove uint32_t check --- meson.build | 2 -- 1 file changed, 2 deletions(-) diff --git a/meson.build b/meson.build index e4dee8a03..7124980e6 100644 --- a/meson.build +++ b/meson.build @@ -132,8 +132,6 @@ if cc.compiles(ctor_fct_src, name : 'constructor attribute for functions') ) endif -cc.has_type('uint32_t', prefix: '#include ') - time_fcts = [ [ 'futimens', [ '#include ' ] ], [ 'futimes', [ '#include ' ] ], From f51a11f845a064f8410dd1cb3411dfd0344d0dad Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Fri, 17 May 2024 01:18:58 +0200 Subject: [PATCH 16/25] move C99 header macros to top level meson.build, unconditionally set macro for mbrtowc --- meson.build | 7 +++++++ src/common/meson.build | 9 --------- src/liblzma/meson.build | 3 --- src/xz/meson.build | 3 --- src/xzdec/meson.build | 6 ------ 5 files changed, 7 insertions(+), 21 deletions(-) diff --git a/meson.build b/meson.build index 7124980e6..797b65a8b 100644 --- a/meson.build +++ b/meson.build @@ -66,6 +66,13 @@ else add_project_arguments('-D_ALL_SOURCE', language: 'c') endif +# unconditionnally define macro for C99 headers +add_project_arguments('-DHAVE_INTTYPES_H', language: 'c') +add_project_arguments('-DHAVE_STDBOOL_H', language: 'c') +add_project_arguments('-DHAVE_STDINT_H', language: 'c') +# unconditionnally define macro for C99 functions +add_project_arguments('-DHAVE_MBRTOWC', language: 'c') + lzma_c_args = [] cflags_try = [] diff --git a/src/common/meson.build b/src/common/meson.build index ed3d3a756..ab1017e1a 100644 --- a/src/common/meson.build +++ b/src/common/meson.build @@ -230,15 +230,6 @@ endif ### FIXME : mbrtowc is supported in C99 spec and on Windows if cc.has_header('wchar.h') - config_h.set10('HAVE_WCHAR_H', true, - description: 'Define to 1 if the header file is available.' - ) - - if cc.has_type('mbstate_t', prefix : '#include ') and cc.has_function('mbrtowc', prefix : '#include ') - config_h.set10('HAVE_MBRTOWC', true, - description: 'Define to 1 if the mbrtowc() function is available.' - ) - endif if cc.has_function('wcwidth', args : '-D_XOPEN_SOURCE', diff --git a/src/liblzma/meson.build b/src/liblzma/meson.build index 71fb40136..d2d610a7c 100644 --- a/src/liblzma/meson.build +++ b/src/liblzma/meson.build @@ -280,9 +280,6 @@ endif lzma_c_args += [ '-DHAVE_CONFIG_H', - '-DHAVE_STDBOOL_H', - '-DHAVE_INTTYPES_H', - '-DHAVE_STDINT_H', ] lzma_incdir = [ diff --git a/src/xz/meson.build b/src/xz/meson.build index bbe7089a3..c99374cd9 100644 --- a/src/xz/meson.build +++ b/src/xz/meson.build @@ -10,9 +10,6 @@ config_h.set('ASSUME_RAM', get_option('assume-ram')) # FIXME -DLOCALEDIR=\"$(localedir)\" xz_cargs = [ '-DHAVE_CONFIG_H', - '-DHAVE_STDBOOL_H', - '-DHAVE_INTTYPES_H', - '-DHAVE_STDINT_H', ] xz_incdir = [ diff --git a/src/xzdec/meson.build b/src/xzdec/meson.build index 871041965..a10212345 100644 --- a/src/xzdec/meson.build +++ b/src/xzdec/meson.build @@ -3,9 +3,6 @@ xzdec_cargs = [ '-DHAVE_CONFIG_H', - '-DHAVE_STDBOOL_H', - '-DHAVE_INTTYPES_H', - '-DHAVE_STDINT_H', '-DTUKLIB_GETTEXT=0' ] @@ -49,9 +46,6 @@ if 'lzma1' in get_option('decoders') and get_option('lzmadec') lzmadec_cargs = [ '-DHAVE_CONFIG_H', - '-DHAVE_STDBOOL_H', - '-DHAVE_INTTYPES_H', - '-DHAVE_STDINT_H', '-DTUKLIB_GETTEXT=0' ] From be2a23a758e387583b8edf95443b33e18e6bc68f Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Fri, 17 May 2024 01:36:13 +0200 Subject: [PATCH 17/25] indent # --- meson.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 797b65a8b..e3a844dd9 100644 --- a/meson.build +++ b/meson.build @@ -66,11 +66,11 @@ else add_project_arguments('-D_ALL_SOURCE', language: 'c') endif -# unconditionnally define macro for C99 headers +# unconditionally define macro for C99 headers add_project_arguments('-DHAVE_INTTYPES_H', language: 'c') add_project_arguments('-DHAVE_STDBOOL_H', language: 'c') add_project_arguments('-DHAVE_STDINT_H', language: 'c') -# unconditionnally define macro for C99 functions +# unconditionally define macro for C99 functions add_project_arguments('-DHAVE_MBRTOWC', language: 'c') lzma_c_args = [] @@ -102,7 +102,7 @@ if cc.get_argument_syntax() == 'gcc' '-Wmissing-prototypes', '-Wmissing-declarations', '-Wredundant-decls', -# + # '-Wc99-compat', '-Wc11-extensions', '-Wc2x-compat', From 8a7b9b11de71c9b0511a4a70d44fe18c1dd7e6fd Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Fri, 17 May 2024 01:43:30 +0200 Subject: [PATCH 18/25] fix description of 'unsafe-type-punning' option --- meson_options.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson_options.txt b/meson_options.txt index 329b4638a..612d701e5 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -172,7 +172,7 @@ option( option('unsafe-type-punning', type : 'boolean', value : false, - description : 'use ARM64 CRC32 instructions' + description : 'use unsafe type punning' ) option('xz', From a83a638d7a129a69f54e5c9a0b86eee96dfaaa56 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Fri, 17 May 2024 01:52:35 +0200 Subject: [PATCH 19/25] use cc.has_function_attribute instead of compile C code --- meson.build | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index e3a844dd9..69b45d93e 100644 --- a/meson.build +++ b/meson.build @@ -128,13 +128,8 @@ config_h.set10('HAVE_VISIBILITY', cc.has_function_attribute('visibility'), description: 'Define to 1 if the compiler supports simple visibility declarations.' ) -ctor_fct_src = ''' -__attribute__((__constructor__)) -static void my_constructor_func(void) { return; } -int main() { return 0; } -''' -if cc.compiles(ctor_fct_src, name : 'constructor attribute for functions') - config_h.set10('HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR', true, +if cc.has_function_attribute('constructor') + config_h.set('HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR', 1, description: 'Define to 1 if __attribute__((__constructor__)) is supported for functions.' ) endif From 859f82121228739c160559befe1b00c0e649893e Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Sat, 18 May 2024 07:19:30 +0200 Subject: [PATCH 20/25] use .set() method instead of .set10(), except for visibility macro --- meson.build | 94 +++++++++++++++++++++++------------------- src/common/meson.build | 49 +++++++++++----------- 2 files changed, 75 insertions(+), 68 deletions(-) diff --git a/meson.build b/meson.build index 69b45d93e..0e28f32fd 100644 --- a/meson.build +++ b/meson.build @@ -36,7 +36,8 @@ config_h.set_quoted('PACKAGE_URL', 'https://tukaani.org/xz/') # host -config_h.set10('WORDS_BIGENDIAN', host_machine.endian() == 'big', +config_h.set('WORDS_BIGENDIAN', + host_machine.endian() == 'big', description: 'Define to 1 if the processor stores words with the most significant byte first.' ) @@ -124,15 +125,16 @@ if cc.get_argument_syntax() == 'gcc' lzma_c_args += cc.get_supported_arguments(cflags_try) endif -config_h.set10('HAVE_VISIBILITY', cc.has_function_attribute('visibility'), +config_h.set10('HAVE_VISIBILITY', + cc.has_function_attribute('visibility'), description: 'Define to 1 if the compiler supports simple visibility declarations.' ) -if cc.has_function_attribute('constructor') - config_h.set('HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR', 1, - description: 'Define to 1 if __attribute__((__constructor__)) is supported for functions.' - ) -endif + +config_h.set('HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR', + cc.has_function_attribute('constructor'), + description: 'Define to 1 if __attribute__((__constructor__)) is supported for functions.', +) time_fcts = [ [ 'futimens', [ '#include ' ] ], @@ -143,19 +145,20 @@ time_fcts = [ [ 'utime', [ '#include ', '#include ' ] ], ] foreach f : time_fcts - if cc.has_function(f[0], prefix : f[1]) - config_h.set10('HAVE_' + f[0].to_upper(), true, - description: 'Define to 1 if the ' + f[0] + '() function is available.' - ) + res = cc.has_function(f[0], prefix : f[1]) + config_h.set('HAVE_' + f[0].to_upper(), + res, + description: 'Define to 1 if the ' + f[0] + '() function is available.' + ) + if res break endif endforeach -if cc.has_function('posix_fadvise', prefix : '#include ') - config_h.set10('HAVE_POSIX_FADVISE', true, - description: 'Define to 1 if the posix_fadvise() function is available.' - ) -endif +config_h.set('HAVE_POSIX_FADVISE', + cc.has_function('posix_fadvise', prefix : '#include '), + description: 'Define to 1 if the posix_fadvise() function is available.' +) ### Filters @@ -177,14 +180,16 @@ simple_filters = [ # FIXME foreach i in array; set_variable(f'have_@i@', true) endforeach foreach f : get_option('encoders') - config_h.set10('HAVE_ENCODER_' + f.underscorify().to_upper(), true, + config_h.set('HAVE_ENCODER_' + f.underscorify().to_upper(), + true, description: 'Define to 1 if ' + f + ' encoder is enabled.' ) encoder_msg += f + ' ' endforeach foreach f : get_option('decoders') - config_h.set10('HAVE_DECODER_' + f.underscorify().to_upper(), true, + config_h.set('HAVE_DECODER_' + f.underscorify().to_upper(), + true, description: 'Define to 1 if ' + f + ' decoder is enabled.' ) decoder_msg += f + ' ' @@ -206,13 +211,15 @@ if ('lzma2' in get_option('encoders') and not ('lzma1' in get_option('encoders') endif if get_option('encoders').length() > 0 - config_h.set10('HAVE_ENCODERS', true, + config_h.set('HAVE_ENCODERS', + true, description: 'Define to 1 if at least one encoder has been enabled.' ) endif if get_option('decoders').length() > 0 - config_h.set10('HAVE_DECODERS', true, + config_h.set('HAVE_DECODERS', + true, description: 'Define to 1 if at least one decoder has been enabled.' ) endif @@ -227,7 +234,8 @@ if 'lzma1' in get_option('encoders') or 'lzma2' in get_option('encoders') endif foreach m : get_option('match-finders') - config_h.set10('HAVE_MF_' + m.underscorify().to_upper(), true, + config_h.set('HAVE_MF_' + m.underscorify().to_upper(), + true, description: 'Define to 1 to enable ' + m + ' match finder.' ) match_finder_msg += m + ' ' @@ -243,7 +251,8 @@ if not ('crc32' in get_option('checks')) endif foreach c : get_option('checks') - config_h.set10('HAVE_CHECK_' + c.underscorify().to_upper(), true, + config_h.set('HAVE_CHECK_' + c.underscorify().to_upper(), + true, description: 'Define to 1 if ' + c + ' integrity check is enabled.' ) check_msg += c + ' ' @@ -262,7 +271,8 @@ if not ('lzma1' in get_option('encoders')) elif get_option('lzip-decoder') lzip_msg = 'yes' have_lzip = true - config_h.set10('HAVE_LZIP_DECODER', true, + config_h.set('HAVE_LZIP_DECODER', + true, description: 'Define to 1 if .lz (lzip) decompression support is enabled.' ) else @@ -280,11 +290,10 @@ endif ### size optimization -if get_option('small') - config_h.set10('HAVE_SMALL', true, - description: 'Define to 1 if optimizing for size.' - ) -endif +config_h.set('HAVE_SMALL', + get_option('small'), + description: 'Define to 1 if optimizing for size.' +) ### threading @@ -292,24 +301,23 @@ have_threads = false if get_option('threads') == true if sys_windows == true - if host_machine.cpu_family() == 'x86' - config_h.set10('MYTHREAD_WIN95', true, - description: 'Define to 1 when using Windows 95 (and thus XP) compatible threads. This avoids use of features that were added in Windows Vista.' - ) - else - config_h.set10('MYTHREAD_VISTA', true, - description: 'Define to 1 when using Windows Vista compatible threads. This uses features that are not available on Windows XP.' - ) - endif + config_h.set('MYTHREAD_WIN95', + host_machine.cpu_family() == 'x86', + description: 'Define to 1 when using Windows 95 (and thus XP) compatible threads. This avoids use of features that were added in Windows Vista.' + ) + config_h.set('MYTHREAD_VISTA', + host_machine.cpu_family() != 'x86', + description: 'Define to 1 when using Windows Vista compatible threads. This uses features that are not available on Windows XP.' + ) have_threads = true else + # FIXME: pthread detection should be fixed pthread_dep = dependency('threads', required : false) - if pthread_dep.found() - config_h.set10('MYTHREAD_POSIX', true, - description: 'Define to 1 when using POSIX threads (pthreads).' - ) - have_threads = true - endif + config_h.set('MYTHREAD_POSIX', + pthread_dep.found(), + description: 'Define to 1 when using POSIX threads (pthreads).' + ) + have_threads = pthread_dep.found() endif endif diff --git a/src/common/meson.build b/src/common/meson.build index ab1017e1a..dfca62d56 100644 --- a/src/common/meson.build +++ b/src/common/meson.build @@ -107,15 +107,15 @@ main(void) if cc.compiles(cpu_special_src, name : 'number of cpu cores on Windows or Cygwin') # nothing to do, here elif cc.compiles(cpu_sched_getaffinity_src, name : 'number of cpu cores with sched_getaffinity()') - config_h.set10('TUKLIB_CPUCORES_SCHED_GETAFFINITY', true) + config_h.set('TUKLIB_CPUCORES_SCHED_GETAFFINITY', true) elif cc.compiles(cpu_cpuset_src, name : 'number of cpu cores with cpuset()') - config_h.set10('TUKLIB_CPUCORES_CPUSET', true) + config_h.set('TUKLIB_CPUCORES_CPUSET', true) elif cc.compiles(cpu_sysctl_src, args : have_sys_param_h ? '-DHAVE_SYS_PARAM_H' : '', name : 'number of cpu cores with sysctl()') - config_h.set10('TUKLIB_CPUCORES_SYSCTL', true) + config_h.set('TUKLIB_CPUCORES_SYSCTL', true) elif cc.compiles(cpu_sysconf_src, name : 'number of cpu cores with sysconf()') - config_h.set10('TUKLIB_CPUCORES_SYSCONF', true) + config_h.set('TUKLIB_CPUCORES_SYSCONF', true) elif cc.compiles(cpu_pstat_getdynamic_src, name : 'number of cpu cores with pstat_getdynamic()') - config_h.set10('TUKLIB_CPUCORES_PSTAT_GETDYNAMIC', true) + config_h.set('TUKLIB_CPUCORES_PSTAT_GETDYNAMIC', true) endif # tuklib_integer.m4 @@ -131,7 +131,7 @@ int main() ''' res = cc.links(bswap_src, name: '__builtin_bswap16/32/64') if res - config_h.set10('HAVE___BUILTIN_BSWAPXX', true, + config_h.set('HAVE___BUILTIN_BSWAPXX', true, description: 'Define to 1 if the GNU C extensions __builtin_bswap16/32/64 are supported.' ) else @@ -145,7 +145,7 @@ else ] foreach h : bswap_headers if cc.has_header(h) - config_h.set10('HAVE_' + h.underscorify().to_upper(), true) + config_h.set('HAVE_' + h.underscorify().to_upper(), true) set_variable(f'have_' + h.underscorify(), true) endif endforeach @@ -165,11 +165,10 @@ int main() return 0; } ''' - if cc.links(bswap_src.format(f), name: f) - config_h.set10('HAVE_' + f.to_upper(), true, - description: 'Define to 1 if ' + f + '() is available.' - ) - endif + config_h.set('HAVE_' + f.to_upper(), + cc.links(bswap_src.format(f), name: f), + description: 'Define to 1 if ' + f + '() is available.' + ) endforeach endif endif @@ -183,7 +182,7 @@ if get_option('unaligned-access').auto() 'x86_64', ] if host_machine.cpu_family() in unaligned_access_cpus - config_h.set10('TUKLIB_FAST_UNALIGNED_ACCESS', true, + config_h.set('TUKLIB_FAST_UNALIGNED_ACCESS', true, description: 'Define to 1 if the system supports fast unaligned access to 16-bit, 32-bit, and 64-bit integers.' ) fast_unaligned_access = true @@ -206,7 +205,7 @@ compile error int main(void) { return 0; } ''' if cc.compiles(ua_src, name: 'fast unaligned access for ' + host_machine.cpu_family()) - config_h.set10('TUKLIB_FAST_UNALIGNED_ACCESS', true, + config_h.set('TUKLIB_FAST_UNALIGNED_ACCESS', true, description: 'Define to 1 if the system supports fast unaligned access to 16-bit, 32-bit, and 64-bit integers.' ) fast_unaligned_access = true @@ -214,14 +213,14 @@ int main(void) { return 0; } endif endif elif get_option('unaligned-access').enabled() - config_h.set10('TUKLIB_FAST_UNALIGNED_ACCESS', true, + config_h.set0('TUKLIB_FAST_UNALIGNED_ACCESS', true, description: 'Define to 1 if the system supports fast unaligned access to 16-bit, 32-bit, and 64-bit integers.' ) fast_unaligned_access = true endif if get_option('unsafe-type-punning') - config_h.set10('HAVE___BUILTIN_ASSUME_ALIGNED', true, + config_h.set('HAVE___BUILTIN_ASSUME_ALIGNED', true, description: 'Define to 1 if the GNU C extension __builtin_assume_aligned is supported.' ) endif @@ -235,7 +234,7 @@ if cc.has_header('wchar.h') args : '-D_XOPEN_SOURCE', prefix : '#include ' ) - config_h.set10('HAVE_WCWIDTH', true, + config_h.set('HAVE_WCWIDTH', true, description: 'Define to 1 if the wcwidth() function is available.' ) endif @@ -349,19 +348,19 @@ main(void) if cc.compiles(physmem_special_src, name : 'physical memory on some special OSes') # nothing to do, here elif cc.compiles(physmem_aix_src, name : 'physical memory on AIX') - config_h.set10('TUKLIB_PHYSMEM_AIX', true) + config_h.set('TUKLIB_PHYSMEM_AIX', true) elif cc.compiles(physmem_sysconf_src, name : 'physical memory with sysconf()') - config_h.set10('TUKLIB_PHYSMEM_SYSCONF', true) + config_h.set('TUKLIB_PHYSMEM_SYSCONF', true) elif cc.compiles(physmem_sysctl_src, args : have_sys_param_h ? '-DHAVE_SYS_PARAM_H' : '', name : 'physical memory with sysctl()') - config_h.set10('TUKLIB_PHYSMEM_SYSCTL', true) + config_h.set('TUKLIB_PHYSMEM_SYSCTL', true) elif cc.compiles(physmem_getsysinfo_src, name : 'physical memory with getsysinfo()') - config_h.set10('TUKLIB_PHYSMEM_GETSYSINFO', true) + config_h.set('TUKLIB_PHYSMEM_GETSYSINFO', true) elif cc.compiles(physmem_pstat_getstatic_src, name : 'physical memory with pstat_getstatic()') - config_h.set10('TUKLIB_PHYSMEM_PSTAT_GETSTATIC', true) + config_h.set('TUKLIB_PHYSMEM_PSTAT_GETSTATIC', true) elif cc.compiles(physmem_getinvent_r_src, name : 'physical memory with getinvent_r()') - config_h.set10('TUKLIB_PHYSMEM_GETINVENT_R', true) + config_h.set('TUKLIB_PHYSMEM_GETINVENT_R', true) elif cc.compiles(physmem_sysinfo_src, name : 'physical memory with sysinfo()') - config_h.set10('TUKLIB_PHYSMEM_SYSINFO', true) + config_h.set('TUKLIB_PHYSMEM_SYSINFO', true) endif # tuklib_progname.m4 @@ -369,7 +368,7 @@ endif if cc.has_function('program_invocation_name', prefix : '#include ' ) - config_h.set10('HAVE_PROGRAM_INVOCATION_NAME', true, + config_h.set('HAVE_PROGRAM_INVOCATION_NAME', true, description: 'Define to 1 if the program_invocation_name() function is available.' ) endif From fb6b458e9ed311ed1728de3b4c4617fd8d5861d3 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Sat, 18 May 2024 17:57:41 +0200 Subject: [PATCH 21/25] change description of macro, define _GNU_SOURCE and __EXTENSIONS__ unconditionally --- meson.build | 37 ++++++++++++++++++------------------- src/common/meson.build | 30 ++++++++++++------------------ 2 files changed, 30 insertions(+), 37 deletions(-) diff --git a/meson.build b/meson.build index 0e28f32fd..fb2ca34e7 100644 --- a/meson.build +++ b/meson.build @@ -38,7 +38,7 @@ config_h.set_quoted('PACKAGE_URL', 'https://tukaani.org/xz/') config_h.set('WORDS_BIGENDIAN', host_machine.endian() == 'big', - description: 'Define to 1 if the processor stores words with the most significant byte first.' + description: 'Defined if the processor stores words with the most significant byte first.' ) host_os = host_machine.system() @@ -57,10 +57,9 @@ COND_W32 = sys_cygwin or sys_windows cc = meson.get_compiler('c') # try mimic AC_USE_SYSTEM_EXTENSIONS -if host_machine.system() == 'linux' - add_project_arguments('-D_GNU_SOURCE', language: 'c') -elif host_machine.system() == 'sunos' - add_project_arguments('-D__EXTENSIONS__', language: 'c') +add_project_arguments('-D_GNU_SOURCE', language: 'c') +add_project_arguments('-D__EXTENSIONS__', language: 'c') +if host_machine.system() == 'sunos' add_project_arguments('-D_POSIX_PTHREAD_SEMANTICS', language: 'c') else add_project_arguments('-D_TANDEM_SOURCE', language: 'c') @@ -127,13 +126,13 @@ endif config_h.set10('HAVE_VISIBILITY', cc.has_function_attribute('visibility'), - description: 'Define to 1 if the compiler supports simple visibility declarations.' + description: 'Defined to 1 if the compiler supports simple visibility declarations.' ) config_h.set('HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR', cc.has_function_attribute('constructor'), - description: 'Define to 1 if __attribute__((__constructor__)) is supported for functions.', + description: 'Defined if __attribute__((__constructor__)) is supported for functions.', ) time_fcts = [ @@ -148,7 +147,7 @@ foreach f : time_fcts res = cc.has_function(f[0], prefix : f[1]) config_h.set('HAVE_' + f[0].to_upper(), res, - description: 'Define to 1 if the ' + f[0] + '() function is available.' + description: 'Defined if the ' + f[0] + '() function is available.' ) if res break @@ -157,7 +156,7 @@ endforeach config_h.set('HAVE_POSIX_FADVISE', cc.has_function('posix_fadvise', prefix : '#include '), - description: 'Define to 1 if the posix_fadvise() function is available.' + description: 'Defined if the posix_fadvise() function is available.' ) ### Filters @@ -182,7 +181,7 @@ simple_filters = [ foreach f : get_option('encoders') config_h.set('HAVE_ENCODER_' + f.underscorify().to_upper(), true, - description: 'Define to 1 if ' + f + ' encoder is enabled.' + description: 'Defined if ' + f + ' encoder is enabled.' ) encoder_msg += f + ' ' endforeach @@ -190,7 +189,7 @@ endforeach foreach f : get_option('decoders') config_h.set('HAVE_DECODER_' + f.underscorify().to_upper(), true, - description: 'Define to 1 if ' + f + ' decoder is enabled.' + description: 'Defined if ' + f + ' decoder is enabled.' ) decoder_msg += f + ' ' endforeach @@ -213,14 +212,14 @@ endif if get_option('encoders').length() > 0 config_h.set('HAVE_ENCODERS', true, - description: 'Define to 1 if at least one encoder has been enabled.' + description: 'Defined if at least one encoder has been enabled.' ) endif if get_option('decoders').length() > 0 config_h.set('HAVE_DECODERS', true, - description: 'Define to 1 if at least one decoder has been enabled.' + description: 'Defined if at least one decoder has been enabled.' ) endif @@ -236,7 +235,7 @@ if 'lzma1' in get_option('encoders') or 'lzma2' in get_option('encoders') foreach m : get_option('match-finders') config_h.set('HAVE_MF_' + m.underscorify().to_upper(), true, - description: 'Define to 1 to enable ' + m + ' match finder.' + description: 'Defined to enable ' + m + ' match finder.' ) match_finder_msg += m + ' ' endforeach @@ -273,7 +272,7 @@ elif get_option('lzip-decoder') have_lzip = true config_h.set('HAVE_LZIP_DECODER', true, - description: 'Define to 1 if .lz (lzip) decompression support is enabled.' + description: 'Defined if .lz (lzip) decompression support is enabled.' ) else lzip_msg = 'no' @@ -292,7 +291,7 @@ endif config_h.set('HAVE_SMALL', get_option('small'), - description: 'Define to 1 if optimizing for size.' + description: 'Defined if optimizing for size.' ) ### threading @@ -303,11 +302,11 @@ if get_option('threads') == true if sys_windows == true config_h.set('MYTHREAD_WIN95', host_machine.cpu_family() == 'x86', - description: 'Define to 1 when using Windows 95 (and thus XP) compatible threads. This avoids use of features that were added in Windows Vista.' + description: 'Defined when using Windows 95 (and thus XP) compatible threads. This avoids use of features that were added in Windows Vista.' ) config_h.set('MYTHREAD_VISTA', host_machine.cpu_family() != 'x86', - description: 'Define to 1 when using Windows Vista compatible threads. This uses features that are not available on Windows XP.' + description: 'Defined when using Windows Vista compatible threads. This uses features that are not available on Windows XP.' ) have_threads = true else @@ -315,7 +314,7 @@ if get_option('threads') == true pthread_dep = dependency('threads', required : false) config_h.set('MYTHREAD_POSIX', pthread_dep.found(), - description: 'Define to 1 when using POSIX threads (pthreads).' + description: 'Defined when using POSIX threads (pthreads).' ) have_threads = pthread_dep.found() endif diff --git a/src/common/meson.build b/src/common/meson.build index dfca62d56..ef0063556 100644 --- a/src/common/meson.build +++ b/src/common/meson.build @@ -132,7 +132,7 @@ int main() res = cc.links(bswap_src, name: '__builtin_bswap16/32/64') if res config_h.set('HAVE___BUILTIN_BSWAPXX', true, - description: 'Define to 1 if the GNU C extensions __builtin_bswap16/32/64 are supported.' + description: 'Defined if the GNU C extensions __builtin_bswap16/32/64 are supported.' ) else have_byteswap_h = false @@ -167,7 +167,7 @@ int main() ''' config_h.set('HAVE_' + f.to_upper(), cc.links(bswap_src.format(f), name: f), - description: 'Define to 1 if ' + f + '() is available.' + description: 'Defined if ' + f + '() is available.' ) endforeach endif @@ -183,7 +183,7 @@ if get_option('unaligned-access').auto() ] if host_machine.cpu_family() in unaligned_access_cpus config_h.set('TUKLIB_FAST_UNALIGNED_ACCESS', true, - description: 'Define to 1 if the system supports fast unaligned access to 16-bit, 32-bit, and 64-bit integers.' + description: 'Defined if the system supports fast unaligned access to 16-bit, 32-bit, and 64-bit integers.' ) fast_unaligned_access = true endif @@ -206,38 +206,32 @@ int main(void) { return 0; } ''' if cc.compiles(ua_src, name: 'fast unaligned access for ' + host_machine.cpu_family()) config_h.set('TUKLIB_FAST_UNALIGNED_ACCESS', true, - description: 'Define to 1 if the system supports fast unaligned access to 16-bit, 32-bit, and 64-bit integers.' + description: 'Defined if the system supports fast unaligned access to 16-bit, 32-bit, and 64-bit integers.' ) fast_unaligned_access = true endif endif endif elif get_option('unaligned-access').enabled() - config_h.set0('TUKLIB_FAST_UNALIGNED_ACCESS', true, - description: 'Define to 1 if the system supports fast unaligned access to 16-bit, 32-bit, and 64-bit integers.' + config_h.set('TUKLIB_FAST_UNALIGNED_ACCESS', true, + description: 'Defined if the system supports fast unaligned access to 16-bit, 32-bit, and 64-bit integers.' ) fast_unaligned_access = true endif if get_option('unsafe-type-punning') config_h.set('HAVE___BUILTIN_ASSUME_ALIGNED', true, - description: 'Define to 1 if the GNU C extension __builtin_assume_aligned is supported.' + description: 'Defined if the GNU C extension __builtin_assume_aligned is supported.' ) endif # tuklib_mbstr.m4 -### FIXME : mbrtowc is supported in C99 spec and on Windows if cc.has_header('wchar.h') - - if cc.has_function('wcwidth', - args : '-D_XOPEN_SOURCE', - prefix : '#include ' - ) - config_h.set('HAVE_WCWIDTH', true, - description: 'Define to 1 if the wcwidth() function is available.' - ) - endif + config_h.set('HAVE_WCWIDTH', + cc.has_function('wcwidth', prefix : '#include '), + description: 'Defined if the wcwidth() function is available.' + ) endif # tuklib_physmem.m4 @@ -369,6 +363,6 @@ if cc.has_function('program_invocation_name', prefix : '#include ' ) config_h.set('HAVE_PROGRAM_INVOCATION_NAME', true, - description: 'Define to 1 if the program_invocation_name() function is available.' + description: 'Defined if the program_invocation_name() function is available.' ) endif From 24ad34ea97e4588e482225a45e7e1509a546a420 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Sat, 18 May 2024 19:41:56 +0200 Subject: [PATCH 22/25] remove check of wchar.h for wcwidth() --- src/common/meson.build | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/common/meson.build b/src/common/meson.build index ef0063556..65af14a5c 100644 --- a/src/common/meson.build +++ b/src/common/meson.build @@ -227,12 +227,10 @@ endif # tuklib_mbstr.m4 -if cc.has_header('wchar.h') - config_h.set('HAVE_WCWIDTH', - cc.has_function('wcwidth', prefix : '#include '), - description: 'Defined if the wcwidth() function is available.' - ) -endif +config_h.set('HAVE_WCWIDTH', + cc.has_function('wcwidth', prefix : '#include '), + description: 'Defined if the wcwidth() function is available.' +) # tuklib_physmem.m4 From efcb02e6fa110cbadac1b1a84fd2ba3674983142 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Sat, 18 May 2024 19:47:47 +0200 Subject: [PATCH 23/25] remove double # at the top of meson.build files --- meson.build | 4 ++-- meson_options.txt | 4 ++-- src/liblzma/meson.build | 4 ++-- src/meson.build | 4 ++-- src/xz/meson.build | 4 ++-- src/xzdec/meson.build | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/meson.build b/meson.build index fb2ca34e7..64dbf562e 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ -## SPDX-License-Identifier: 0BSD -## Author: Vincent Torri +# SPDX-License-Identifier: 0BSD +# Author: Vincent Torri project( 'xz', diff --git a/meson_options.txt b/meson_options.txt index 612d701e5..e8c5af33c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,5 +1,5 @@ -## SPDX-License-Identifier: 0BSD -## Author: Vincent Torri +# SPDX-License-Identifier: 0BSD +# Author: Vincent Torri # [ ] debug - not used : done by meson # [ ] arm64-crc32 diff --git a/src/liblzma/meson.build b/src/liblzma/meson.build index d2d610a7c..f8865044a 100644 --- a/src/liblzma/meson.build +++ b/src/liblzma/meson.build @@ -1,5 +1,5 @@ -## SPDX-License-Identifier: 0BSD -## Author: Vincent Torri +# SPDX-License-Identifier: 0BSD +# Author: Vincent Torri lzma_src = [ '../common/tuklib_physmem.c', diff --git a/src/meson.build b/src/meson.build index 9b80f928d..1a637bdae 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,5 +1,5 @@ -## SPDX-License-Identifier: 0BSD -## Author: Vincent Torri +# SPDX-License-Identifier: 0BSD +# Author: Vincent Torri subdir('common') subdir('liblzma') diff --git a/src/xz/meson.build b/src/xz/meson.build index c99374cd9..6ee0c20a3 100644 --- a/src/xz/meson.build +++ b/src/xz/meson.build @@ -1,5 +1,5 @@ -## SPDX-License-Identifier: 0BSD -## Author: Vincent Torri +# SPDX-License-Identifier: 0BSD +# Author: Vincent Torri if get_option('assume-ram') <= 0 error('option "assume-ram" accepts only positive integers') diff --git a/src/xzdec/meson.build b/src/xzdec/meson.build index a10212345..94c847617 100644 --- a/src/xzdec/meson.build +++ b/src/xzdec/meson.build @@ -1,5 +1,5 @@ -## SPDX-License-Identifier: 0BSD -## Author: Vincent Torri +# SPDX-License-Identifier: 0BSD +# Author: Vincent Torri xzdec_cargs = [ '-DHAVE_CONFIG_H', From d45e486bdd311b8a9d8ada059c4400199af092b0 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Wed, 22 May 2024 22:40:24 +0200 Subject: [PATCH 24/25] add lzmainfo and scripts, plus some fixes --- meson.build | 2 ++ meson_options.txt | 6 ++-- src/common/meson.build | 1 + src/lzmainfo/meson.build | 35 ++++++++++++++++++++++ src/meson.build | 8 +++++ src/scripts/meson.build | 64 ++++++++++++++++++++++++++++++++++++++++ src/xz/meson.build | 21 +++++++++++++ 7 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 src/lzmainfo/meson.build create mode 100644 src/scripts/meson.build diff --git a/meson.build b/meson.build index 64dbf562e..de8d9f00f 100644 --- a/meson.build +++ b/meson.build @@ -50,6 +50,7 @@ sunos = 'sunos' asm_os = [ 'linux', 'dragonfly', 'freebsd', 'netbsd', 'openbsd', 'windows', 'cygwin' ] sys_cygwin = cygwin.contains(host_os) sys_windows = windows.contains(host_os) +sys_sunos = sunos.contains(host_os) COND_W32 = sys_cygwin or sys_windows @@ -143,6 +144,7 @@ time_fcts = [ [ '_futime', [ '#include ' ] ], [ 'utime', [ '#include ', '#include ' ] ], ] + foreach f : time_fcts res = cc.has_function(f[0], prefix : f[1]) config_h.set('HAVE_' + f[0].to_upper(), diff --git a/meson_options.txt b/meson_options.txt index e8c5af33c..26aea208d 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -14,11 +14,11 @@ # [X] external-sha256 # [X] lzip-decoder # [X] lzmadec -# [ ] lzmainfo +# [X] lzmainfo # [ ] lzma-links # [X] match-finders # [X] microlzma -# [ ] path-for-scripts +# [X] path-for-scripts # [ ] sandbox # [X] small # [ ] symbol-versions @@ -27,7 +27,7 @@ # [X] unaligned-access # [X] unsafe-type-punning # [ ] werror - not used : done by meson -# [ ] xz +# [X] xz # [X] xzdec option('arm64-crc32', diff --git a/src/common/meson.build b/src/common/meson.build index 65af14a5c..f78d68d2b 100644 --- a/src/common/meson.build +++ b/src/common/meson.build @@ -358,6 +358,7 @@ endif # tuklib_progname.m4 if cc.has_function('program_invocation_name', + args : '-D_GNU_SOURCE', prefix : '#include ' ) config_h.set('HAVE_PROGRAM_INVOCATION_NAME', true, diff --git a/src/lzmainfo/meson.build b/src/lzmainfo/meson.build new file mode 100644 index 000000000..7e7f4b0b1 --- /dev/null +++ b/src/lzmainfo/meson.build @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: 0BSD +# Author: Vincent Torri + +lzmainfo_cargs = [ + '-DHAVE_CONFIG_H', +] + +lzmainfo_incdir = [ + '../common', + config_dir, +] + +lzmainfo_src = [ + 'lzmainfo.c', + '../common/tuklib_progname.c', + '../common/tuklib_exit.c', +] + +if sys_windows + lzmainfo_rc = win_mod.compile_resources(files('lzmainfo_w32res.rc'), + args : lzmainfo_cargs, + depend_files : files('../common/common_w32res.rc'), + include_directories : [ '../src/common/', config_dir ] + ) + lzmainfo_src += [ lzmainfo_rc ] +endif + +executable('lzmainfo', lzmainfo_src, + c_args: lzmainfo_cargs, + dependencies: lzma_dep, + include_directories : lzmainfo_incdir, + install: true, +) + +install_man(files('lzmainfo.1')) diff --git a/src/meson.build b/src/meson.build index 1a637bdae..b7a3017ee 100644 --- a/src/meson.build +++ b/src/meson.build @@ -8,3 +8,11 @@ subdir('xzdec') if get_option('xz') subdir('xz') endif + +if 'lzma1' in get_option('decoders') and get_option('lzmainfo') + subdir('lzmainfo') +endif + +if get_option('scripts') + subdir('scripts') +endif \ No newline at end of file diff --git a/src/scripts/meson.build b/src/scripts/meson.build new file mode 100644 index 000000000..3e1c4419d --- /dev/null +++ b/src/scripts/meson.build @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: 0BSD +# Author: Vincent Torri + +path_for_script = '' +if get_option('path-for-scripts') == '' + if sys_sunos + path_for_script = '/usr/xpg4/bin' + endif +else + path_for_script = 'PATH=' + get_option('path-for-scripts') + ':$PATH' +endif + +# As discussed on IRC, @xz@ is transformed to 'xz' + +scriptconf = configuration_data() + +scriptconf.set('PACKAGE_NAME', meson.project_name()) +scriptconf.set('PACKAGE_VERSION', meson.project_version()) +scriptconf.set('PACKAGE_BUGREPORT', meson.project_version()) +scriptconf.set('enable_path_for_scripts', path_for_script) +scriptconf.set('xz', 'xz') + +scripts = [ + 'xzdiff', + 'xzgrep', + 'xzmore', + 'xzless', +] + +foreach s : scripts + configure_file( + input : s + '.in', + output : s, + configuration : scriptconf, + install_dir : get_option('bindir') + ) +endforeach + +links = [ + [ 'xzdiff', 'xzcmp' ], + [ 'xzgrep', 'xzegrep' ], + [ 'xzgrep', 'xzfgrep' ], +] + +if get_option('lzma-links') + links += [ + [ 'xzdiff', 'lzdiff' ], + [ 'xzdiff', 'lzcmp' ], + [ 'xzgrep', 'lzgrep' ], + [ 'xzgrep', 'lzegrep' ], + [ 'xzgrep', 'lzfgrep' ], + [ 'xzmore', 'lzmore' ], + [ 'xzless', 'lzless' ], + ] +endif + +foreach l : links + install_symlink(l[1], + install_dir: get_option('bindir'), + pointing_to: l[0], + ) +endforeach + +install_man(files([ 'xzdiff.1', 'xzgrep.1', 'xzless.1', 'xzmore.1' ])) diff --git a/src/xz/meson.build b/src/xz/meson.build index 6ee0c20a3..a3cc2c021 100644 --- a/src/xz/meson.build +++ b/src/xz/meson.build @@ -60,3 +60,24 @@ executable('xz', xz_src, ) install_man(files('xz.1')) + +xz_links = [ + 'unxz', + 'xzcat', +] + +if get_option('lzma-links') + xz_links += [ + 'lzma', + 'unlzma', + 'lzcat', + ] +endif + + +foreach l : xz_links + install_symlink(l + (sys_windows ? '.exe' : ''), + install_dir: get_option('bindir'), + pointing_to: 'xz' + (sys_windows ? '.exe' : ''), + ) +endforeach From 7105a71ccb4fb5643ab647b6b75066a3d78e777b Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Thu, 30 May 2024 12:06:44 +0200 Subject: [PATCH 25/25] add C tests --- meson.build | 1 + tests/meson.build | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 tests/meson.build diff --git a/meson.build b/meson.build index de8d9f00f..5b1552042 100644 --- a/meson.build +++ b/meson.build @@ -326,6 +326,7 @@ endif ### subdirectories subdir('src') +subdir('tests') configure_file(output: 'config.h', configuration: config_h) diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 000000000..0ffe4dceb --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: 0BSD +# Author: Vincent Torri + +xz_test_src = [ + 'create_compress_files', + 'test_check', + 'test_hardware', + 'test_stream_flags', + 'test_filter_flags', + 'test_filter_str', + 'test_block_header', + 'test_index', + 'test_index_hash', + 'test_bcj_exact_size', + 'test_memlimit', + 'test_lzip_decoder', + 'test_vli', +] +if get_option('microlzma') + xz_test_src += [ + 'test_microlzma', + ] +endif + +test_cargs = [ + '-DHAVE_CONFIG_H', +] + +test_incdir = [ + '../src/common', + '../src/liblzma', + '../src/liblzma/api', + config_dir +] + +foreach t : xz_test_src + exe = executable( + t, + files(t + '.c'), + c_args: test_cargs, + dependencies: lzma_dep, + include_directories: test_incdir, + ) + test(t, exe, timeout: 0, workdir: meson.current_source_dir()) +endforeach + +# TODO: script ones