818508fa00ad0b35c43961568fab16ebef358400
[sip-router] / test / travis / build_travis.sh
1 #!/bin/bash
2 #
3 # build script for travis CI
4 # environment based docker container at
5 # https://hub.docker.com/r/kamailio/pkg-kamailio-docker/
6 #
7
8 set -e
9
10 DIST=${DIST:-stretch}
11 CC=${CC:-gcc}
12
13 if ! [ -d /code/pkg/kamailio/deb/"${DIST}" ] ; then
14         echo "${DIST} not supported"
15         exit 1
16 else
17         rm -rf /code/debian
18         ln -s /code/pkg/kamailio/deb/"${DIST}" /code/debian
19 fi
20
21 function _clean {
22         echo "make clean"
23         make -f debian/rules clean
24 }
25
26 function _build {
27         echo "make build"
28         make -f debian/rules build
29 }
30
31 function _install {
32         if [[ "$CC" =~ gcc ]] ; then
33                 echo "make install"
34                 make install
35         else
36                 echo "skip make install step"
37         fi
38 }
39
40 if [[ "${CC}" =~ clang ]] ; then
41         CLANG=$(find /usr/bin -type l -name 'clang-[0-9]*' | sort -r | head -1)
42         echo "setting clang to ${CLANG}"
43         update-alternatives --install /usr/bin/clang clang "${CLANG}" 1
44 fi
45
46 echo "environment DIST=$DIST CC=$CC"
47 ${CC} --version
48
49 _clean
50 _build
51 _install