jjb: Add coverity job to latency-tracker
[lttng-ci.git] / scripts / lttng-ust / build.sh
CommitLineData
3b3282a6 1#!/bin/bash -exu
2b68721a 2#
1f4fba8c
MJ
3# Copyright (C) 2015, Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4# 2016, Michael Jeanson <mjeanson@efficios.com>
2b68721a
MJ
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19
c3bc676b 20# liburcu
2b68721a
MJ
21URCU_INCS="$WORKSPACE/deps/liburcu/build/include/"
22URCU_LIBS="$WORKSPACE/deps/liburcu/build/lib/"
c3bc676b 23
1f4fba8c
MJ
24SRCDIR="$WORKSPACE/src/lttng-ust"
25TMPDIR="$WORKSPACE/tmp"
3b3282a6
MJ
26PREFIX="$WORKSPACE/build"
27
1f4fba8c
MJ
28# Create build and tmp directories
29rm -rf "$PREFIX" "$TMPDIR"
30mkdir -p "$PREFIX" "$TMPDIR"
31
32export TMPDIR
33
3b3282a6
MJ
34# Set platform variables
35case "$arch" in
36*)
37 MAKE=make
38 TAR=tar
39 NPROC=nproc
40 BISON="bison"
41 YACC="$BISON -y"
42 CFLAGS=""
43 ;;
44esac
45
46# Export build flags
c3bc676b
JRJ
47export CPPFLAGS="-I$URCU_INCS"
48export LDFLAGS="-L$URCU_LIBS"
2b68721a 49export LD_LIBRARY_PATH="$URCU_LIBS:${LD_LIBRARY_PATH:-}"
c3bc676b 50
c3bc676b 51
3b3282a6 52# Set configure options for each build configuration
c3bc676b 53CONF_OPTS=""
c3bc676b 54case "$conf" in
3b3282a6
MJ
55static)
56 # Unsupported! liblttng-ust can't pull in it's static (.a) dependencies.
57 echo "Static build"
58 CONF_OPTS="--enable-static --disable-shared"
59 ;;
60
c3bc676b
JRJ
61java-agent)
62 echo "Java agent build"
63 export CLASSPATH="/usr/share/java/log4j-1.2.jar"
64 CONF_OPTS="--enable-java-agent-all"
65 ;;
3b3282a6 66
2b68721a 67python-agent)
3b3282a6
MJ
68 echo "Python agent build"
69 CONF_OPTS="--enable-python-agent"
70 ;;
71
c3bc676b
JRJ
72*)
73 echo "Standard build"
74 CONF_OPTS=""
75 ;;
76esac
77
1f4fba8c
MJ
78# Enter the source directory
79cd "$SRCDIR"
3b3282a6 80
1f4fba8c 81# Run bootstrap in the source directory prior to configure
3b3282a6
MJ
82./bootstrap
83
84
2b68721a
MJ
85# Build type
86# oot : out-of-tree build
87# dist: build via make dist
88# * : normal tree build
89#
90# Make sure to move to the build_path and configure
91# before continuing
1f4fba8c 92BUILD_PATH=$SRCDIR
2b68721a 93case "$build" in
3b3282a6
MJ
94oot)
95 echo "Out of tree build"
96 BUILD_PATH=$WORKSPACE/oot
89b9225e
MJ
97 mkdir -p "$BUILD_PATH"
98 cd "$BUILD_PATH"
99 "$SRCDIR/configure" --prefix="$PREFIX" $CONF_OPTS
3b3282a6
MJ
100 ;;
101
102dist)
103 echo "Distribution out of tree build"
89b9225e 104 BUILD_PATH="`mktemp -d`"
3b3282a6
MJ
105
106 # Initial configure and generate tarball
89b9225e 107 "$SRCDIR/configure"
3b3282a6
MJ
108 $MAKE dist
109
89b9225e
MJ
110 mkdir -p "$BUILD_PATH"
111 cp ./*.tar.* "$BUILD_PATH/"
112 cd "$BUILD_PATH"
3b3282a6
MJ
113
114 # Ignore level 1 of tar
89b9225e 115 $TAR xvf ./*.tar.* --strip 1
3b3282a6 116
89b9225e 117 "$BUILD_PATH/configure" --prefix="$PREFIX" $CONF_OPTS
3b3282a6
MJ
118 ;;
119
120*)
1f4fba8c 121 echo "Standard in-tree build"
89b9225e 122 "$BUILD_PATH/configure" --prefix="$PREFIX" $CONF_OPTS
3b3282a6 123 ;;
2b68721a
MJ
124esac
125
3b3282a6 126# BUILD!
89b9225e 127$MAKE -j "`$NPROC`" V=1
3b3282a6 128$MAKE install
c3bc676b
JRJ
129
130# Run tests
1f4fba8c 131$MAKE check
c3bc676b 132
1f4fba8c
MJ
133# Copy tap logs for the jenkins tap parser
134rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$WORKSPACE/tap"
c3bc676b 135
1f4fba8c 136# Clean the build directory
3b3282a6 137$MAKE clean
c3bc676b 138
3b3282a6 139# Cleanup rpath in executables and shared libraries
89b9225e 140find "$PREFIX/lib" -name "*.so" -exec chrpath --delete {} \;
3b3282a6
MJ
141
142# Remove libtool .la files
89b9225e 143find "$PREFIX/lib" -name "*.la" -exec rm -f {} \;
2b68721a
MJ
144
145# Clean temp dir for dist build
3b3282a6 146if [ "$build" = "dist" ]; then
89b9225e
MJ
147 cd "$SRCDIR"
148 rm -rf "$BUILD_PATH"
2b68721a 149fi
3b3282a6
MJ
150
151# EOF
This page took 0.038051 seconds and 4 git commands to generate.