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