| 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 build flags |
| 52 | export CPPFLAGS="-I$URCU_INCS" |
| 53 | export LDFLAGS="-L$URCU_LIBS" |
| 54 | export LD_LIBRARY_PATH="$URCU_LIBS:${LD_LIBRARY_PATH:-}" |
| 55 | |
| 56 | |
| 57 | # Set configure options for each build configuration |
| 58 | CONF_OPTS="" |
| 59 | case "$conf" in |
| 60 | static) |
| 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 | |
| 66 | java-agent) |
| 67 | echo "Java agent build" |
| 68 | export CLASSPATH="/usr/share/java/log4j-1.2.jar" |
| 69 | CONF_OPTS="--enable-java-agent-all" |
| 70 | ;; |
| 71 | |
| 72 | python-agent) |
| 73 | echo "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 | # * : normal tree build |
| 94 | # |
| 95 | # Make sure to move to the build_path and configure |
| 96 | # before continuing |
| 97 | BUILD_PATH=$SRCDIR |
| 98 | case "$build" in |
| 99 | oot) |
| 100 | echo "Out of tree build" |
| 101 | BUILD_PATH=$WORKSPACE/oot |
| 102 | mkdir -p "$BUILD_PATH" |
| 103 | cd "$BUILD_PATH" |
| 104 | "$SRCDIR/configure" --prefix="$PREFIX" $CONF_OPTS |
| 105 | ;; |
| 106 | |
| 107 | dist) |
| 108 | echo "Distribution out of tree build" |
| 109 | BUILD_PATH="$(mktemp -d)" |
| 110 | |
| 111 | # Initial configure and generate tarball |
| 112 | "$SRCDIR/configure" |
| 113 | $MAKE dist |
| 114 | |
| 115 | mkdir -p "$BUILD_PATH" |
| 116 | cp ./*.tar.* "$BUILD_PATH/" |
| 117 | cd "$BUILD_PATH" |
| 118 | |
| 119 | # Ignore level 1 of tar |
| 120 | $TAR xvf ./*.tar.* --strip 1 |
| 121 | |
| 122 | "$BUILD_PATH/configure" --prefix="$PREFIX" $CONF_OPTS |
| 123 | ;; |
| 124 | |
| 125 | *) |
| 126 | echo "Standard in-tree build" |
| 127 | "$BUILD_PATH/configure" --prefix="$PREFIX" $CONF_OPTS |
| 128 | ;; |
| 129 | esac |
| 130 | |
| 131 | # BUILD! |
| 132 | $MAKE -j "$($NPROC)" V=1 |
| 133 | $MAKE install |
| 134 | |
| 135 | # Run tests |
| 136 | $MAKE check |
| 137 | |
| 138 | # Copy tap logs for the jenkins tap parser |
| 139 | rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$WORKSPACE/tap" |
| 140 | |
| 141 | # Clean the build directory |
| 142 | $MAKE clean |
| 143 | |
| 144 | # Cleanup rpath in executables and shared libraries |
| 145 | find "$PREFIX/lib" -name "*.so" -exec chrpath --delete {} \; |
| 146 | |
| 147 | # Remove libtool .la files |
| 148 | find "$PREFIX/lib" -name "*.la" -exec rm -f {} \; |
| 149 | |
| 150 | # Clean temp dir for dist build |
| 151 | if [ "$build" = "dist" ]; then |
| 152 | cd "$SRCDIR" |
| 153 | rm -rf "$BUILD_PATH" |
| 154 | fi |
| 155 | |
| 156 | # EOF |