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 | ||
19 | ||
c3bc676b | 20 | # liburcu |
2b68721a MJ |
21 | URCU_INCS="$WORKSPACE/deps/liburcu/build/include/" |
22 | URCU_LIBS="$WORKSPACE/deps/liburcu/build/lib/" | |
c3bc676b | 23 | |
1f4fba8c MJ |
24 | SRCDIR="$WORKSPACE/src/lttng-ust" |
25 | TMPDIR="$WORKSPACE/tmp" | |
3b3282a6 MJ |
26 | PREFIX="$WORKSPACE/build" |
27 | ||
1f4fba8c MJ |
28 | # Create build and tmp directories |
29 | rm -rf "$PREFIX" "$TMPDIR" | |
30 | mkdir -p "$PREFIX" "$TMPDIR" | |
31 | ||
32 | export TMPDIR | |
33 | ||
3b3282a6 MJ |
34 | # Set platform variables |
35 | case "$arch" in | |
36 | *) | |
37 | MAKE=make | |
38 | TAR=tar | |
39 | NPROC=nproc | |
40 | BISON="bison" | |
41 | YACC="$BISON -y" | |
42 | CFLAGS="" | |
43 | ;; | |
44 | esac | |
45 | ||
46 | # Export build flags | |
c3bc676b JRJ |
47 | export CPPFLAGS="-I$URCU_INCS" |
48 | export LDFLAGS="-L$URCU_LIBS" | |
2b68721a | 49 | export LD_LIBRARY_PATH="$URCU_LIBS:${LD_LIBRARY_PATH:-}" |
c3bc676b | 50 | |
c3bc676b | 51 | |
3b3282a6 | 52 | # Set configure options for each build configuration |
c3bc676b | 53 | CONF_OPTS="" |
c3bc676b | 54 | case "$conf" in |
3b3282a6 MJ |
55 | static) |
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 | ||
c3bc676b JRJ |
61 | java-agent) |
62 | echo "Java agent build" | |
63 | export CLASSPATH="/usr/share/java/log4j-1.2.jar" | |
64 | CONF_OPTS="--enable-java-agent-all" | |
65 | ;; | |
3b3282a6 | 66 | |
2b68721a | 67 | python-agent) |
3b3282a6 MJ |
68 | echo "Python agent build" |
69 | CONF_OPTS="--enable-python-agent" | |
70 | ;; | |
71 | ||
c3bc676b JRJ |
72 | *) |
73 | echo "Standard build" | |
74 | CONF_OPTS="" | |
75 | ;; | |
76 | esac | |
77 | ||
1f4fba8c MJ |
78 | # Enter the source directory |
79 | cd "$SRCDIR" | |
3b3282a6 | 80 | |
1f4fba8c | 81 | # Run bootstrap in the source directory prior to configure |
3b3282a6 MJ |
82 | ./bootstrap |
83 | ||
84 | ||
2b68721a MJ |
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 | |
1f4fba8c | 92 | BUILD_PATH=$SRCDIR |
2b68721a | 93 | case "$build" in |
3b3282a6 MJ |
94 | oot) |
95 | echo "Out of tree build" | |
96 | BUILD_PATH=$WORKSPACE/oot | |
89b9225e MJ |
97 | mkdir -p "$BUILD_PATH" |
98 | cd "$BUILD_PATH" | |
99 | "$SRCDIR/configure" --prefix="$PREFIX" $CONF_OPTS | |
3b3282a6 MJ |
100 | ;; |
101 | ||
102 | dist) | |
103 | echo "Distribution out of tree build" | |
89b9225e | 104 | BUILD_PATH="`mktemp -d`" |
3b3282a6 MJ |
105 | |
106 | # Initial configure and generate tarball | |
89b9225e | 107 | "$SRCDIR/configure" |
3b3282a6 MJ |
108 | $MAKE dist |
109 | ||
89b9225e MJ |
110 | mkdir -p "$BUILD_PATH" |
111 | cp ./*.tar.* "$BUILD_PATH/" | |
112 | cd "$BUILD_PATH" | |
3b3282a6 MJ |
113 | |
114 | # Ignore level 1 of tar | |
89b9225e | 115 | $TAR xvf ./*.tar.* --strip 1 |
3b3282a6 | 116 | |
89b9225e | 117 | "$BUILD_PATH/configure" --prefix="$PREFIX" $CONF_OPTS |
3b3282a6 MJ |
118 | ;; |
119 | ||
120 | *) | |
1f4fba8c | 121 | echo "Standard in-tree build" |
89b9225e | 122 | "$BUILD_PATH/configure" --prefix="$PREFIX" $CONF_OPTS |
3b3282a6 | 123 | ;; |
2b68721a MJ |
124 | esac |
125 | ||
3b3282a6 | 126 | # BUILD! |
89b9225e | 127 | $MAKE -j "`$NPROC`" V=1 |
3b3282a6 | 128 | $MAKE install |
c3bc676b JRJ |
129 | |
130 | # Run tests | |
1f4fba8c | 131 | $MAKE check |
c3bc676b | 132 | |
1f4fba8c MJ |
133 | # Copy tap logs for the jenkins tap parser |
134 | rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$WORKSPACE/tap" | |
c3bc676b | 135 | |
1f4fba8c | 136 | # Clean the build directory |
3b3282a6 | 137 | $MAKE clean |
c3bc676b | 138 | |
3b3282a6 | 139 | # Cleanup rpath in executables and shared libraries |
89b9225e | 140 | find "$PREFIX/lib" -name "*.so" -exec chrpath --delete {} \; |
3b3282a6 MJ |
141 | |
142 | # Remove libtool .la files | |
89b9225e | 143 | find "$PREFIX/lib" -name "*.la" -exec rm -f {} \; |
2b68721a MJ |
144 | |
145 | # Clean temp dir for dist build | |
3b3282a6 | 146 | if [ "$build" = "dist" ]; then |
89b9225e MJ |
147 | cd "$SRCDIR" |
148 | rm -rf "$BUILD_PATH" | |
2b68721a | 149 | fi |
3b3282a6 MJ |
150 | |
151 | # EOF |