travis: Allow testsuite to run with GCC or Clang.
[cascardo/ovs.git] / .travis / build.sh
1 #!/bin/bash
2
3 set -o errexit
4
5 KERNELSRC=""
6 CFLAGS="-Werror"
7
8 function install_kernel()
9 {
10     wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.14.7.tar.gz
11     tar xzvf linux-3.14.7.tar.gz > /dev/null
12     cd linux-3.14.7
13     make allmodconfig
14     make net/openvswitch/
15     KERNELSRC=$(pwd)
16     echo "Installed kernel source in $(pwd)"
17     cd ..
18 }
19
20 function install_dpdk()
21 {
22     wget http://www.dpdk.org/browse/dpdk/snapshot/dpdk-1.7.0.tar.gz
23     tar xzvf dpdk-1.7.0.tar.gz > /dev/null
24     cd dpdk-1.7.0
25     find ./ -type f | xargs sed -i 's/max-inline-insns-single=100/max-inline-insns-single=400/'
26     sed -ri 's,(CONFIG_RTE_BUILD_COMBINE_LIBS=).*,\1y,' config/common_linuxapp
27     make config CC=gcc T=x86_64-native-linuxapp-gcc
28     make CC=gcc RTE_KERNELDIR=$KERNELSRC
29     echo "Installed DPDK source in $(pwd)"
30     cd ..
31 }
32
33 function configure_ovs()
34 {
35     ./boot.sh && ./configure $*
36 }
37
38 if [ "$KERNEL" ] || [ "$DPDK" ]; then
39     install_kernel
40 fi
41
42 [ "$DPDK" ] && {
43     install_dpdk
44     # Disregard bad function cassts until DPDK is fixed
45     CFLAGS="$CFLAGS -Wno-error=bad-function-cast -Wno-error=cast-align"
46 }
47
48 configure_ovs $*
49
50
51 if [ $CC = "clang" ]; then
52     make CFLAGS="$CFLAGS -Wno-error=unused-command-line-argument"
53 else
54     make CFLAGS="$CFLAGS" C=1
55 fi
56
57 if [ $TESTSUITE ]; then
58     if ! make distcheck; then
59         # testsuite.log is necessary for debugging.
60         cat */_build/tests/testsuite.log
61         exit 1
62     fi
63 fi
64
65 exit 0