jjb: add lttng-tools jgalar dev jobs
[lttng-ci.git] / scripts / liburcu / build.sh
... / ...
CommitLineData
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# Version compare functions
20verlte() {
21 [ "$1" = "$(printf '%s\n%s' "$1" "$2" | sort -t '.' -k 1,1 -k 2,2 -k 3,3 -k 4,4 -g | 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 -t '.' -k 1,1 -k 2,2 -k 3,3 -k 4,4 -g | tail -n1)" ]
30}
31
32vergt() {
33 [ "$1" = "$2" ] && return 1 || vergte "$1" "$2"
34}
35
36
37SRCDIR="$WORKSPACE/src/liburcu"
38TMPDIR="$WORKSPACE/tmp"
39PREFIX="$WORKSPACE/build"
40
41# Create build and tmp directories
42rm -rf "$PREFIX" "$TMPDIR"
43mkdir -p "$PREFIX" "$TMPDIR"
44
45export TMPDIR
46
47# Set platform variables
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 ;;
55
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 ;;
63
64macosx)
65 MAKE=make
66 TAR=tar
67 NPROC="getconf _NPROCESSORS_ONLN"
68 BISON="bison"
69 YACC="$BISON -y"
70 export PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
71 export CFLAGS="-I/opt/local/include"
72 export LDFLAGS="-L/opt/local/lib"
73 ;;
74
75*)
76 MAKE=make
77 TAR=tar
78 NPROC=nproc
79 CFLAGS=""
80 ;;
81esac
82
83# Set configure options for each build configuration
84CONF_OPTS=""
85case "$conf" in
86static)
87 echo "Static build"
88 CONF_OPTS="--enable-static --disable-shared"
89 ;;
90
91tls_fallback)
92 echo "Using pthread_getspecific() to emulate TLS"
93 CONF_OPTS="--disable-compiler-tls"
94 ;;
95
96*)
97 echo "Standard build"
98 CONF_OPTS=""
99 ;;
100esac
101
102
103# Enter the source directory
104cd "$SRCDIR"
105
106# Run bootstrap in the source directory prior to configure
107./bootstrap
108
109# Get source version from configure script
110eval `grep '^PACKAGE_VERSION=' ./configure`
111
112
113# Build type
114# oot : out-of-tree build
115# dist: build via make dist
116# * : normal tree build
117#
118# Make sure to move to the build_path and configure
119# before continuing
120BUILD_PATH=$SRCDIR
121case "$build" in
122oot)
123 echo "Out of tree build"
124 BUILD_PATH=$WORKSPACE/oot
125 mkdir -p $BUILD_PATH
126 cd $BUILD_PATH
127 MAKE=$MAKE CFLAGS="$CFLAGS" $SRCDIR/configure --prefix=$PREFIX $CONF_OPTS
128 ;;
129
130dist)
131 echo "Distribution out of tree build"
132 BUILD_PATH=`mktemp -d`
133
134 # Initial configure and generate tarball
135 MAKE=$MAKE $SRCDIR/configure
136 $MAKE dist
137
138 mkdir -p $BUILD_PATH
139 cp *.tar.* $BUILD_PATH/
140 cd $BUILD_PATH
141
142 # Ignore level 1 of tar
143 $TAR xvf *.tar.* --strip 1
144
145 MAKE=$MAKE CFLAGS="$CFLAGS" $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS
146 ;;
147*)
148 echo "Standard in-tree build"
149 MAKE=$MAKE CFLAGS="$CFLAGS" $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS
150 ;;
151esac
152
153# BUILD!
154$MAKE -j `$NPROC` V=1
155$MAKE install
156
157# Run tests
158$MAKE check
159# Only run regtest for 0.9 and up
160if vergte "$PACKAGE_VERSION" "0.9"; then
161 $MAKE regtest
162fi
163
164# Cleanup
165$MAKE clean
166
167# Cleanup rpath in executables and shared libraries
168#find $WORKSPACE/build/bin -type f -perm -0500 -exec chrpath --delete {} \;
169find $PREFIX/lib -name "*.so" -exec chrpath --delete {} \;
170
171# Remove libtool .la files
172find $PREFIX/lib -name "*.la" -exec rm -f {} \;
173
174# Cleanup temp directory of dist build
175if [ "$build" = "dist" ]; then
176 cd $SRCDIR
177 rm -rf $BUILD_PATH
178fi
179
180# EOF
This page took 0.022394 seconds and 4 git commands to generate.