Build: Add support for shared libraries and versioning.
[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.16.2.tar.gz
11     tar xzvf linux-3.16.2.tar.gz > /dev/null
12     cd linux-3.16.2
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.1.tar.gz
23     tar xzvf dpdk-1.7.1.tar.gz > /dev/null
24     cd dpdk-1.7.1
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     sed -ri '/CONFIG_RTE_LIBNAME/a CONFIG_RTE_BUILD_FPIC=y' config/common_linuxapp
28     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
29     make config CC=gcc T=x86_64-native-linuxapp-gcc
30     make CC=gcc RTE_KERNELDIR=$KERNELSRC
31     echo "Installed DPDK source in $(pwd)"
32     cd ..
33 }
34
35 function configure_ovs()
36 {
37     ./boot.sh && ./configure $*
38 }
39
40 if [ "$KERNEL" ] || [ "$DPDK" ]; then
41     install_kernel
42 fi
43
44 if [ "$DPDK" ]; then
45     install_dpdk
46     # Disregard bad function cassts until DPDK is fixed
47     CFLAGS="$CFLAGS -Wno-error=bad-function-cast -Wno-error=cast-align"
48 elif [ $CC != "clang" ]; then
49     # DPDK headers currently trigger sparse errors
50     CFLAGS="$CFLAGS -Wsparse-error"
51 fi
52
53 configure_ovs $*
54
55
56 if [ $CC = "clang" ]; then
57     make CFLAGS="$CFLAGS -Wno-error=unused-command-line-argument"
58 else
59     make CFLAGS="$CFLAGS" C=1
60 fi
61
62 if [ $TESTSUITE ]; then
63     if ! make distcheck; then
64         # testsuite.log is necessary for debugging.
65         cat */_build/tests/testsuite.log
66         exit 1
67     fi
68 fi
69
70 exit 0