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