travis: test with latest jjb
[lttng-ci.git] / scripts / liburcu / build.sh
CommitLineData
72f4f0c1 1#!/bin/bash -exu
e3022ad9
MJ
2#
3# Copyright (C) 2015 - Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
6d35c326 4# 2016 - Michael Jeanson <mjeanson@efficios.com>
e3022ad9
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
5fd8db76
MJ
19# Version compare functions
20verlte() {
21 [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | head -n1`" ]
22}
23
24verlt() {
25 [ "$1" = "$2" ] && return 1 || verlte $1 $2
26}
27
28vergte() {
29 [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | tail -n1`" ]
30}
31
32vergt() {
33 [ "$1" = "$2" ] && return 1 || vergte $1 $2
34}
35
e3022ad9 36
6d35c326
MJ
37SRCDIR="$WORKSPACE/src/liburcu"
38TMPDIR="$WORKSPACE/tmp"
56162e2a
JRJ
39PREFIX="$WORKSPACE/build"
40
6d35c326
MJ
41# Create build and tmp directories
42rm -rf "$PREFIX" "$TMPDIR"
43mkdir -p "$PREFIX" "$TMPDIR"
44
45export TMPDIR
46
72f4f0c1 47# Set platform variables
7491c28d
MJ
48case "$arch" in
49solaris10)
50 MAKE=gmake
51 TAR=gtar
52 NPROC=gnproc
53 CFLAGS="-D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__=1"
54 ;;
72f4f0c1 55
7491c28d
MJ
56solaris11)
57 MAKE=gmake
58 TAR=gtar
59 NPROC=nproc
60 CFLAGS="-D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__=1"
61 export PATH="$PATH:/usr/perl5/bin"
62 ;;
72f4f0c1 63
7491c28d
MJ
64*)
65 MAKE=make
66 TAR=tar
67 NPROC=nproc
68 CFLAGS=""
69 ;;
70esac
71
72f4f0c1
MJ
72# Set configure options for each build configuration
73CONF_OPTS=""
56162e2a
JRJ
74case "$conf" in
75static)
76 echo "Static build"
77 CONF_OPTS="--enable-static --disable-shared"
78 ;;
72f4f0c1 79
56162e2a
JRJ
80tls_fallback)
81 echo "Using pthread_getspecific() to emulate TLS"
82 CONF_OPTS="--disable-compiler-tls"
83 ;;
72f4f0c1 84
56162e2a
JRJ
85*)
86 echo "Standard build"
87 CONF_OPTS=""
88 ;;
89esac
90
72f4f0c1 91
6d35c326
MJ
92# Enter the source directory
93cd "$SRCDIR"
94
95# Run bootstrap in the source directory prior to configure
72f4f0c1
MJ
96./bootstrap
97
5fd8db76
MJ
98# Get source version from configure script
99eval `grep '^PACKAGE_VERSION=' ./configure`
100
72f4f0c1 101
595a34c7
JR
102# Build type
103# oot : out-of-tree build
104# dist: build via make dist
105# * : normal tree build
106#
107# Make sure to move to the build_path and configure
108# before continuing
6d35c326 109BUILD_PATH=$SRCDIR
595a34c7 110case "$build" in
72f4f0c1
MJ
111oot)
112 echo "Out of tree build"
113 BUILD_PATH=$WORKSPACE/oot
114 mkdir -p $BUILD_PATH
115 cd $BUILD_PATH
6d35c326 116 MAKE=$MAKE CFLAGS="$CFLAGS" $SRCDIR/configure --prefix=$PREFIX $CONF_OPTS
72f4f0c1
MJ
117 ;;
118
119dist)
120 echo "Distribution out of tree build"
121 BUILD_PATH=`mktemp -d`
122
123 # Initial configure and generate tarball
6d35c326 124 MAKE=$MAKE $SRCDIR/configure
72f4f0c1
MJ
125 $MAKE dist
126
127 mkdir -p $BUILD_PATH
128 cp *.tar.* $BUILD_PATH/
129 cd $BUILD_PATH
130
131 # Ignore level 1 of tar
132 $TAR xvf *.tar.* --strip 1
133
134 MAKE=$MAKE CFLAGS="$CFLAGS" $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS
135 ;;
136*)
6d35c326
MJ
137 echo "Standard in-tree build"
138 MAKE=$MAKE CFLAGS="$CFLAGS" $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS
72f4f0c1 139 ;;
595a34c7
JR
140esac
141
72f4f0c1 142# BUILD!
fe584a39 143$MAKE -j `$NPROC` V=1
7491c28d 144$MAKE install
72f4f0c1
MJ
145
146# Run tests
7491c28d 147$MAKE check
5fd8db76
MJ
148# Only run regtest for 0.9 and up
149if vergte "$PACKAGE_VERSION" "0.9"; then
72f4f0c1 150 $MAKE regtest
5fd8db76 151fi
72f4f0c1
MJ
152
153# Cleanup
7491c28d 154$MAKE clean
56162e2a 155
72f4f0c1
MJ
156# Cleanup rpath in executables and shared libraries
157#find $WORKSPACE/build/bin -type f -perm -0500 -exec chrpath --delete {} \;
6d35c326 158find $PREFIX/lib -name "*.so" -exec chrpath --delete {} \;
72f4f0c1
MJ
159
160# Remove libtool .la files
6d35c326 161find $PREFIX/lib -name "*.la" -exec rm -f {} \;
595a34c7 162
cdcf7df4 163# Cleanup temp directory of dist build
72f4f0c1 164if [ "$build" = "dist" ]; then
6d35c326 165 cd $SRCDIR
72f4f0c1 166 rm -rf $BUILD_PATH
595a34c7 167fi
7491c28d
MJ
168
169# EOF
This page took 0.038129 seconds and 4 git commands to generate.