meson: introduce meson build files

The PACKAGE* variables are defined by AC_INIT so we have to define
explicitly with meson.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
This commit is contained in:
Pavel Hrdina 2020-08-03 08:50:49 +02:00
parent 1ba97d7f6b
commit 8770571e4d
5 changed files with 144 additions and 149 deletions

View File

@ -1,53 +0,0 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
#
# THe following options must come first. All other or subsequent
# arguments are passed to configure:
# --no-git skip `git submodule update --init`
test -n "$srcdir" || srcdir=$(dirname "$0")
test -n "$srcdir" || srcdir=.
olddir=$(pwd)
cd "$srcdir"
(test -f src/libvirt.c) || {
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
echo " top-level libvirt directory"
exit 1
}
if [ "x$1" = x--no-git ]; then
shift
else
git submodule update --init || exit 1
fi
autoreconf --verbose --force --install || exit 1
if test "x$1" = "x--system"; then
shift
prefix=/usr
libdir=$prefix/lib
sysconfdir=/etc
localstatedir=/var
if [ -d /usr/lib64 ]; then
libdir=$prefix/lib64
fi
EXTRA_ARGS="--prefix=$prefix --sysconfdir=$sysconfdir --localstatedir=$localstatedir --libdir=$libdir"
fi
cd "$olddir"
if [ "$NOCONFIGURE" = "" ]; then
$srcdir/configure $EXTRA_ARGS "$@" || exit 1
if [ "$1" = "--help" ]; then
exit 0
else
echo "Now type 'make' to compile libvirt" || exit 1
fi
else
echo "Skipping configure process."
fi

1
config.h Normal file
View File

@ -0,0 +1 @@
#include <meson-config.h>

View File

