jjb: Update babeltrace jobs
[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
a57a60d9
MJ
19# Required parameters
20arch=${arch:-}
21conf=${conf:-}
22build=${build:-}
23
2b68721a 24
c3bc676b 25# liburcu
2b68721a
MJ
26URCU_INCS="$WORKSPACE/deps/liburcu/build/include/"
27URCU_LIBS="$WORKSPACE/deps/liburcu/build/lib/"
c3bc676b 28
1f4fba8c
MJ
29SRCDIR="$WORKSPACE/src/lttng-ust"
30TMPDIR="$WORKSPACE/tmp"
3b3282a6
MJ
31PREFIX="$WORKSPACE/build"
32
1f4fba8c
MJ
33# Create build and tmp directories
34rm -rf "$PREFIX" "$TMPDIR"
35mkdir -p "$PREFIX" "$TMPDIR"
36
37export TMPDIR
72d087d4 38export CFLAGS="-g -O2"
1f4fba8c 39
3b3282a6
MJ
40# Set platform variables
41case "$arch" in
42*)
43 MAKE=make
44 TAR=tar
45 NPROC=nproc
a57a60d9
MJ
46 #BISON="bison"
47 #YACC="$BISON -y"
48 #CFLAGS=""
3b3282a6
MJ
49 ;;
50esac
51
ab89ec98 52# Export time env. variables flags
2b68721a 53export LD_LIBRARY_PATH="$URCU_LIBS:${LD_LIBRARY_PATH:-}"
c3bc676b 54
ab89ec98
JR
55# Define flags
56CPPFLAGS="-I$URCU_INCS"
57LDFLAGS="-L$URCU_LIBS"
58
c3bc676b 59
3b3282a6 60# Set configure options for each build configuration
c3bc676b 61CONF_OPTS=""
c3bc676b 62case "$conf" in
3b3282a6
MJ
63static)
64 # Unsupported! liblttng-ust can't pull in it's static (.a) dependencies.
65 echo "Static build"
66 CONF_OPTS="--enable-static --disable-shared"
67 ;;
68
67122b96
MJ
69agents)
70 echo "Enable Java agent build"
c3bc676b 71 export CLASSPATH="/usr/share/java/log4j-1.2.jar"
67122b96 72 CONF_OPTS+=" --enable-java-agent-all --enable-jni-interface"
3b3282a6 73
67122b96
MJ
74 echo "Enable Python agent build"
75 CONF_OPTS+=" --enable-python-agent"
3b3282a6
MJ
76 ;;
77
a76416f2
JR
78debug-rcu)
79 echo "Enable RCU sanity checks for debugging"
80 CPPFLAGS="${CPPFLAGS:-} -DDEBUG_RCU"
81 ;;
82
c3bc676b
JRJ
83*)
84 echo "Standard build"
85 CONF_OPTS=""
86 ;;
87esac
88
1f4fba8c
MJ
89# Enter the source directory
90cd "$SRCDIR"
3b3282a6 91
1f4fba8c 92# Run bootstrap in the source directory prior to configure
3b3282a6
MJ
93./bootstrap
94
95
2b68721a 96# Build type
67122b96
MJ
97# oot : out-of-tree build
98# dist : build via make dist
99# oot-dist: build via make dist out-of-tree
100# * : normal tree build
2b68721a
MJ
101#
102# Make sure to move to the build_path and configure
103# before continuing
1f4fba8c 104BUILD_PATH=$SRCDIR
2b68721a 105case "$build" in
3b3282a6
MJ
106oot)
107 echo "Out of tree build"
108 BUILD_PATH=$WORKSPACE/oot
67122b96 109
89b9225e
MJ
110 mkdir -p "$BUILD_PATH"
111 cd "$BUILD_PATH"
67122b96 112
ab89ec98 113 CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" "$SRCDIR/configure" --prefix="$PREFIX" $CONF_OPTS
3b3282a6
MJ
114 ;;
115
116dist)
67122b96 117 echo "Distribution tarball in-tree build"
3b3282a6
MJ
118
119 # Initial configure and generate tarball
4e6f0bd1 120 CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" "$SRCDIR/configure"
3b3282a6
MJ
121 $MAKE dist
122
67122b96 123 BUILD_PATH="$(mktemp -d)"
89b9225e
MJ
124 cp ./*.tar.* "$BUILD_PATH/"
125 cd "$BUILD_PATH"
3b3282a6
MJ
126
127 # Ignore level 1 of tar
89b9225e 128 $TAR xvf ./*.tar.* --strip 1
3b3282a6 129
67122b96 130 # Build in extracted source tree
ab89ec98 131 CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" "$BUILD_PATH/configure" --prefix="$PREFIX" $CONF_OPTS
3b3282a6
MJ
132 ;;
133
67122b96
MJ
134oot-dist)
135 echo "Distribution tarball out of tree build"
136 BUILD_PATH="$(mktemp -d)"
137 cd "$BUILD_PATH"
138
139 # Initial configure and generate tarball
4e6f0bd1 140 CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" "$SRCDIR/configure"
67122b96
MJ
141 $MAKE dist
142
143 NEWSRC_PATH="$(mktemp -d)"
144 cp ./*.tar.* "$NEWSRC_PATH/"
145 cd "$NEWSRC_PATH"
146
147 # Ignore level 1 of tar
148 $TAR xvf ./*.tar.* --strip 1
149
150 BUILD_PATH="$(mktemp -d)"
151 cd "$BUILD_PATH"
152
153 # Build oot from extracted sources
ab89ec98 154 CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" "$NEWSRC_PATH/configure" --prefix="$PREFIX" $CONF_OPTS
67122b96
MJ
155 ;;
156
3b3282a6 157*)
1f4fba8c 158 echo "Standard in-tree build"
ab89ec98 159 CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" "$BUILD_PATH/configure" --prefix="$PREFIX" $CONF_OPTS
3b3282a6 160 ;;
2b68721a
MJ
161esac
162
3b3282a6 163# BUILD!
a57a60d9 164$MAKE -j "$($NPROC)" V=1
3b3282a6 165$MAKE install
c3bc676b
JRJ
166
167# Run tests
6827c67a 168$MAKE --keep-going check
c3bc676b 169
1f4fba8c
MJ
170# Copy tap logs for the jenkins tap parser
171rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$WORKSPACE/tap"
c3bc676b 172
1f4fba8c 173# Clean the build directory
3b3282a6 174$MAKE clean
c3bc676b 175
3b3282a6 176# Cleanup rpath in executables and shared libraries
89b9225e 177find "$PREFIX/lib" -name "*.so" -exec chrpath --delete {} \;
3b3282a6
MJ
178
179# Remove libtool .la files
89b9225e 180find "$PREFIX/lib" -name "*.la" -exec rm -f {} \;
2b68721a
MJ
181
182# Clean temp dir for dist build
3b3282a6 183if [ "$build" = "dist" ]; then
89b9225e
MJ
184 cd "$SRCDIR"
185 rm -rf "$BUILD_PATH"
2b68721a 186fi
3b3282a6
MJ
187
188# EOF
This page took 0.051974 seconds and 4 git commands to generate.