+install_target () # <builddir> <installdir>
+{
+ rm -rf $2
+ if [ -n "$TEST_MESON_BUILD_VERY_VERBOSE$TEST_MESON_BUILD_VERBOSE" ]; then
+ echo "DESTDIR=$2 $ninja_cmd -C $1 install"
+ DESTDIR=$2 $ninja_cmd -C $1 install
+ else
+ echo "DESTDIR=$2 $ninja_cmd -C $1 install >/dev/null"
+ DESTDIR=$2 $ninja_cmd -C $1 install >/dev/null
+ fi
+}
+
+build () # <directory> <target compiler | cross file> <meson options>
+{
+ targetdir=$1
+ shift
+ crossfile=
+ [ -r $1 ] && crossfile=$1 || targetcc=$1
+ shift
+ # skip build if compiler not available
+ command -v ${CC##* } >/dev/null 2>&1 || return 0
+ if [ -n "$crossfile" ] ; then
+ cross="--cross-file $crossfile"
+ targetcc=$(sed -n 's,^c[[:space:]]*=[[:space:]]*,,p' \
+ $crossfile | tr -d "'" | tr -d '"')
+ else
+ cross=
+ fi
+ load_env $targetcc || return 0
+ config $srcdir $builds_dir/$targetdir $cross --werror $*
+ compile $builds_dir/$targetdir
+ if [ -n "$DPDK_ABI_REF_VERSION" ]; then
+ abirefdir=${DPDK_ABI_REF_DIR:-reference}/$DPDK_ABI_REF_VERSION
+ if [ ! -d $abirefdir/$targetdir ]; then
+ # clone current sources
+ if [ ! -d $abirefdir/src ]; then
+ git clone --local --no-hardlinks \
+ --single-branch \
+ -b $DPDK_ABI_REF_VERSION \
+ $srcdir $abirefdir/src
+ fi
+
+ rm -rf $abirefdir/build
+ config $abirefdir/src $abirefdir/build $cross \
+ -Dexamples= $*
+ compile $abirefdir/build
+ install_target $abirefdir/build $abirefdir/$targetdir
+ $srcdir/devtools/gen-abi.sh $abirefdir/$targetdir
+
+ # save disk space by removing static libs and apps
+ find $abirefdir/$targetdir/usr/local -name '*.a' -delete
+ rm -rf $abirefdir/$targetdir/usr/local/bin
+ rm -rf $abirefdir/$targetdir/usr/local/share
+ fi
+
+ install_target $builds_dir/$targetdir \
+ $(readlink -f $builds_dir/$targetdir/install)
+ $srcdir/devtools/gen-abi.sh \
+ $(readlink -f $builds_dir/$targetdir/install)
+ $srcdir/devtools/check-abi.sh $abirefdir/$targetdir \
+ $(readlink -f $builds_dir/$targetdir/install)
+ fi
+}
+