New upstream version 18.08
[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 -m $0))/..
11 MESON=${MESON:-meson}
12
13 if command -v ninja >/dev/null 2>&1 ; then
14         ninja_cmd=ninja
15 elif command -v ninja-build >/dev/null 2>&1 ; then
16         ninja_cmd=ninja-build
17 else
18         echo "ERROR: ninja is not found" >&2
19         exit 1
20 fi
21
22 build () # <directory> <meson options>
23 {
24         builddir=$1
25         shift
26         if [ ! -d "$builddir" ] ; then
27                 options="--werror -Dexamples=all $*"
28                 echo "$MESON $options $srcdir $builddir"
29                 $MESON $options $srcdir $builddir
30                 unset CC
31         fi
32         echo "$ninja_cmd -C $builddir"
33         $ninja_cmd -C $builddir
34 }
35
36 # shared and static linked builds with gcc and clang
37 for c in gcc clang ; do
38         for s in static shared ; do
39                 export CC="ccache $c"
40                 build build-$c-$s --default-library=$s
41         done
42 done
43
44 # test compilation with minimal x86 instruction set
45 build build-x86-default -Dmachine=nehalem
46
47 # enable cross compilation if gcc cross-compiler is found
48 c=aarch64-linux-gnu-gcc
49 if command -v $c >/dev/null 2>&1 ; then
50         # compile the general v8a also for clang to increase coverage
51         export CC="ccache clang"
52         build build-arm64-host-clang --cross-file \
53                 config/arm/arm64_armv8_linuxapp_gcc
54
55         for f in config/arm/arm*gcc ; do
56                 export CC="ccache gcc"
57                 build build-$(basename $f | tr '_' '-' | cut -d'-' -f-2) \
58                         --cross-file $f
59         done
60 fi