New upstream version 18.11.2
[deb_dpdk.git] / devtools / test-meson-builds.sh
1 #! /bin/sh -e
2 # SPDX-License-Identifier: BSD-3-Clause
3 # Copyright(c) 2018 Intel Corporation
4
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.
9
10 srcdir=$(dirname $(readlink -f $0))/..
11 MESON=${MESON:-meson}
12 use_shared="--default-library=shared"
13
14 if command -v ninja >/dev/null 2>&1 ; then
15         ninja_cmd=ninja
16 elif command -v ninja-build >/dev/null 2>&1 ; then
17         ninja_cmd=ninja-build
18 else
19         echo "ERROR: ninja is not found" >&2
20         exit 1
21 fi
22
23 build () # <directory> <meson options>
24 {
25         builddir=$1
26         shift
27         if [ ! -f "$builddir/build.ninja" ] ; then
28                 options="--werror -Dexamples=all $*"
29                 echo "$MESON $options $srcdir $builddir"
30                 $MESON $options $srcdir $builddir
31                 unset CC
32         fi
33         echo "$ninja_cmd -C $builddir"
34         $ninja_cmd -C $builddir
35 }
36
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
41                 export CC="ccache $c"
42                 build build-$c-$s --default-library=$s
43         done
44 done
45
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'
51 fi
52 build build-x86-default -Dmachine=$default_machine $use_shared
53
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
61
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
66         done
67 fi