diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2020-09-14 21:37:50 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2020-09-14 21:49:09 +0200 |
commit | 0b669b5fbe4d3c25a682a67f1059d8633c963b3d (patch) | |
tree | 59a47e62869618359506195074e3f7ca73f64654 | |
parent | 8a808aa493980e212b4d5f5465330905c8294e59 (diff) | |
download | slirp-0b669b5fbe4d3c25a682a67f1059d8633c963b3d.zip slirp-0b669b5fbe4d3c25a682a67f1059d8633c963b3d.tar.gz slirp-0b669b5fbe4d3c25a682a67f1059d8633c963b3d.tar.bz2 |
meson: support compiling as subproject
Skip installation of devel files if compiling as
a subproject, including the library if a static version is
available; the parent project can force usage of the (installed)
shared library using default_library=shared.
An option can also be used to customize the SLIRP_VERSION_STRING
and ascertain if the parent project is using the embedded version
of slirp.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | meson.build | 54 | ||||
-rw-r--r-- | meson_options.txt | 2 |
2 files changed, 33 insertions, 23 deletions
diff --git a/meson.build b/meson.build index 65bc6cb..c777dff 100644 --- a/meson.build +++ b/meson.build @@ -2,7 +2,7 @@ project('libslirp', 'c', version : '4.3.1', license : 'BSD-3-Clause', default_options : ['warning_level=1', 'c_std=gnu99'], - meson_version : '>= 0.49', + meson_version : '>= 0.50', ) version = meson.project_version() @@ -17,7 +17,7 @@ conf.set('SLIRP_MINOR_VERSION', minor_version) conf.set('SLIRP_MICRO_VERSION', micro_version) full_version = run_command('build-aux/git-version-gen', - '@0@/.tarball-version'.format(meson.source_root()), + '@0@/.tarball-version'.format(meson.current_source_dir()), check : true).stdout().strip() if full_version.startswith('UNKNOWN') full_version = meson.project_version() @@ -25,7 +25,7 @@ elif not full_version.startswith(meson.project_version()) error('meson.build project version @0@ does not match git-describe output @1@' .format(meson.project_version(), full_version)) endif -conf.set_quoted('SLIRP_VERSION_STRING', full_version) +conf.set_quoted('SLIRP_VERSION_STRING', full_version + get_option('version_suffix')) # libtool versioning - this applies to libslirp # @@ -105,9 +105,12 @@ sources = [ mapfile = 'src/libslirp.map' vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile) +install_devel = not meson.is_subproject() + configure_file( input : 'src/libslirp-version.h.in', output : 'libslirp-version.h', + install : install_devel, install_dir : join_paths(get_option('includedir'), 'slirp'), configuration : conf ) @@ -118,25 +121,30 @@ lib = library('slirp', sources, link_args : vflag, link_depends : mapfile, dependencies : [glib_dep, platform_deps], - install : true + install : install_devel or get_option('default_library') == 'shared', ) -libslirp_dep = declare_dependency( - include_directories: include_directories('.', 'src'), - link_with: lib) - -install_headers(['src/libslirp.h'], subdir : 'slirp') - -pkg = import('pkgconfig') - -pkg.generate( - version : version, - libraries : lib, - requires : [ - 'glib-2.0', - ], - name : 'slirp', - description : 'User-space network stack', - filebase : 'slirp', - subdirs : 'slirp', -) +if install_devel + install_headers(['src/libslirp.h'], subdir : 'slirp') + + pkg = import('pkgconfig') + + pkg.generate( + version : version, + libraries : lib, + requires : [ + 'glib-2.0', + ], + name : 'slirp', + description : 'User-space network stack', + filebase : 'slirp', + subdirs : 'slirp', + ) +else + if get_option('default_library') == 'both' + lib = lib.get_static_lib() + endif + libslirp_dep = declare_dependency( + include_directories: include_directories('.', 'src'), + link_with: lib) +endif diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..27e7c80 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,2 @@ +option('version_suffix', type: 'string', value: '', + description: 'Suffix to append to SLIRP_VERSION_STRING') |