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