| 1 | #!/bin/sh -exu |
| 2 | # |
| 3 | # Copyright (C) 2015 - Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> |
| 4 | # |
| 5 | # This program is free software: you can redistribute it and/or modify |
| 6 | # it under the terms of the GNU General Public License as published by |
| 7 | # the Free Software Foundation, either version 3 of the License, or |
| 8 | # (at your option) any later version. |
| 9 | # |
| 10 | # This program is distributed in the hope that it will be useful, |
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | # GNU General Public License for more details. |
| 14 | # |
| 15 | # You should have received a copy of the GNU General Public License |
| 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | |
| 19 | # Create build directory |
| 20 | rm -rf $WORKSPACE/build |
| 21 | mkdir -p $WORKSPACE/build |
| 22 | |
| 23 | PREFIX="$WORKSPACE/build" |
| 24 | |
| 25 | ./bootstrap |
| 26 | |
| 27 | CONF_OPTS="" |
| 28 | |
| 29 | case "$conf" in |
| 30 | static) |
| 31 | echo "Static build" |
| 32 | CONF_OPTS="--enable-static --disable-shared" |
| 33 | ;; |
| 34 | tls_fallback) |
| 35 | echo "Using pthread_getspecific() to emulate TLS" |
| 36 | CONF_OPTS="--disable-compiler-tls" |
| 37 | ;; |
| 38 | *) |
| 39 | echo "Standard build" |
| 40 | CONF_OPTS="" |
| 41 | ;; |
| 42 | esac |
| 43 | |
| 44 | # Build type |
| 45 | # oot : out-of-tree build |
| 46 | # dist: build via make dist |
| 47 | # * : normal tree build |
| 48 | # |
| 49 | # Make sure to move to the build_path and configure |
| 50 | # before continuing |
| 51 | |
| 52 | BUILD_PATH=$WORKSPACE |
| 53 | case "$build" in |
| 54 | oot) |
| 55 | echo "Out of tree build" |
| 56 | BUILD_PATH=$WORKSPACE/oot |
| 57 | mkdir -p $BUILD_PATH |
| 58 | cd $BUILD_PATH |
| 59 | $WORKSPACE/configure --prefix=$PREFIX $CONF_OPTS |
| 60 | ;; |
| 61 | dist) |
| 62 | echo "Distribution out of tree build" |
| 63 | BUILD_PATH=`mktemp -d` |
| 64 | |
| 65 | # Initial configure and generate tarball |
| 66 | ./configure |
| 67 | make dist |
| 68 | |
| 69 | mkdir -p $BUILD_PATH |
| 70 | cp *.tar.* $BUILD_PATH/ |
| 71 | cd $BUILD_PATH |
| 72 | |
| 73 | # Ignore level 1 of tar |
| 74 | tar xvf *.tar.* --strip 1 |
| 75 | |
| 76 | $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS |
| 77 | ;; |
| 78 | *) |
| 79 | BUILD_PATH=$WORKSPACE |
| 80 | echo "Standard tree build" |
| 81 | $WORKSPACE/configure --prefix=$PREFIX $CONF_OPTS |
| 82 | ;; |
| 83 | esac |
| 84 | |
| 85 | make |
| 86 | make install |
| 87 | make clean |
| 88 | |
| 89 | # Cleanup rpath and libtool .la files |
| 90 | find $WORKSPACE/build/lib -name "*.so" -exec chrpath --delete {} \; |
| 91 | find $WORKSPACE/build/lib -name "*.la" -exec rm -f {} \; |
| 92 | |
| 93 | # Cleanup temp directory of dist build |
| 94 | if [ $build = "dist" ]; then |
| 95 | rm -rf $BUILD_PATH |
| 96 | fi |