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