netdev-dpdk: fix mbuf leaks
[cascardo/ovs.git] / .travis / build.sh
1 #!/bin/bash
2
3 set -o errexit
4
5 KERNELSRC=""
6 CFLAGS="-Werror"
7 SPARSE_FLAGS=""
8 EXTRA_OPTS=""
9
10 function install_kernel()
11 {
12     if [[ "$1" =~ ^4.* ]]; then
13         PREFIX="v4.x"
14     elif [[ "$1" =~ ^3.* ]]; then
15         PREFIX="v3.x"
16     else
17         PREFIX="v2.6/longterm/v2.6.32"
18     fi
19
20     wget https://www.kernel.org/pub/linux/kernel/${PREFIX}/linux-${1}.tar.gz
21     tar xzvf linux-${1}.tar.gz > /dev/null
22     cd linux-${1}
23     make allmodconfig
24
25     # Older kernels do not include openvswitch
26     if [ -d "net/openvswitch" ]; then
27         make net/openvswitch/
28     else
29         make net/bridge/
30     fi
31
32     KERNELSRC=$(pwd)
33     if [ ! "$DPDK" ]; then
34         EXTRA_OPTS="--with-linux=$(pwd)"
35     fi
36     echo "Installed kernel source in $(pwd)"
37     cd ..
38 }
39
40 function install_dpdk()
41 {
42     if [ -n "$DPDK_GIT" ]; then
43         git clone $DPDK_GIT dpdk-$1
44         cd dpdk-$1
45         git checkout v$1
46     else
47         wget http://www.dpdk.org/browse/dpdk/snapshot/dpdk-$1.tar.gz
48         tar xzvf dpdk-$1.tar.gz > /dev/null
49         cd dpdk-$1
50     fi
51     find ./ -type f | xargs sed -i 's/max-inline-insns-single=100/max-inline-insns-single=400/'
52     sed -ri 's,(CONFIG_RTE_BUILD_COMBINE_LIBS=).*,\1y,' config/common_linuxapp
53     echo 'CONFIG_RTE_BUILD_FPIC=y' >>config/common_linuxapp
54     sed -ri '/EXECENV_CFLAGS  = -pthread -fPIC/{s/$/\nelse ifeq ($(CONFIG_RTE_BUILD_FPIC),y)/;s/$/\nEXECENV_CFLAGS  = -pthread -fPIC/}' mk/exec-env/linuxapp/rte.vars.mk
55     make config CC=gcc T=x86_64-native-linuxapp-gcc
56     make CC=gcc RTE_KERNELDIR=$KERNELSRC
57     echo "Installed DPDK source in $(pwd)"
58     cd ..
59 }
60
61 function configure_ovs()
62 {
63     ./boot.sh && ./configure $*
64 }
65
66 if [ "$KERNEL" ] || [ "$DPDK" ]; then
67     install_kernel $KERNEL
68 fi
69
70 if [ "$DPDK" ]; then
71     if [ -z "$DPDK_VER" ]; then
72         DPDK_VER="2.2.0"
73     fi
74     install_dpdk $DPDK_VER
75     if [ "$CC" = "clang" ]; then
76         # Disregard cast alignment errors until DPDK is fixed
77         CFLAGS="$CFLAGS -Wno-cast-align"
78     fi
79     EXTRA_OPTS="$EXTRA_OPTS --with-dpdk=./dpdk-$DPDK_VER/build"
80 elif [ "$CC" != "clang" ]; then
81     # DPDK headers currently trigger sparse errors
82     SPARSE_FLAGS="$SPARSE_FLAGS -Wsparse-error"
83 fi
84
85 configure_ovs $EXTRA_OPTS $*
86
87 # Only build datapath if we are testing kernel w/o running testsuite
88 if [ "$KERNEL" ] && [ ! "$TESTSUITE" ] && [ ! "$DPDK" ]; then
89     cd datapath
90 fi
91
92 if [ "$CC" = "clang" ]; then
93     make CFLAGS="$CFLAGS -Wno-error=unused-command-line-argument"
94 elif [[ $BUILD_ENV =~ "-m32" ]]; then
95     # Disable sparse for 32bit builds on 64bit machine
96     make CFLAGS="$CFLAGS $BUILD_ENV"
97 else
98     make CFLAGS="$CFLAGS $BUILD_ENV $SPARSE_FLAGS" C=1
99 fi
100
101 if [ "$TESTSUITE" ] && [ "$CC" != "clang" ]; then
102     if ! make distcheck RECHECK=yes; then
103         # testsuite.log is necessary for debugging.
104         cat */_build/tests/testsuite.log
105         exit 1
106     fi
107 fi
108
109 exit 0