2 # SPDX-License-Identifier: BSD-3-Clause
3 # Copyright(c) 2018 Intel Corporation
5 # Run meson to auto-configure the various builds.
6 # * all builds get put in a directory whose name starts with "build-"
7 # * if a build-directory already exists we assume it was properly configured
8 # Run ninja after configuration is done.
10 # set pipefail option if possible
12 set -o | grep -q pipefail && set -o pipefail && PIPEFAIL=1
14 srcdir=$(dirname $(readlink -f $0))/..
16 use_shared="--default-library=shared"
18 if command -v ninja >/dev/null 2>&1 ; then
20 elif command -v ninja-build >/dev/null 2>&1 ; then
23 echo "ERROR: ninja is not found" >&2
27 build () # <directory> <meson options>
31 if command -v $CC >/dev/null 2>&1 ; then
32 if [ ! -f "$builddir/build.ninja" ] ; then
33 options="--werror -Dexamples=all $*"
34 echo "$MESON $options $srcdir $builddir"
35 $MESON $options $srcdir $builddir
38 if [ -n "$TEST_MESON_BUILD_VERY_VERBOSE" ] ; then
39 # for full output from ninja use "-v"
40 echo "$ninja_cmd -v -C $builddir"
41 $ninja_cmd -v -C $builddir
42 elif [ -n "$TEST_MESON_BUILD_VERBOSE" ] ; then
43 # for keeping the history of short cmds, pipe through cat
44 echo "$ninja_cmd -C $builddir | cat"
45 $ninja_cmd -C $builddir | cat
47 echo "$ninja_cmd -C $builddir"
48 $ninja_cmd -C $builddir
53 if [ "$1" = "-vv" ] ; then
54 TEST_MESON_BUILD_VERY_VERBOSE=1
55 elif [ "$1" = "-v" ] ; then
56 TEST_MESON_BUILD_VERBOSE=1
58 # we can't use plain verbose when we don't have pipefail option so up-level
59 if [ -z "$PIPEFAIL" -a -n "$TEST_MESON_BUILD_VERBOSE" ] ; then
60 echo "# Missing pipefail shell option, changing VERBOSE to VERY_VERBOSE"
61 TEST_MESON_BUILD_VERY_VERBOSE=1
64 # shared and static linked builds with gcc and clang
65 for c in gcc clang ; do
66 command -v $c >/dev/null 2>&1 || continue
67 for s in static shared ; do
69 build build-$c-$s --default-library=$s
73 # test compilation with minimal x86 instruction set
74 default_machine='nehalem'
75 ok=$(cc -march=$default_machine -E - < /dev/null > /dev/null 2>&1 || echo false)
76 if [ "$ok" = "false" ] ; then
77 default_machine='corei7'
79 build build-x86-default -Dmachine=$default_machine $use_shared
81 # enable cross compilation if gcc cross-compiler is found
82 c=aarch64-linux-gnu-gcc
83 if command -v $c >/dev/null 2>&1 ; then
84 # compile the general v8a also for clang to increase coverage
86 build build-arm64-host-clang $use_shared \
87 --cross-file $srcdir/config/arm/arm64_armv8_linux_gcc
89 for f in $srcdir/config/arm/arm*gcc ; do
90 export CC="ccache gcc"
91 build build-$(basename $f | tr '_' '-' | cut -d'-' -f-2) \
92 $use_shared --cross-file $f