diff --git a/doc/meson.build b/doc/meson.build new file mode 100644 index 0000000..6142884 --- /dev/null +++ b/doc/meson.build @@ -0,0 +1,46 @@ +scdoc_prog = find_program(scdoc.get_pkgconfig_variable('scdoc'), native: true) +sh = find_program('sh', native: true) +mandir = get_option('mandir') + +man_files = [ + 'apk.8.scd', + 'apk-add.8.scd', + 'apk-audit.8.scd', + 'apk-cache.5.scd', + 'apk-cache.8.scd', + 'apk-del.8.scd', + 'apk-dot.8.scd', + 'apk-fetch.8.scd', + 'apk-fix.8.scd', + 'apk-index.8.scd', + 'apk-info.8.scd', + 'apk-keys.5.scd', + 'apk-list.8.scd', + 'apk-manifest.8.scd', + 'apk-policy.8.scd', + 'apk-repositories.5.scd', + 'apk-stats.8.scd', + 'apk-update.8.scd', + 'apk-upgrade.8.scd', + 'apk-verify.8.scd', + 'apk-version.8.scd', + 'apk-world.5.scd', +] + +foreach filename : man_files + topic = filename.split('.')[-3].split('/')[-1] + section = filename.split('.')[-2] + output = '@0@.@1@'.format(topic, section) + + custom_target( + output, + input: filename, + capture: true, + output: output, + command: [ + sh, '-c', '@0@ < @INPUT@'.format(scdoc_prog.path()) + ], + install: true, + install_dir: '@0@/man@1@'.format(mandir, section) + ) +endforeach \ No newline at end of file diff --git a/libfetch/meson.build b/libfetch/meson.build new file mode 100644 index 0000000..1438cac --- /dev/null +++ b/libfetch/meson.build @@ -0,0 +1,46 @@ +libfetch_src = [ + 'common.c', + 'fetch.c', + 'file.c', + 'ftp.c', + 'http.c', + 'openssl-compat.c' +] + +errlist_generator = find_program('errlist.sh') + +ftperr_h = custom_target( + 'ftperr.h', + capture: true, + command: [errlist_generator, 'ftp_errlist', 'FTP', '@INPUT@'], + output: 'ftperr.h', + input: 'ftp.errors', +) + +httperr_h = custom_target( + 'httpderr.h', + capture: true, + command: [errlist_generator, 'http_errlist', 'HTTP', '@INPUT@'], + output: 'httperr.h', + input: 'http.errors', +) + +libfetch_src += [ftperr_h, httperr_h] + +libfetch_cargs = [ + '-DCA_CERT_FILE="/' + apk_confdir / 'ca.pem"', + '-DCA_CRL_FILE="/' + apk_confdir / 'crl.pem"', + '-DCLIENT_CERT_FILE="/' + apk_confdir / 'cert.pem"', + '-DCLIENT_KEY_FILE="/' + apk_confdir / 'cert.key"', +] + +libfetch = static_library( + 'fetch', + libfetch_src, + c_args: libfetch_cargs, +) + +libfetch_dep = declare_dependency( + link_whole: libfetch, + include_directories: include_directories('.'), +) diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..c3fd394 --- /dev/null +++ b/meson.build @@ -0,0 +1,31 @@ +project( + 'apk-tools', + ['c'], + default_options : ['c_std=gnu99'], + version: '2.10.5', + meson_version: '>=0.51' +) +pkgc = import('pkgconfig') + +apk_confdir = get_option('sysconfdir') / 'apk' +apk_libdir = get_option('libdir') + +zlib_dep = dependency('zlib') +openssl_dep = dependency('openssl') +lua_dep = dependency('lua' + get_option('lua_version'), required: get_option('lua')) +scdoc = dependency('scdoc', version: '>=1.10', required: get_option('docs')) + +add_project_arguments('-D_GNU_SOURCE', language: 'c') + +# If we're a subproject we only want the static lib and not files +subproject = meson.is_subproject() +if get_option('default_library') == 'static' + add_project_arguments('-DOPENSSL_NO_ENGINE', language: 'c') +endif + +subdir('libfetch') +subdir('src') + +if scdoc.found() + subdir('doc') +endif diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..8ea72c7 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,3 @@ +option('docs', description: 'Build manpages with scdoc', type: 'feature', value: 'auto') +option('lua', description: 'Build luaapk (lua bindings)', type: 'feature', value: 'auto') +option('lua_version', description: 'Lua version to build against', type: 'string', value: '5.3') diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..070a55b --- /dev/null +++ b/src/meson.build @@ -0,0 +1,117 @@ +libapk_src = [ + 'blob.c', + 'commit.c', + 'common.c', + 'database.c', + 'hash.c', + 'io.c', + 'io_archive.c', + 'io_url.c', + 'io_gunzip.c', + 'package.c', + 'print.c', + 'solver.c', + 'version.c', +] + +libapk_headers = [ + 'apk_applet.h', + 'apk_archive.h', + 'apk_blob.h', + 'apk_database.h', + 'apk_defines.h', + 'apk_hash.h', + 'apk_io.h', + 'apk_openssl.h', + 'apk_package.h', + 'apk_print.h', + 'apk_provider_data.h', + 'apk_solver_data.h', + 'apk_solver.h', + 'apk_version.h', +] + +apk_src = [ + 'apk.c', + 'app_add.c', + 'app_audit.c', + 'app_cache.c', + 'app_del.c', + 'app_dot.c', + 'app_fetch.c', + 'app_fix.c', + 'app_index.c', + 'app_info.c', + 'app_list.c', + 'app_manifest.c', + 'app_policy.c', + 'app_update.c', + 'app_upgrade.c', + 'app_search.c', + 'app_stats.c', + 'app_verify.c', + 'app_version.c', +] + +apk_cargs = [ + '-DAPK_VERSION="' + meson.project_version() + '"', + '-D_ATFILE_SOURCE', +] + +libapk = library( + 'apk', + libapk_src, + version: meson.project_version(), + install: true, + dependencies: [ + libfetch_dep, + zlib_dep, + openssl_dep, + ], + c_args: apk_cargs, +) + +libapk_dep = declare_dependency( + link_with: libapk, +) + +if not subproject + pkgc.generate( + libapk, + name: 'apk', + version: meson.project_version(), + ) + + install_headers( + libapk_headers, + subdir: 'apk', + ) +endif + +if(lua_dep.found()) + luaapk_src = [ + 'lua-apk.c', + ] + + libluaapk = library( + 'luaapk', + luaapk_src, + dependencies: [lua_dep, libapk_dep], + install: true, + install_dir: lua_dep.get_pkgconfig_variable('libdir'), + c_args: apk_cargs, + ) +endif + +apk_exe = executable( + 'apk', + apk_src, + install: not subproject, + dependencies: [ + libapk_dep, + zlib_dep, + openssl_dep, + libfetch_dep.partial_dependency(includes: true), + ], + c_args: apk_cargs, +)