jjb: babeltrace cleanups
[lttng-ci.git] / scripts / lttng-ust / build.sh
... / ...
CommitLineData
1#!/bin/bash -exu
2#
3# Copyright (C) 2015, Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4# 2016, Michael Jeanson <mjeanson@efficios.com>
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
20# liburcu
21URCU_INCS="$WORKSPACE/deps/liburcu/build/include/"
22URCU_LIBS="$WORKSPACE/deps/liburcu/build/lib/"
23
24SRCDIR="$WORKSPACE/src/lttng-ust"
25TMPDIR="$WORKSPACE/tmp"
26PREFIX="$WORKSPACE/build"
27
28# Create build and tmp directories
29rm -rf "$PREFIX" "$TMPDIR"
30mkdir -p "$PREFIX" "$TMPDIR"
31
32export TMPDIR
33
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
47export CPPFLAGS="-I$URCU_INCS"
48export LDFLAGS="-L$URCU_LIBS"
49export LD_LIBRARY_PATH="$URCU_LIBS:${LD_LIBRARY_PATH:-}"
50
51
52# Set configure options for each build configuration
53CONF_OPTS=""
54case "$conf" in
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
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 ;;
66
67python-agent)
68 echo "Python agent build"
69 CONF_OPTS="--enable-python-agent"
70 ;;
71
72*)
73 echo "Standard build"
74 CONF_OPTS=""
75 ;;
76esac
77
78# Enter the source directory
79cd "$SRCDIR"
80
81# Run bootstrap in the source directory prior to configure
82./bootstrap
83
84
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
92BUILD_PATH=$SRCDIR
93case "$build" in
94oot)
95 echo "Out of tree build"
96 BUILD_PATH=$WORKSPACE/oot
97 mkdir -p $BUILD_PATH
98 cd $BUILD_PATH
99 $SRCDIR/configure --prefix=$PREFIX $CONF_OPTS
100 ;;
101
102dist)
103 echo "Distribution out of tree build"
104 BUILD_PATH=`mktemp -d`
105
106 # Initial configure and generate tarball
107 $SRCDIR/configure
108 $MAKE dist
109
110 mkdir -p $BUILD_PATH
111 cp *.tar.* $BUILD_PATH/
112 cd $BUILD_PATH
113
114 # Ignore level 1 of tar
115 $TAR xvf *.tar.* --strip 1
116
117 $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS
118 ;;
119
120*)
121 echo "Standard in-tree build"
122 $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS
123 ;;
124esac
125
126# BUILD!
127$MAKE -j `$NPROC` V=1
128$MAKE install
129
130# Run tests
131$MAKE check
132
133# Copy tap logs for the jenkins tap parser
134rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$WORKSPACE/tap"
135
136# Clean the build directory
137$MAKE clean
138
139# Cleanup rpath in executables and shared libraries
140find $PREFIX/lib -name "*.so" -exec chrpath --delete {} \;
141
142# Remove libtool .la files
143find $PREFIX/lib -name "*.la" -exec rm -f {} \;
144
145# Clean temp dir for dist build
146if [ "$build" = "dist" ]; then
147 cd $SRCDIR
148 rm -rf $BUILD_PATH
149fi
150
151# EOF
This page took 0.07996 seconds and 4 git commands to generate.