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 srcdir=$(dirname $(readlink -f $0))/..
12 use_shared="--default-library=shared"
14 if command -v ninja >/dev/null 2>&1 ; then
16 elif command -v ninja-build >/dev/null 2>&1 ; then
19 echo "ERROR: ninja is not found" >&2
23 build () # <directory> <meson options>
27 if [ ! -f "$builddir/build.ninja" ] ; then
28 options="--werror -Dexamples=all $*"
29 echo "$MESON $options $srcdir $builddir"
30 $MESON $options $srcdir $builddir
33 echo "$ninja_cmd -C $builddir"
34 $ninja_cmd -C $builddir
37 # shared and static linked builds with gcc and clang
38 for c in gcc clang ; do
39 command -v $c >/dev/null 2>&1 || continue
40 for s in static shared ; do
42 build build-$c-$s --default-library=$s
46 # test compilation with minimal x86 instruction set
47 default_machine='nehalem'
48 ok=$(cc -march=$default_machine -E - < /dev/null > /dev/null 2>&1 || echo false)
49 if [ "$ok" = "false" ] ; then
50 default_machine='corei7'
52 build build-x86-default -Dmachine=$default_machine $use_shared
54 # enable cross compilation if gcc cross-compiler is found
55 c=aarch64-linux-gnu-gcc
56 if command -v $c >/dev/null 2>&1 ; then
57 # compile the general v8a also for clang to increase coverage
58 export CC="ccache clang"
59 build build-arm64-host-clang $use_shared \
60 --cross-file config/arm/arm64_armv8_linuxapp_gcc
62 for f in config/arm/arm*gcc ; do
63 export CC="ccache gcc"
64 build build-$(basename $f | tr '_' '-' | cut -d'-' -f-2) \
65 $use_shared --cross-file $f