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))/..
15 . $srcdir/devtools/load-devel-config
18 use_shared="--default-library=shared"
19 builds_dir=${DPDK_BUILD_TEST_DIR:-.}
21 if command -v gmake >/dev/null 2>&1 ; then
26 if command -v ninja >/dev/null 2>&1 ; then
28 elif command -v ninja-build >/dev/null 2>&1 ; then
31 echo "ERROR: ninja is not found" >&2
34 if command -v ccache >/dev/null 2>&1 ; then
41 default_pkgpath=$PKG_CONFIG_PATH
42 default_cppflags=$CPPFLAGS
43 default_cflags=$CFLAGS
44 default_ldflags=$LDFLAGS
46 load_env () # <target compiler>
49 export PATH=$default_path
50 export PKG_CONFIG_PATH=$default_pkgpath
51 export CPPFLAGS=$default_cppflags
52 export CFLAGS=$default_cflags
53 export LDFLAGS=$default_ldflags
54 unset DPDK_MESON_OPTIONS
55 command -v $targetcc >/dev/null 2>&1 || return 1
56 DPDK_TARGET=$($targetcc -v 2>&1 | sed -n 's,^Target: ,,p')
57 . $srcdir/devtools/load-devel-config
60 build () # <directory> <target compiler> <meson options>
62 builddir=$builds_dir/$1
66 # skip build if compiler not available
67 command -v ${CC##* } >/dev/null 2>&1 || return 0
68 load_env $targetcc || return 0
69 if [ ! -f "$builddir/build.ninja" ] ; then
70 options="--werror -Dexamples=all"
71 for option in $DPDK_MESON_OPTIONS ; do
72 options="$options -D$option"
75 echo "$MESON $options $srcdir $builddir"
76 $MESON $options $srcdir $builddir
79 if [ -n "$TEST_MESON_BUILD_VERY_VERBOSE" ] ; then
80 # for full output from ninja use "-v"
81 echo "$ninja_cmd -v -C $builddir"
82 $ninja_cmd -v -C $builddir
83 elif [ -n "$TEST_MESON_BUILD_VERBOSE" ] ; then
84 # for keeping the history of short cmds, pipe through cat
85 echo "$ninja_cmd -C $builddir | cat"
86 $ninja_cmd -C $builddir | cat
88 echo "$ninja_cmd -C $builddir"
89 $ninja_cmd -C $builddir
93 if [ "$1" = "-vv" ] ; then
94 TEST_MESON_BUILD_VERY_VERBOSE=1
95 elif [ "$1" = "-v" ] ; then
96 TEST_MESON_BUILD_VERBOSE=1
98 # we can't use plain verbose when we don't have pipefail option so up-level
99 if [ -z "$PIPEFAIL" -a -n "$TEST_MESON_BUILD_VERBOSE" ] ; then
100 echo "# Missing pipefail shell option, changing VERBOSE to VERY_VERBOSE"
101 TEST_MESON_BUILD_VERY_VERBOSE=1
104 # shared and static linked builds with gcc and clang
105 for c in gcc clang ; do
106 command -v $c >/dev/null 2>&1 || continue
107 for s in static shared ; do
108 export CC="$CCACHE $c"
109 build build-$c-$s $c --default-library=$s
113 # test compilation with minimal x86 instruction set
114 # Set the install path for libraries to "lib" explicitly to prevent problems
115 # with pkg-config prefixes if installed in "lib/x86_64-linux-gnu" later.
116 default_machine='nehalem'
117 ok=$(cc -march=$default_machine -E - < /dev/null > /dev/null 2>&1 || echo false)
118 if [ "$ok" = "false" ] ; then
119 default_machine='corei7'
121 build build-x86-default cc -Dlibdir=lib -Dmachine=$default_machine $use_shared
123 c=aarch64-linux-gnu-gcc
124 # generic armv8a with clang as host compiler
126 build build-arm64-host-clang $c $use_shared \
127 --cross-file $srcdir/config/arm/arm64_armv8_linux_gcc
128 # all gcc/arm configurations
129 for f in $srcdir/config/arm/arm64_[bdo]*gcc ; do
130 export CC="$CCACHE gcc"
131 build build-$(basename $f | tr '_' '-' | cut -d'-' -f-2) $c \
132 $use_shared --cross-file $f
135 # Test installation of the x86-default target, to be used for checking
136 # the sample apps build using the pkg-config file for cflags and libs
137 build_path=$(readlink -f $builds_dir/build-x86-default)
138 export DESTDIR=$build_path/install-root
139 $ninja_cmd -C $build_path install
142 pc_file=$(find $DESTDIR -name libdpdk.pc)
143 export PKG_CONFIG_PATH=$(dirname $pc_file):$PKG_CONFIG_PATH
145 # if pkg-config defines the necessary flags, test building some examples
146 if pkg-config --define-prefix libdpdk >/dev/null 2>&1; then
147 export PKGCONF="pkg-config --define-prefix"
148 for example in cmdline helloworld l2fwd l3fwd skeleton timer; do
149 echo "## Building $example"
150 $MAKE -C $DESTDIR/usr/local/share/dpdk/examples/$example clean all