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 [ ! -f "$builddir/build.ninja" ] ; then
32 options="--werror -Dexamples=all $*"
33 echo "$MESON $options $srcdir $builddir"
34 $MESON $options $srcdir $builddir
37 if [ -n "$TEST_MESON_BUILD_VERY_VERBOSE" ] ; then
38 # for full output from ninja use "-v"
39 echo "$ninja_cmd -v -C $builddir"
40 $ninja_cmd -v -C $builddir
41 elif [ -n "$TEST_MESON_BUILD_VERBOSE" ] ; then
42 # for keeping the history of short cmds, pipe through cat
43 echo "$ninja_cmd -C $builddir | cat"
44 $ninja_cmd -C $builddir | cat
46 echo "$ninja_cmd -C $builddir"
47 $ninja_cmd -C $builddir
51 if [ "$1" = "-vv" ] ; then
52 TEST_MESON_BUILD_VERY_VERBOSE=1
53 elif [ "$1" = "-v" ] ; then
54 TEST_MESON_BUILD_VERBOSE=1
56 # we can't use plain verbose when we don't have pipefail option so up-level
57 if [ -z "$PIPEFAIL" -a -n "$TEST_MESON_BUILD_VERBOSE" ] ; then
58 echo "# Missing pipefail shell option, changing VERBOSE to VERY_VERBOSE"
59 TEST_MESON_BUILD_VERY_VERBOSE=1
62 # shared and static linked builds with gcc and clang
63 for c in gcc clang ; do
64 command -v $c >/dev/null 2>&1 || continue
65 for s in static shared ; do
67 build build-$c-$s --default-library=$s
71 # test compilation with minimal x86 instruction set
72 default_machine='nehalem'
73 ok=$(cc -march=$default_machine -E - < /dev/null > /dev/null 2>&1 || echo false)
74 if [ "$ok" = "false" ] ; then
75 default_machine='corei7'
77 build build-x86-default -Dmachine=$default_machine $use_shared
79 # enable cross compilation if gcc cross-compiler is found
80 c=aarch64-linux-gnu-gcc
81 if command -v $c >/dev/null 2>&1 ; then
82 # compile the general v8a also for clang to increase coverage
83 export CC="ccache clang"
84 build build-arm64-host-clang $use_shared \
85 --cross-file $srcdir/config/arm/arm64_armv8_linux_gcc
87 for f in $srcdir/config/arm/arm*gcc ; do
88 export CC="ccache gcc"
89 build build-$(basename $f | tr '_' '-' | cut -d'-' -f-2) \
90 $use_shared --cross-file $f