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# set pipefail option if possible 11PIPEFAIL="" 12set -o | grep -q pipefail && set -o pipefail && PIPEFAIL=1 13 14srcdir=$(dirname $(readlink -f $0))/.. 15MESON=${MESON:-meson} 16use_shared="--default-library=shared" 17 18if command -v gmake >/dev/null 2>&1 ; then 19 MAKE=gmake 20else 21 MAKE=make 22fi 23if command -v ninja >/dev/null 2>&1 ; then 24 ninja_cmd=ninja 25elif command -v ninja-build >/dev/null 2>&1 ; then 26 ninja_cmd=ninja-build 27else 28 echo "ERROR: ninja is not found" >&2 29 exit 1 30fi 31 32default_path=$PATH 33default_pkgpath=$PKG_CONFIG_PATH 34 35reset_env () 36{ 37 export PATH=$default_path 38 export PKG_CONFIG_PATH=$default_pkgpath 39 unset DPDK_MESON_OPTIONS 40} 41 42build () # <directory> <target compiler> <meson options> 43{ 44 builddir=$1 45 shift 46 targetcc=$1 47 shift 48 # skip build if compiler not available 49 command -v $CC >/dev/null 2>&1 || return 0 50 command -v $targetcc >/dev/null 2>&1 || return 0 51 reset_env 52 DPDK_TARGET=$($targetcc -v 2>&1 | sed -n 's,^Target: ,,p') 53 . $srcdir/devtools/load-devel-config 54 if [ ! -f "$builddir/build.ninja" ] ; then 55 options="--werror -Dexamples=all" 56 for option in $DPDK_MESON_OPTIONS ; do 57 options="$options -D$option" 58 done 59 options="$options $*" 60 echo "$MESON $options $srcdir $builddir" 61 $MESON $options $srcdir $builddir 62 unset CC 63 fi 64 if [ -n "$TEST_MESON_BUILD_VERY_VERBOSE" ] ; then 65 # for full output from ninja use "-v" 66 echo "$ninja_cmd -v -C $builddir" 67 $ninja_cmd -v -C $builddir 68 elif [ -n "$TEST_MESON_BUILD_VERBOSE" ] ; then 69 # for keeping the history of short cmds, pipe through cat 70 echo "$ninja_cmd -C $builddir | cat" 71 $ninja_cmd -C $builddir | cat 72 else 73 echo "$ninja_cmd -C $builddir" 74 $ninja_cmd -C $builddir 75 fi 76} 77 78if [ "$1" = "-vv" ] ; then 79 TEST_MESON_BUILD_VERY_VERBOSE=1 80elif [ "$1" = "-v" ] ; then 81 TEST_MESON_BUILD_VERBOSE=1 82fi 83# we can't use plain verbose when we don't have pipefail option so up-level 84if [ -z "$PIPEFAIL" -a -n "$TEST_MESON_BUILD_VERBOSE" ] ; then 85 echo "# Missing pipefail shell option, changing VERBOSE to VERY_VERBOSE" 86 TEST_MESON_BUILD_VERY_VERBOSE=1 87fi 88 89# shared and static linked builds with gcc and clang 90for c in gcc clang ; do 91 command -v $c >/dev/null 2>&1 || continue 92 for s in static shared ; do 93 export CC="ccache $c" 94 build build-$c-$s $c --default-library=$s 95 done 96done 97 98# test compilation with minimal x86 instruction set 99# Set the install path for libraries to "lib" explicitly to prevent problems 100# with pkg-config prefixes if installed in "lib/x86_64-linux-gnu" later. 101default_machine='nehalem' 102ok=$(cc -march=$default_machine -E - < /dev/null > /dev/null 2>&1 || echo false) 103if [ "$ok" = "false" ] ; then 104 default_machine='corei7' 105fi 106build build-x86-default cc -Dlibdir=lib -Dmachine=$default_machine $use_shared 107 108c=aarch64-linux-gnu-gcc 109# generic armv8a with clang as host compiler 110export CC="clang" 111build build-arm64-host-clang $c $use_shared \ 112 --cross-file $srcdir/config/arm/arm64_armv8_linux_gcc 113# all gcc/arm configurations 114for f in $srcdir/config/arm/arm*gcc ; do 115 export CC="ccache gcc" 116 build build-$(basename $f | tr '_' '-' | cut -d'-' -f-2) $c \ 117 $use_shared --cross-file $f 118done 119 120# Test installation of the x86-default target, to be used for checking 121# the sample apps build using the pkg-config file for cflags and libs 122build_path=build-x86-default 123export DESTDIR=$(pwd)/$build_path/install-root 124$ninja_cmd -C $build_path install 125 126pc_file=$(find $DESTDIR -name libdpdk.pc) 127export PKG_CONFIG_PATH=$(dirname $pc_file):$PKG_CONFIG_PATH 128 129for example in cmdline helloworld l2fwd l3fwd skeleton timer; do 130 echo "## Building $example" 131 $MAKE -C $DESTDIR/usr/local/share/dpdk/examples/$example clean all 132done 133