Update the build-api compatibility script
Allow running:
./configure
make
make install
from the source directory, just like autotools would.
# configure script adapter for Meson
# Based on build-api: https://github.com/cgwalters/build-api
# Copyright 2010, 2011, 2013 Colin Walters <walters@verbum.org>
-# Copyright 2016 Emmanuele Bassi
+# Copyright 2016, 2017 Emmanuele Bassi
# Licensed under the new-BSD license (http://www.opensource.org/licenses/bsd-license.php)
# Build API variables:
-# buildapi-variable-require-builddir
# Little helper function for reading args from the commandline.
# it automatically handles -a b and -a=b variants, and returns 1 if
@@ -52,12 +51,13 @@ sanitycheck() {
exit 1
}
-
sanitycheck MESON 'meson'
+sanitycheck MESONTEST 'mesontest'
sanitycheck NINJA 'ninja' 'ninja-build'
enable_docs='-Denable-gtk-doc=false'
-enable_introspection='-Denable-introspection=true'
+enable_man='-Denable-man=false'
+enable_introspection=''
while (($# > 0)); do
case "${1%%=*}" in
@@ -73,8 +73,10 @@ while (($# > 0)); do
--includedir) read_arg includedir "$@" || shift;;
--enable-gtk-doc) enable_docs='-Denable-gtk-doc=true';;
--disable-gtk-doc) enable_docs='-Denable-gtk-doc=false';;
- --enable-introspection) enable_introspection='-Denable-introspection=true';;
- --disable-introspection) enable_introspection='-Denable-introspection=false';;
+ --enable-man) enable_man='-Denable-man=true';;
+ --disable-man) enable_man='-Denable-man=false';;
+ --enable-introspection) enable_introspection='';;
+ --disable-introspection) enable_introspection='-Ddisable_introspection=true';;
*) echo -e "\e[1;33mINFO\e[0m: Ignoring unknown option '$1'";;
esac
shift
@@ -95,15 +97,31 @@ test -z ${includedir} && includedir=${prefix}/include
# The source directory is the location of this file
srcdir=$(dirname $0)
+# The build directory is the current location
+builddir=`pwd`
+
+# If we're calling this file from the source directory then
+# we automatically create a build directory and ensure that
+# both Meson and Ninja invocations are relative to that
+# location
+if [[ -f "${builddir}/meson.build" ]]; then
+ mkdir -p _build
+ builddir="${builddir}/_build"
+ NINJA_OPT="-C ${builddir}"
+fi
+
# Wrapper Makefile for Ninja
cat > Makefile <<END
# Generated by configure; do not edit
all:
- CC="\$(CC)" CXX="\$(CXX)" ${NINJA}
+ CC="\$(CC)" CXX="\$(CXX)" ${NINJA} ${NINJA_OPT}
install:
- DESTDIR="\$(DESTDIR)" ${NINJA} install
+ DESTDIR="\$(DESTDIR)" ${NINJA} ${NINJA_OPT} install
+
+check:
+ ${MESONTEST} ${NINJA_OPT}
END
echo "Summary:"
@@ -135,6 +153,7 @@ exec ${MESON} \
${enable_docs} \
${enable_man} \
${enable_introspection} \
+ ${builddir} \
${srcdir}
# vim: ai ts=8 noet sts=2 ft=sh