@ -16,16 +16,7 @@ dnl You should have received a copy of the GNU Lesser General Public
dnl License along with this library. If not, see dnl License along with this library. If not, see
dnl <http://www.gnu.org/licenses/>. dnl <http://www.gnu.org/licenses/>.
AC_INIT([libvirt], [6.7.0], [libvir-list@redhat.com], [], [https://libvirt.org])
if test $srcdir = "."
then
AC_MSG_ERROR([Build directory must be different from source directory])
fi
AC_CONFIG_SRCDIR([src/libvirt.c])
AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h])
AH_BOTTOM([#include <config-post.h>]) AH_BOTTOM([#include <config-post.h>])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
dnl Make automake keep quiet about wildcards & other GNUmake-isms dnl Make automake keep quiet about wildcards & other GNUmake-isms
@ -50,61 +41,6 @@ m4_ifndef([AM_SILENT_RULES],
AC_CANONICAL_HOST AC_CANONICAL_HOST
AC_USE_SYSTEM_EXTENSIONS
# First extract pieces from the version number string
LIBVIRT_MAJOR_VERSION=`echo $VERSION | awk -F. '{print $1}'`
LIBVIRT_MINOR_VERSION=`echo $VERSION | awk -F. '{print $2}'`
LIBVIRT_MICRO_VERSION=`echo $VERSION | awk -F. '{print $3}'`
LIBVIRT_VERSION=$LIBVIRT_MAJOR_VERSION.$LIBVIRT_MINOR_VERSION.$LIBVIRT_MICRO_VERSION$LIBVIRT_MICRO_VERSION_SUFFIX
LIBVIRT_VERSION_NUMBER=`expr $LIBVIRT_MAJOR_VERSION \* 1000000 + $LIBVIRT_MINOR_VERSION \* 1000 + $LIBVIRT_MICRO_VERSION`
# In libtool terminology we need to figure out:
#
# CURRENT
# The most recent interface number that this library implements.
#
# REVISION
# The implementation number of the CURRENT interface.
#
# AGE
# The difference between the newest and oldest interfaces that this
# library implements.
#
# In other words, the library implements all the interface numbers
# in the range from number `CURRENT - AGE' to `CURRENT'.
#
# Libtool assigns the soname version from `CURRENT - AGE', and we
# don't want that to ever change in libvirt. ie it must always be
# zero, to produce libvirt.so.0.
#
# We would, however, like the libvirt version number reflected
# in the so version'd symlinks, and this is based on AGE.REVISION
# eg libvirt.so.0.AGE.REVISION
#
# Assuming we do ever want to break soname version, this can
# toggled. But seriously, don't ever touch this.
LIBVIRT_SONUM=0
# The following examples show what libtool will do
#
# Input: 0.9.14 -> libvirt.so.0.9.14
# Input: 1.0.0 -> libvirt.so.0.1000.0
# Input: 2.5.8 -> libvirt.so.0.2005.8
#
AGE=`expr $LIBVIRT_MAJOR_VERSION '*' 1000 + $LIBVIRT_MINOR_VERSION`
REVISION=$LIBVIRT_MICRO_VERSION
CURRENT=`expr $LIBVIRT_SONUM + $AGE`
LIBVIRT_VERSION_INFO=$CURRENT:$REVISION:$AGE
AC_SUBST([LIBVIRT_MAJOR_VERSION])
AC_SUBST([LIBVIRT_MINOR_VERSION])
AC_SUBST([LIBVIRT_MICRO_VERSION])
AC_SUBST([LIBVIRT_SONUM])
AC_SUBST([LIBVIRT_VERSION])
AC_SUBST([LIBVIRT_VERSION_INFO])
AC_SUBST([LIBVIRT_VERSION_NUMBER])
LIBVIRT_ARG_WITH([PACKAGER], [Extra packager name], [no]) LIBVIRT_ARG_WITH([PACKAGER], [Extra packager name], [no])
LIBVIRT_ARG_WITH([PACKAGER_VERSION], [Extra packager version], [no]) LIBVIRT_ARG_WITH([PACKAGER_VERSION], [Extra packager version], [no])
if test "x$with_packager" != "xno" if test "x$with_packager" != "xno"
@ -126,27 +62,6 @@ AC_PROG_CC
AC_PROG_INSTALL AC_PROG_INSTALL
AC_PROG_CPP AC_PROG_CPP
dnl autoconf 2.70 adds a --runstatedir option so that downstreams
dnl can point to /run instead of the historic /var/run, but
dnl autoconf hasn't had a release since 2012.
if test "x$runstatedir" = x; then
AC_SUBST([runstatedir], ['${localstatedir}/run'])
fi
dnl we introduce --with-runstatedir and then overwrite the
dnl value of $runstatedir so configmake.h is more useful
AC_ARG_WITH(
[runstatedir],
[AS_HELP_STRING(
[--with-runstatedir],
[State directory for temporary sockets, pid files, etc])])
if test -n "$with_runstatedir"
then
runstatedir=$with_runstatedir
fi
dnl get 64-int interfaces on 32-bit platforms dnl get 64-int interfaces on 32-bit platforms
CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64" CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64"
@ -450,17 +365,6 @@ dnl
LIBVIRT_CHECK_EXTERNAL_PROGRAMS LIBVIRT_CHECK_EXTERNAL_PROGRAMS
dnl if --prefix is /usr, don't use /usr/var for localstatedir
dnl or /usr/etc for sysconfdir
dnl as this makes a lot of things break in testing situations
if test "$prefix" = "/usr" && test "$localstatedir" = '${prefix}/var' ; then
localstatedir='/var'
fi
if test "$prefix" = "/usr" && test "$sysconfdir" = '${prefix}/etc' ; then
sysconfdir='/etc'
fi
dnl dnl
dnl Virtualization drivers check dnl Virtualization drivers check
dnl dnl

139
meson.build Normal file
View File

@ -0,0 +1,139 @@
project(
'libvirt', 'c',
version: '6.7.0',
license: 'LGPLv2+',
meson_version: '>= 0.54.0',
default_options: [
'buildtype=debugoptimized',
'c_std=gnu99',
],
)
if not get_option('force_incomplete_build')
error('This commit is part of the meson conversion and does not build a complete libvirt. If bisecting, use "git bisect skip" to continue, or "-Dforce_incomplete_build=true" to perform a partial build.')
endif
# figure out if we are building from git
git = run_command('test', '-d', '.git').returncode() == 0
if git and not get_option('no_git')
run_command('git', 'submodule', 'update', '--init')
endif
# prepare build configuration data
conf = configuration_data()
conf.set('_GNU_SOURCE', 1)
conf.set_quoted('abs_top_builddir', meson.build_root())
conf.set_quoted('abs_top_srcdir', meson.source_root())
conf.set_quoted('PACKAGE', meson.project_name())
conf.set_quoted('PACKAGE_NAME', meson.project_name())
conf.set_quoted('PACKAGE_VERSION', meson.project_version())
conf.set_quoted('VERSION', meson.project_version())
# set various paths
if get_option('system')
prefix = '/usr'
libdir = prefix / 'lib64'
if run_command('test', '-d', libdir).returncode() != 0
libdir = prefix / 'lib'
endif
localstatedir = '/var'
sysconfdir = '/etc'
else
prefix = get_option('prefix')
libdir = prefix / get_option('libdir')
localstatedir = prefix / get_option('localstatedir')
sysconfdir = prefix / get_option('sysconfdir')
endif
# if --prefix is /usr, don't use /usr/var for localstatedir or /usr/etc for
# sysconfdir as this makes a lot of things break in testing situations
if prefix == '/usr'
if localstatedir == '/usr/var'
localstatedir = '/var'
endif
if sysconfdir == '/usr/etc'
sysconfdir = '/etc'
endif
endif
runstatedir = get_option('runstatedir')
if runstatedir == ''
runstatedir = localstatedir / 'run'
endif
bindir = prefix / get_option('bindir')
datadir = prefix / get_option('datadir')
includedir = prefix / get_option('includedir')
infodir = prefix / get_option('infodir')
libexecdir = prefix / get_option('libexecdir')
localedir = prefix / get_option('localedir')
mandir = prefix / get_option('mandir')
sbindir = prefix / get_option('sbindir')
sharedstatedir = prefix / get_option('sharedstatedir')
confdir = sysconfdir / meson.project_name()
docdir = datadir / 'doc' / meson.project_name()
pkgdatadir = datadir / meson.project_name()
# figure out libvirt version strings
arr_version = meson.project_version().split('.')
libvirt_version_number = 1000000 * arr_version[0].to_int() + 1000 * arr_version[1].to_int() + arr_version[2].to_int()
conf.set('LIBVIRT_VERSION_NUMBER', libvirt_version_number)
# In libtool terminology we need to figure out:
#
# CURRENT
# The most recent interface number that this library implements.
#
# REVISION
# The implementation number of the CURRENT interface.
#
# AGE
# The difference between the newest and oldest interfaces that this
# library implements.
#
# In other words, the library implements all the interface numbers
# in the range from number `CURRENT - AGE' to `CURRENT'.
#
# Libtool assigns the soname version from `CURRENT - AGE', and we
# don't want that to ever change in libvirt. ie it must always be
# zero, to produce libvirt.so.0.
#
# We would, however, like the libvirt version number reflected
# in the so version'd symlinks, and this is based on AGE.REVISION
# eg libvirt.so.0.AGE.REVISION
#
# The following examples show what libtool will do
#
# Input: 0.9.14 -> libvirt.so.0.9.14
# Input: 1.0.0 -> libvirt.so.0.1000.0
# Input: 2.5.8 -> libvirt.so.0.2005.8
#
# Assuming we do ever want to break soname version, this can
# toggled. But seriously, don't ever touch this.
libvirt_so_version = 0
libvirt_age = 1000 * arr_version[0].to_int() + arr_version[1].to_int()
libvirt_revision = arr_version[2].to_int()
libvirt_lib_version = '@0@.@1@.@2@'.format(libvirt_so_version, libvirt_age, libvirt_revision)
# define top include directory
top_inc_dir = include_directories('.')
# generate meson-config.h file
configure_file(output: 'meson-config.h', configuration: conf)

4
meson_options.txt Normal file
View File

@ -0,0 +1,4 @@
option('force_incomplete_build', type: 'boolean', value: false, description: 'Meson setup fails by default until the rewrite to meson is done, set this to "true" to force the build.')
option('no_git', type: 'boolean', value: false, description: 'Disable git submodule update')
option('system', type: 'boolean', value: false, description: 'Set install paths to system ones')
option('runstatedir', type: 'string', value: '', description: 'State directory for temporary sockets, pid files, etc')