From 5268ff9b006802451e1ebd32bd7a2a9df92c3dd9 Mon Sep 17 00:00:00 2001 From: Emily Date: Sat, 3 Aug 2024 12:58:43 +0100 Subject: [PATCH] Port build system to Meson --- README.md | 21 ++++++++++++++++++++- meson.build | 41 +++++++++++++++++++++++++++++++++++++++++ meson.options | 13 +++++++++++++ src/resample.def | 6 ++++++ tests/meson.build | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 meson.build create mode 100644 meson.options create mode 100644 src/resample.def create mode 100644 tests/meson.build diff --git a/README.md b/README.md index 75faa6b..29bcfa2 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,11 @@ Changes in version 0.1.4: * Uploaded to GitHub: http://github.com/minorninth/libresample -Usage notes: +Changes in version 0.1.5: + +* Added a new build system using Meson. + +Usage notes: - If the output buffer you pass is too small, resample_process may not use any input samples because its internal output @@ -74,6 +78,21 @@ Usage notes: assume that it will be exactly 8000. If you need exactly 8000 outputs, pad the input with extra zeros as necessary. +Build instructions: + +libresample can be built with [Meson](https://mesonbuild.com/), +with the standard Autotools `./configure && make`, or with the +included Visual Studio 2005 project file. + +The Meson build should generally be preferred. In particular, +it is strongly recommended that downstream distribution +packagers use the Meson build system for reasons of +interoperability, as it generates a pkg-config file, supports +building a shared library, can automatically run the tests, and +runs on both Unix-like platforms and Windows. The older Autotools +build system is retained for projects that already embed it into +their builds and systems that do not have Meson. + License and warranty: All of the files in this package are Copyright 2003 by Dominic diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..1aac8f7 --- /dev/null +++ b/meson.build @@ -0,0 +1,41 @@ +project( + 'libresample', + 'c', + meson_version : '>=1.3', + default_options : 'default_library=both', + version : '0.1.5', + license : 'BSD-3-Clause OR LGPL-2.1-or-later', + license_files : ['LICENSE-BSD.txt', 'LICENSE-LGPL.txt'], +) + +cc = meson.get_compiler('c') + +configure_file( + output : 'config.h', + configuration : { + 'HAVE_INTTYPES_H': cc.has_header('inttypes.h').to_int(), + }, +) +config_inc = include_directories('.') + +libm_dep = cc.find_library('m', required : false) + +resample = library( + 'resample', + 'src/filterkit.c', + 'src/resample.c', + 'src/resamplesubs.c', + dependencies : [libm_dep], + include_directories : [config_inc], + vs_module_defs : 'src/resample.def', + version : meson.project_version(), + soversion : 1, + install : true, +) + +install_headers('include/libresample.h') + +pkg = import('pkgconfig') +pkg.generate(resample, name : 'libresample') + +subdir('tests') diff --git a/meson.options b/meson.options new file mode 100644 index 0000000..753971e --- /dev/null +++ b/meson.options @@ -0,0 +1,13 @@ +option( + 'resample-sndfile', + type : 'feature', + value : 'auto', + description : 'Build and install the resample-sndfile tool (depends on libsndfile)', +) + +option( + 'compareresample', + type : 'feature', + value : 'auto', + description : 'Build and install the compareresample tool (depends on libsamplerate)', +) diff --git a/src/resample.def b/src/resample.def new file mode 100644 index 0000000..01a3c6b --- /dev/null +++ b/src/resample.def @@ -0,0 +1,6 @@ +EXPORTS + resample_open + resample_dup + resample_get_filter_width + resample_process + resample_close diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 0000000..ef832a5 --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,35 @@ +testresample = executable( + 'testresample', + 'testresample.c', + dependencies : [libm_dep], + link_with : [resample], +) +test('testresample', testresample) + +sndfile_dep = dependency( + 'sndfile', + required : get_option('resample-sndfile'), +) +if sndfile_dep.found() + resample_sndfile = executable( + 'resample-sndfile', + 'resample-sndfile.c', + dependencies : [sndfile_dep], + link_with : [resample], + install : true, + ) +endif + +samplerate_dep = dependency( + 'samplerate', + required : get_option('compareresample'), +) +if samplerate_dep.found() + compareresample = executable( + 'compareresample', + 'compareresample.c', + dependencies : [libm_dep, samplerate_dep], + link_with : [resample], + install : true, + ) +endif