travis: test with latest jjb
[lttng-ci.git] / scripts / liburcu / build.sh
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
20 verlte() {
21 [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | head -n1`" ]
22 }
23
24 verlt() {
25 [ "$1" = "$2" ] && return 1 || verlte $1 $2
26 }
27
28 vergte() {
29 [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | tail -n1`" ]
30 }
31
32 vergt() {
33 [ "$1" = "$2" ] && return 1 || vergte $1 $2
34 }
35
36
37 SRCDIR="$WORKSPACE/src/liburcu"
38 TMPDIR="$WORKSPACE/tmp"
39 PREFIX="$WORKSPACE/build"
40
41 # Create build and tmp directories
42 rm -rf "$PREFIX" "$TMPDIR"
43 mkdir -p "$PREFIX" "$TMPDIR"
44
45 export TMPDIR
46
47 # Set platform variables
48 case "$arch" in
49 solaris10)
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
56 solaris11)
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
64 *)
65 MAKE=make
66 TAR=tar
67 NPROC=nproc
68 CFLAGS=""
69 ;;
70 esac
71
72 # Set configure options for each build configuration
73 CONF_OPTS=""
74 case "$conf" in
75 static)
76 echo "Static build"
77 CONF_OPTS="--enable-static --disable-shared"
78 ;;
79
80 tls_fallback)
81 echo "Using pthread_getspecific() to emulate TLS"
82 CONF_OPTS="--disable-compiler-tls"
83 ;;
84
85 *)
86 echo "Standard build"
87 CONF_OPTS=""
88 ;;
89 esac
90
91
92 # Enter the source directory
93 cd "$SRCDIR"
94
95 # Run bootstrap in the source directory prior to configure
96 ./bootstrap
97
98 # Get source version from configure script
99 eval `grep '^PACKAGE_VERSION=' ./configure`
100
101
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
109 BUILD_PATH=$SRCDIR
110 case "$build" in
111 oot)
112 echo "Out of tree build"
113 BUILD_PATH=$WORKSPACE/oot
114 mkdir -p $BUILD_PATH
115 cd $BUILD_PATH
116 MAKE=$MAKE CFLAGS="$CFLAGS" $SRCDIR/configure --prefix=$PREFIX $CONF_OPTS
117 ;;
118
119 dist)
120 echo "Distribution out of tree build"
121 BUILD_PATH=`mktemp -d`
122
123 # Initial configure and generate tarball
124 MAKE=$MAKE $SRCDIR/configure
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 *)
137 echo "Standard in-tree build"
138 MAKE=$MAKE CFLAGS="$CFLAGS" $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS
139 ;;
140 esac
141
142 # BUILD!
143 $MAKE -j `$NPROC` V=1
144 $MAKE install
145
146 # Run tests
147 $MAKE check
148 # Only run regtest for 0.9 and up
149 if vergte "$PACKAGE_VERSION" "0.9"; then
150 $MAKE regtest
151 fi
152
153 # Cleanup
154 $MAKE clean
155
156 # Cleanup rpath in executables and shared libraries
157 #find $WORKSPACE/build/bin -type f -perm -0500 -exec chrpath --delete {} \;
158 find $PREFIX/lib -name "*.so" -exec chrpath --delete {} \;
159
160 # Remove libtool .la files
161 find $PREFIX/lib -name "*.la" -exec rm -f {} \;
162
163 # Cleanup temp directory of dist build
164 if [ "$build" = "dist" ]; then
165 cd $SRCDIR
166 rm -rf $BUILD_PATH
167 fi
168
169 # EOF
This page took 0.03313 seconds and 5 git commands to generate.