From 5c3c04fc156085425e489c87f61f540ac17849da Mon Sep 17 00:00:00 2001 From: meator Date: Sat, 7 Dec 2024 22:03:53 +0100 Subject: [PATCH] Add Meson -Werror is dropped, because Meson's werror is more strict than configure one. This implementation does not support running tests. The Kyua testsuite heavily relies on in-source builds. Tests would have to be rewritten (at least the Kyuafile files, but probably more) to support Meson. Meson does not support retrieving git info and providing it as a compiler flag. Meson's vcs_tag() mechanism supports outputting to a (header or source) file only. This would mean that xbps.h.in would have to be modified. No substitution is done on xbps.h.in. See #598 for explanation. _DEFAULT_SOURCE is dropped, because _GNU_SOURCE implies _DEFAULT_SOURCE. -D_FILE_OFFSET_BITS=64 is set automatically by Meson. Work in progress! --- .gitignore | 5 + bin/meson.build | 19 +++ bin/xbps-alternatives/meson.build | 4 + bin/xbps-checkvers/meson.build | 10 ++ bin/xbps-create/meson.build | 4 + bin/xbps-dgraph/meson.build | 4 + bin/xbps-digest/meson.build | 4 + bin/xbps-fbulk/meson.build | 4 + bin/xbps-fetch/meson.build | 4 + bin/xbps-install/meson.build | 50 +++++++ bin/xbps-pkgdb/meson.build | 12 ++ bin/xbps-query/meson.build | 12 ++ bin/xbps-reconfigure/meson.build | 4 + bin/xbps-remove/meson.build | 10 ++ bin/xbps-rindex/meson.build | 11 ++ bin/xbps-uchroot/meson.build | 4 + bin/xbps-uhelper/meson.build | 4 + bin/xbps-uunshare/meson.build | 4 + data/meson.build | 39 +++++ doc/meson.build | 39 +++++ include/meson.build | 11 ++ lib/compat/meson.build | 19 +++ lib/external/meson.build | 1 + lib/fetch/meson.build | 27 ++++ lib/meson.build | 78 ++++++++++ lib/portableproplib/meson.build | 53 +++++++ meson.build | 240 ++++++++++++++++++++++++++++++ meson.options | 9 ++ subprojects/libarchive.wrap | 13 ++ subprojects/openssl.wrap | 15 ++ subprojects/zlib.wrap | 13 ++ 31 files changed, 726 insertions(+) create mode 100644 bin/meson.build create mode 100644 bin/xbps-alternatives/meson.build create mode 100644 bin/xbps-checkvers/meson.build create mode 100644 bin/xbps-create/meson.build create mode 100644 bin/xbps-dgraph/meson.build create mode 100644 bin/xbps-digest/meson.build create mode 100644 bin/xbps-fbulk/meson.build create mode 100644 bin/xbps-fetch/meson.build create mode 100644 bin/xbps-install/meson.build create mode 100644 bin/xbps-pkgdb/meson.build create mode 100644 bin/xbps-query/meson.build create mode 100644 bin/xbps-reconfigure/meson.build create mode 100644 bin/xbps-remove/meson.build create mode 100644 bin/xbps-rindex/meson.build create mode 100644 bin/xbps-uchroot/meson.build create mode 100644 bin/xbps-uhelper/meson.build create mode 100644 bin/xbps-uunshare/meson.build create mode 100644 data/meson.build create mode 100644 doc/meson.build create mode 100644 include/meson.build create mode 100644 lib/compat/meson.build create mode 100644 lib/external/meson.build create mode 100644 lib/fetch/meson.build create mode 100644 lib/meson.build create mode 100644 lib/portableproplib/meson.build create mode 100644 meson.build create mode 100644 meson.options create mode 100644 subprojects/libarchive.wrap create mode 100644 subprojects/openssl.wrap create mode 100644 subprojects/zlib.wrap diff --git a/.gitignore b/.gitignore index 66249eedc..11f4e76ac 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,11 @@ tests/*/*/*_test tests/*/*/*_tests include/xbps.h +subprojects/libarchive-* +subprojects/openssl-* +subprojects/packagecache +subprojects/zlib-* + # vim backup files .*.swp *~ diff --git a/bin/meson.build b/bin/meson.build new file mode 100644 index 000000000..df04a4ddd --- /dev/null +++ b/bin/meson.build @@ -0,0 +1,19 @@ +subdir('xbps-alternatives') +subdir('xbps-create') +subdir('xbps-dgraph') +subdir('xbps-install') +subdir('xbps-pkgdb') +subdir('xbps-query') +subdir('xbps-reconfigure') +subdir('xbps-remove') +subdir('xbps-rindex') +subdir('xbps-uhelper') +subdir('xbps-checkvers') +subdir('xbps-fbulk') +subdir('xbps-digest') +subdir('xbps-fetch') + +if host_machine.system() == 'linux' + subdir('xbps-uchroot') + subdir('xbps-uunshare') +endif diff --git a/bin/xbps-alternatives/meson.build b/bin/xbps-alternatives/meson.build new file mode 100644 index 000000000..8bbbc93d1 --- /dev/null +++ b/bin/xbps-alternatives/meson.build @@ -0,0 +1,4 @@ +src = ['main.c'] + +install_man('xbps-alternatives.1') +executable('xbps-alternatives', src, dependencies: libxbps_dep, install: true) diff --git a/bin/xbps-checkvers/meson.build b/bin/xbps-checkvers/meson.build new file mode 100644 index 000000000..3ae6c236e --- /dev/null +++ b/bin/xbps-checkvers/meson.build @@ -0,0 +1,10 @@ +src = ['main.c'] + +install_man('xbps-checkvers.1') +executable( + 'xbps-checkvers', + src, + c_args: '-Wno-deprecated-declarations', + dependencies: libxbps_dep, + install: true, +) diff --git a/bin/xbps-create/meson.build b/bin/xbps-create/meson.build new file mode 100644 index 000000000..83704986f --- /dev/null +++ b/bin/xbps-create/meson.build @@ -0,0 +1,4 @@ +src = ['main.c'] + +install_man('xbps-create.1') +executable('xbps-create', src, dependencies: libxbps_dep, install: true) diff --git a/bin/xbps-dgraph/meson.build b/bin/xbps-dgraph/meson.build new file mode 100644 index 000000000..475123976 --- /dev/null +++ b/bin/xbps-dgraph/meson.build @@ -0,0 +1,4 @@ +src = ['main.c'] + +install_man('xbps-dgraph.1') +executable('xbps-dgraph', src, dependencies: libxbps_dep, install: true) diff --git a/bin/xbps-digest/meson.build b/bin/xbps-digest/meson.build new file mode 100644 index 000000000..37a62268f --- /dev/null +++ b/bin/xbps-digest/meson.build @@ -0,0 +1,4 @@ +src = ['main.c'] + +install_man('xbps-digest.1') +executable('xbps-digest', src, dependencies: libxbps_dep, install: true) diff --git a/bin/xbps-fbulk/meson.build b/bin/xbps-fbulk/meson.build new file mode 100644 index 000000000..d49f1289f --- /dev/null +++ b/bin/xbps-fbulk/meson.build @@ -0,0 +1,4 @@ +src = ['main.c'] + +install_man('xbps-fbulk.1') +executable('xbps-fbulk', src, dependencies: libxbps_dep, install: true) diff --git a/bin/xbps-fetch/meson.build b/bin/xbps-fetch/meson.build new file mode 100644 index 000000000..5e60a4b63 --- /dev/null +++ b/bin/xbps-fetch/meson.build @@ -0,0 +1,4 @@ +src = ['main.c', '../xbps-install/fetch_cb.c'] + +install_man('xbps-fetch.1') +executable('xbps-fetch', src, dependencies: libxbps_dep, install: true) diff --git a/bin/xbps-install/meson.build b/bin/xbps-install/meson.build new file mode 100644 index 000000000..616b4f930 --- /dev/null +++ b/bin/xbps-install/meson.build @@ -0,0 +1,50 @@ +src = [ + 'main.c', + 'transaction.c', + 'question.c', + 'fetch_cb.c', + 'state_cb.c', + 'util.c', +] + +clock_gettime_code = ''' +#include +int main(void) { + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return 0; +} +''' + +CC = meson.get_compiler('c') + +rt = CC.find_library('rt', required: false) +extra_flags = [] + +if rt.found() + if CC.compiles( + clock_gettime_code, + name: 'clock_gettime() available', + args: '-D_GNU_SOURCE', + dependencies: rt, + ) + extra_flags = '-DHAVE_CLOCK_GETTIME' + endif +else + if CC.compiles( + clock_gettime_code, + name: 'clock_gettime() available', + args: '-D_GNU_SOURCE', + ) + extra_flags = '-DHAVE_CLOCK_GETTIME' + endif +endif + +install_man('xbps-install.1') +executable( + 'xbps-install', + src, + c_args: extra_flags, + dependencies: libxbps_dep, + install: true, +) diff --git a/bin/xbps-pkgdb/meson.build b/bin/xbps-pkgdb/meson.build new file mode 100644 index 000000000..65e412d00 --- /dev/null +++ b/bin/xbps-pkgdb/meson.build @@ -0,0 +1,12 @@ +src = [ + 'main.c', + 'check.c', + 'check_pkg_files.c', + 'check_pkg_alternatives.c', + 'check_pkg_rundeps.c', + 'check_pkg_symlinks.c', + 'check_pkg_unneeded.c', +] + +install_man('xbps-pkgdb.1') +executable('xbps-pkgdb', src, dependencies: libxbps_dep, install: true) diff --git a/bin/xbps-query/meson.build b/bin/xbps-query/meson.build new file mode 100644 index 000000000..46a875f7e --- /dev/null +++ b/bin/xbps-query/meson.build @@ -0,0 +1,12 @@ +src = [ + 'main.c', + 'list.c', + 'show-deps.c', + 'show-info-files.c', + 'ownedby.c', + 'search.c', + '../xbps-install/util.c', +] + +install_man('xbps-query.1') +executable('xbps-query', src, dependencies: libxbps_dep, install: true) diff --git a/bin/xbps-reconfigure/meson.build b/bin/xbps-reconfigure/meson.build new file mode 100644 index 000000000..45339af36 --- /dev/null +++ b/bin/xbps-reconfigure/meson.build @@ -0,0 +1,4 @@ +src = ['main.c', 'find-deps.c'] + +install_man('xbps-reconfigure.1') +executable('xbps-reconfigure', src, dependencies: libxbps_dep, install: true) diff --git a/bin/xbps-remove/meson.build b/bin/xbps-remove/meson.build new file mode 100644 index 000000000..0b3195e23 --- /dev/null +++ b/bin/xbps-remove/meson.build @@ -0,0 +1,10 @@ +src = [ + 'main.c', + 'clean-cache.c', + '../xbps-install/question.c', + '../xbps-install/util.c', + '../xbps-install/transaction.c', +] + +install_man('xbps-remove.1') +executable('xbps-remove', src, dependencies: libxbps_dep, install: true) diff --git a/bin/xbps-rindex/meson.build b/bin/xbps-rindex/meson.build new file mode 100644 index 000000000..4fb440fce --- /dev/null +++ b/bin/xbps-rindex/meson.build @@ -0,0 +1,11 @@ +src = [ + 'main.c', + 'index-add.c', + 'index-clean.c', + 'remove-obsoletes.c', + 'repoflush.c', + 'sign.c', +] + +install_man('xbps-rindex.1') +executable('xbps-rindex', src, dependencies: libxbps_dep, install: true) diff --git a/bin/xbps-uchroot/meson.build b/bin/xbps-uchroot/meson.build new file mode 100644 index 000000000..7741513b0 --- /dev/null +++ b/bin/xbps-uchroot/meson.build @@ -0,0 +1,4 @@ +src = ['main.c'] + +install_man('xbps-uchroot.1') +executable('xbps-uchroot', src, dependencies: libxbps_dep, install: true) diff --git a/bin/xbps-uhelper/meson.build b/bin/xbps-uhelper/meson.build new file mode 100644 index 000000000..137cc7014 --- /dev/null +++ b/bin/xbps-uhelper/meson.build @@ -0,0 +1,4 @@ +src = ['main.c', '../xbps-install/fetch_cb.c'] + +install_man('xbps-uhelper.1') +executable('xbps-uhelper', src, dependencies: libxbps_dep, install: true) diff --git a/bin/xbps-uunshare/meson.build b/bin/xbps-uunshare/meson.build new file mode 100644 index 000000000..feeb68d5d --- /dev/null +++ b/bin/xbps-uunshare/meson.build @@ -0,0 +1,4 @@ +src = ['main.c'] + +install_man('xbps-uunshare.1') +executable('xbps-uunshare', src, dependencies: libxbps_dep, install: true) diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 000000000..2a6a4874b --- /dev/null +++ b/data/meson.build @@ -0,0 +1,39 @@ +install_man('xbps.d.5') +install_data( + '60:ae:0c:d6:f0:95:17:80:bc:93:46:7a:89:af:a3:2d.plist', + install_dir: dbdir, +) +install_data( + 'repod-main.conf', + 'xbps.conf', + install_dir: get_option('datadir') / 'xbps.d', + rename: ['00-repository-main.conf', 'xbps.conf'], +) +install_data( + '_xbps', + '_xbps_src', + install_dir: get_option('datadir') / 'zsh/site-functions', +) +install_data( + 'xbps.bash', + install_dir: get_option('datadir') / 'bash-completion/completions', + rename: 'xbps', +) + +foreach file : [ + 'xbps-checkvers', + 'xbps-create', + 'xbps-dgraph', + 'xbps-install', + 'xbps-pkgdb', + 'xbps-query', + 'xbps-reconfigure', + 'xbps-remove', + 'xbps-rindex', +] + install_symlink( + file, + pointing_to: 'xbps', + install_dir: get_option('datadir') / 'bash-completion/completions', + ) +endforeach diff --git a/doc/meson.build b/doc/meson.build new file mode 100644 index 000000000..18e772891 --- /dev/null +++ b/doc/meson.build @@ -0,0 +1,39 @@ +doxygen = find_program('doxygen', required: true) +graphviz_dot = find_program('dot', required: true) + +dot_format = get_option('api-docs-format') + +foreach dotfile : [ + 'xbps_transaction_dictionary', + 'xbps_pkgdb_dictionary', + 'xbps_pkg_props_dictionary', + 'xbps_pkg_files_dictionary', + 'xbps_binary_pkg_content', +] + custom_target( + command: [graphviz_dot, '-T' + dot_format, '@INPUT@', '-o', '@OUTPUT@'], + input: dotfile + '.dot', + output: dotfile + '.' + dot_format, + build_by_default: true, + ) +endforeach + +sed = find_program('sed', required: true) +distver = get_option('api-docs-distver') +if distver == '' + command = [ + 'sh', + '-c', + sed.full_path() + ' -e \'s|@@PROJECT_NUMBER@@|$(date +%Y%m%d)|\' @INPUT@', + ] +else + command = [sed, '-e', 's|@@PROJECT_NUMBER@@|' + distver + '|', '@INPUT@'] +endif +xbps_api_doxyfile = custom_target( + command: command, + input: 'xbps_api_doxyfile.in', + capture: true, + output: 'xbps_api_doxyfile', +) + +run_target('doxygen', command: [doxygen, xbps_api_doxyfile]) diff --git a/include/meson.build b/include/meson.build new file mode 100644 index 000000000..43fd1830e --- /dev/null +++ b/include/meson.build @@ -0,0 +1,11 @@ +configure_file( + input: 'xbps.h.in', + output: 'xbps.h', + copy: true, + install: true, + install_dir: get_option('includedir'), +) + +install_subdir('xbps', install_dir: get_option('includedir')) + +xbps_include = include_directories('.') diff --git a/lib/compat/meson.build b/lib/compat/meson.build new file mode 100644 index 000000000..1e0cacf05 --- /dev/null +++ b/lib/compat/meson.build @@ -0,0 +1,19 @@ +compat_functions = [] + +if not compatibility_functions['vasprintf'] + compat_functions += 'vasprintf.c' +endif +if not compatibility_functions['strcasestr'] + compat_functions += 'strcasestr.c' +endif +if not compatibility_functions['strlcpy'] + compat_functions += 'strlcpy.c' +endif +if not compatibility_functions['strlcat'] + compat_functions += 'strlcat.c' +endif +if not compatibility_functions['humanize_number'] + compat_functions += 'humanize_number.c' +endif + +compat_files = files(compat_functions) diff --git a/lib/external/meson.build b/lib/external/meson.build new file mode 100644 index 000000000..aaa4b5e48 --- /dev/null +++ b/lib/external/meson.build @@ -0,0 +1 @@ +external_files = files('dewey.c', 'fexec.c', 'mkpath.c') diff --git a/lib/fetch/meson.build b/lib/fetch/meson.build new file mode 100644 index 000000000..da51f4b73 --- /dev/null +++ b/lib/fetch/meson.build @@ -0,0 +1,27 @@ +src = ['common.c', 'fetch.c', 'file.c', 'ftp.c', 'http.c'] + +ftperr = custom_target( + 'ftperr', + command: [files('errlist.sh'), 'ftp_errlist', 'FTP', '@INPUT@'], + capture: true, + input: 'ftp.errors', + output: 'ftperr.h', +) + +httperr = custom_target( + 'httperr', + command: [files('errlist.sh'), 'http_errlist', 'HTTP', '@INPUT@'], + capture: true, + input: 'http.errors', + output: 'httperr.h', +) + +libfetch = static_library( + 'fetch', + src, + ftperr, + httperr, + c_args: ['-DFTP_COMBINE_CWDS', '-DINET6', '-DWITH_SSL'], + gnu_symbol_visibility: 'hidden', + include_directories: [xbps_include, '.'], +) diff --git a/lib/meson.build b/lib/meson.build new file mode 100644 index 000000000..e19ed025b --- /dev/null +++ b/lib/meson.build @@ -0,0 +1,78 @@ +subdir('external') +subdir('compat') + +subdir('portableproplib') +subdir('fetch') + +src = [ + 'package_configure.c', + 'package_config_files.c', + 'package_orphans.c', + 'package_remove.c', + 'package_state.c', + 'package_msg.c', + 'package_unpack.c', + 'package_register.c', + 'package_script.c', + 'verifysig.c', + 'transaction_commit.c', + 'transaction_prepare.c', + 'transaction_ops.c', + 'transaction_store.c', + 'transaction_check_replaces.c', + 'transaction_check_revdeps.c', + 'transaction_check_conflicts.c', + 'transaction_check_shlibs.c', + 'transaction_files.c', + 'transaction_fetch.c', + 'transaction_pkg_deps.c', + 'transaction_internalize.c', + 'pubkey2fp.c', + 'package_fulldeptree.c', + 'download.c', + 'initend.c', + 'pkgdb.c', + 'plist.c', + 'plist_find.c', + 'plist_match.c', + 'archive.c', + 'plist_remove.c', + 'plist_fetch.c', + 'util.c', + 'util_path.c', + 'util_hash.c', + 'repo.c', + 'repo_sync.c', + 'rpool.c', + 'cb_util.c', + 'proplib_wrapper.c', + 'package_alternatives.c', + 'conf.c', + 'log.c', + external_files, + compat_files, +] + +libxbps = library( + 'xbps', + src, + version: '5.0.1', + include_directories: [xbps_include, 'fetch', 'portableproplib'], + link_with: [libprop, libfetch], + dependencies: [libarchive, libssl, libcrypto], + install: true, +) + +pkg = import('pkgconfig') +pkg.generate( + libxbps, + name: 'XBPS API Library', + description: 'The X Binary Package System library', + filebase: 'libxbps', +) + +libxbps_dep = declare_dependency( + link_with: libxbps, + include_directories: xbps_include, + dependencies: [libarchive, libssl, libcrypto], +) diff --git a/lib/portableproplib/meson.build b/lib/portableproplib/meson.build new file mode 100644 index 000000000..90595d91c --- /dev/null +++ b/lib/portableproplib/meson.build @@ -0,0 +1,53 @@ +src = [ + 'prop_array.c', + 'prop_bool.c', + 'prop_dictionary.c', + 'prop_ingest.c', + 'prop_object.c', + 'prop_stack.c', + 'prop_string.c', + 'prop_array_util.c', + 'prop_number.c', + 'prop_dictionary_util.c', + 'prop_zlib.c', + 'prop_data.c', +] + +CC = meson.get_compiler('c') + +rb_tree_init_code = ''' +#include +int main(void) { + rb_tree_init(NULL, NULL); + return 0; +} +''' + +gcc_atomic_code = ''' +int main() { + volatile unsigned long val = 1; + __sync_fetch_and_add(&val, 1); + __sync_fetch_and_sub(&val, 1); + __sync_add_and_fetch(&val, 1); + __sync_sub_and_fetch(&val, 1); + return 0; +} +''' + +if not CC.compiles(rb_tree_init_code, name: 'rb_tree_init() available') + src += 'rb.c' +endif + +enable_atomic = [] +if CC.compiles(gcc_atomic_code, name: 'GCC atomic builtins available') + enable_atomic = '-DHAVE_ATOMICS' +endif + +libprop = static_library( + 'portableproplib', + src, + c_args: ['-Wno-unused-parameter', enable_atomic], + include_directories: [xbps_include, 'prop'], + gnu_symbol_visibility: 'hidden', + dependencies: [zlib], +) diff --git a/meson.build b/meson.build new file mode 100644 index 000000000..50d87845e --- /dev/null +++ b/meson.build @@ -0,0 +1,240 @@ +project( + 'xbps', + 'c', + default_options: ['warning_level=3', 'c_std=c99', 'b_lto=true'], + license: 'BSD-2-Clause, BSD-3-Clause, ISC', + license_files: 'LICENSE', + meson_version: '>=1.3.0', + version: '0.60', +) + +# == Set preprocessor defines used by XBPS ==================================== + +CC = meson.get_compiler('c') + +if CC.has_function_attribute('visibility:hidden') + add_project_arguments('-DHAVE_VISIBILITY', language: 'c') +endif + +prefix = get_option('prefix') + +dbdir = get_option('dbdir') +if dbdir == '' + dbdir = prefix / get_option('localstatedir') / 'db/xbps' +else + dbdir = prefix / dbdir +endif + +CC.has_function_attribute('unused', required: true) + +add_project_arguments( + '-D_GNU_SOURCE', + '-DXBPS_SYSCONF_PATH="' + prefix / get_option('sysconfdir') / 'xbps.d' + '"', + '-DXBPS_SYSDEFCONF_PATH="' + prefix / get_option('datadir') / 'xbps.d' + '"', + '-DXBPS_VERSION="' + meson.project_version() + '"', + '-DXBPS_META_PATH="' + dbdir + '"', + '-DUNUSED=__attribute__((__unused__))', + language: 'c', +) + +if get_option('enable-fulldebug') + add_project_arguments('-DFULL_DEBUG', language: 'c') +elif get_option('debug') + add_project_arguments('-DDEBUG', language: 'c') +endif + +if build_machine.system() == 'linux' + add_project_arguments('-D_XOPEN_SOURCE=700', language: 'c') +endif + +# == Set extra flags for warnings, fortifying and linking ===================== + +# Enable extra warnings if supported by compiler. +if get_option('warning_level') == '3' + foreach warn : [ + 'shadow', + 'format=2', + 'missing-prototypes', + 'missing-declarations', + 'nested-externs', + 'vla', + 'overlength-strings', + 'unsafe-loop-optimizations', + 'undef', + 'sign-compare', + 'missing-include-dirs', + 'old-style-definition', + 'init-self', + 'redundant-decls', + 'float-equal', + 'missing-noreturn', + 'cast-align', + 'cast-qual', + 'pointer-arith', + 'comment', + 'declaration-after-statement', + 'write-strings', + 'stack-protector', + ] + if CC.has_argument('-W' + warn) + add_project_arguments('-W' + warn, language: 'c') + endif + endforeach +endif + +if CC.has_argument('-finline-functions') + add_project_arguments('-finline-functions', language: 'c') +endif +if CC.has_argument('-fstack-protector-strong') + add_project_arguments('-fstack-protector-strong', language: 'c') +elif CC.has_argument('-fstack-protector') + add_project_arguments('-fstack-protector', language: 'c') + if CC.get_id() == 'gcc' + add_project_arguments('--param', 'ssp-buffer-size=1', language: 'c') + endif +endif + +if CC.has_multi_link_arguments('-z', 'relro') + add_project_link_arguments('-z', 'relro', language: 'c') +endif +if CC.has_multi_link_arguments('-z', 'now') + add_project_link_arguments('-z', 'now', language: 'c') +endif + +# openssl 3 compatibility +add_project_arguments('-Wno-error=deprecated-declarations', language: 'c') + +# TODO: vcs_tag() & XBPS_GIT +# TODO: export_dynamic +# TODO: does LTO require gcc-ar and gcc-ranlib? + +# == Get dependencies ========================================================= + +# Import all dependencies. If provided through a subproject, skip building tests +# and additional executables. +libssl = dependency('libssl', version: '>=3.0.0', default_options: 'c_std=none') +libcrypto = dependency('libcrypto', default_options: 'c_std=none') +zlib = dependency('zlib', default_options: ['c_std=none', 'tests=disabled']) +libarchive = dependency( + 'libarchive', + version: '>=3.3.3', + default_options: ['c_std=none', 'progs=[]'], +) + +# == Check for nonportable functions ========================================== + +vasprintf_code = ''' +#define _GNU_SOURCE +#include +#include +int main(void) { + va_list ap; + vasprintf(NULL, NULL, ap); + return 0; +} +''' + +strcasestr_code = ''' +#define _GNU_SOURCE +#include +int main(void) { + const char *h = "NEEDCOFEE"; + const char *n = "IneedCoffee"; + strcasestr(n, h); + return 0; +} +''' + +strlcpy_code = ''' +#include +int main(void) { + const char s1[] = "foo"; + char s2[10]; + strlcpy(s2, s1, sizeof(s2)); + return 0; +} +''' + +strlcat_code = ''' +#include +int main(void) { + const char src[] = "foo"; + char dst[10]; + strlcat(dst, src, sizeof(dst)); + return 0; +} +''' + +humanize_number_code = ''' +#include +#include + +int main(void) { + humanize_number(NULL, 0, 0, NULL, 0, 0); + return 0; +} +''' + +fdatasync_code = ''' +#include +int main(void) { + fdatasync(0); + return 0; +} +''' + +# Link against util if available +util_lib = CC.find_library('util', required: false) +util_lib_dependency = util_lib.found() ? {'dependencies': util_lib} : {} + +# This variable is reused in lib/compat/ to use compatibility replacements +# for unavailable functions. +compatibility_functions = { + 'vasprintf': CC.compiles(vasprintf_code, name: 'vasprintf() available'), + 'strcasestr': CC.compiles(strcasestr_code, name: 'strcasestr() available'), + 'strlcpy': CC.compiles(strlcpy_code, name: 'strlcpy() available'), + 'strlcat': CC.compiles(strlcat_code, name: 'strlcat() available'), + 'humanize_number': CC.compiles( + humanize_number_code, + name: 'humanize_number() available', + kwargs: util_lib_dependency, + ), +} + +if compatibility_functions['vasprintf'] + add_project_arguments('-DHAVE_VASPRINTF', language: 'c') +endif +if compatibility_functions['strcasestr'] + add_project_arguments('-DHAVE_STRCASESTR', language: 'c') +endif +if compatibility_functions['strlcpy'] + add_project_arguments('-DHAVE_STRLCPY', language: 'c') +endif +if compatibility_functions['strlcat'] + add_project_arguments('-DHAVE_STRLCAT', language: 'c') +endif +if compatibility_functions['humanize_number'] + add_project_arguments('-DHAVE_HUMANIZE_NUMBER', language: 'c') +endif + +if CC.compiles(fdatasync_code, name: 'fdatasync() available') + add_project_arguments('-DHAVE_FDATASYNC', language: 'c') +endif + +# == Build subdirectories ===================================================== + +subdir('include') +subdir('lib') +subdir('bin') +subdir('data') + +if get_option('enable-api-docs') + subdir('doc') +endif +if get_option('enable-tests') + error( + 'Tests are not implemented in Meson! They heavily rely on in-source', + 'builds, which Meson does not support.', + ) + # subdir('tests') +endif diff --git a/meson.options b/meson.options new file mode 100644 index 000000000..edec73755 --- /dev/null +++ b/meson.options @@ -0,0 +1,9 @@ +option('dbdir', description: 'Path to the pkgdb directory [LOCALSTATEDIR/db/xbps]', type: 'string') +option('enable-fulldebug', description: 'Enables extra debugging code', type: 'boolean', value: false) +option('enable-api-docs', description: 'Install XBPS API Library documentation (use doxygen target to build docs)', type: 'boolean', value: false) +option('enable-tests', description: '''Build and install Kyua tests (default disabled) + Needs atf >= 0.15 (https://github.com/jmmv/atf) + Needs kyua to run the test suite (https://github.com/jmmv/kyua)''', type: 'boolean', value: false) +option('testsdir', description: 'Test suite directory [PREFIX/tests]', type: 'string', value: 'tests') +option('api-docs-format', description: 'Format of dot diagrams in doc/', type: 'string', value: 'png') +option('api-docs-distver', description: 'Project number of Doxygen docs (current date if unset)', type: 'string') diff --git a/subprojects/libarchive.wrap b/subprojects/libarchive.wrap new file mode 100644 index 000000000..061452545 --- /dev/null +++ b/subprojects/libarchive.wrap @@ -0,0 +1,13 @@ +[wrap-file] +directory = libarchive-3.7.7 +source_url = https://github.com/libarchive/libarchive/releases/download/v3.7.7/libarchive-3.7.7.tar.xz +source_filename = libarchive-3.7.7.tar.xz +source_hash = 879acd83c3399c7caaee73fe5f7418e06087ab2aaf40af3e99b9e29beb29faee +patch_filename = libarchive_3.7.7-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/libarchive_3.7.7-1/get_patch +patch_hash = 52f3f4b4f7ee8af27350bdbe21a726b6183d2a872a9ee7dfcc3f752022a70817 +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/libarchive_3.7.7-1/libarchive-3.7.7.tar.xz +wrapdb_version = 3.7.7-1 + +[provide] +libarchive = libarchive_dep diff --git a/subprojects/openssl.wrap b/subprojects/openssl.wrap new file mode 100644 index 000000000..873d55106 --- /dev/null +++ b/subprojects/openssl.wrap @@ -0,0 +1,15 @@ +[wrap-file] +directory = openssl-3.0.8 +source_url = https://www.openssl.org/source/openssl-3.0.8.tar.gz +source_filename = openssl-3.0.8.tar.gz +source_hash = 6c13d2bf38fdf31eac3ce2a347073673f5d63263398f1f69d0df4a41253e4b3e +patch_filename = openssl_3.0.8-3_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/openssl_3.0.8-3/get_patch +patch_hash = 300da189e106942347d61a4a4295aa2edbcf06184f8d13b4cee0bed9fb936963 +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/openssl_3.0.8-3/openssl-3.0.8.tar.gz +wrapdb_version = 3.0.8-3 + +[provide] +libcrypto = libcrypto_dep +libssl = libssl_dep +openssl = openssl_dep diff --git a/subprojects/zlib.wrap b/subprojects/zlib.wrap new file mode 100644 index 000000000..aa14de177 --- /dev/null +++ b/subprojects/zlib.wrap @@ -0,0 +1,13 @@ +[wrap-file] +directory = zlib-1.3.1 +source_url = http://zlib.net/fossils/zlib-1.3.1.tar.gz +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/zlib_1.3.1-1/zlib-1.3.1.tar.gz +source_filename = zlib-1.3.1.tar.gz +source_hash = 9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23 +patch_filename = zlib_1.3.1-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/zlib_1.3.1-1/get_patch +patch_hash = e79b98eb24a75392009cec6f99ca5cdca9881ff20bfa174e8b8926d5c7a47095 +wrapdb_version = 1.3.1-1 + +[provide] +zlib = zlib_dep