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