1#!/bin/bash
2# This file is part of the Givaro library.
3# It is distributed under the terms of the CeCILL-B licence
4# (see COPYING)
5# Created by AB - 2014/12/03
6# Modified by AC - 2016/04/08
7# Modified by CP - 2016/06/22
8
9# Some influential environment variables:
10#	CXX			C++ compiler command
11#	CXXFLAGS	C++ compiler flags
12
13# Note: This script is intended to be launched
14# by the Jenkins web interface whenever it needs
15# to compile the project.
16# But should be stored in /<slave_jenkins_path>/makers/
17# It is launched from the svn:trunk root directory.
18
19SOURCE_DIRECTORY=$( cd "$( dirname "$0" )" && pwd )
20
21
22#=============================#
23# Change only these variables #
24#=============================#
25ARCH=`pwd | awk -F/ '{print $(NF-2)}'`
26CXX=`pwd | awk -F/ '{print $(NF)}'`
27#SSE=`pwd | awk -F/ '{print $NF}'`
28
29# Job givaro with SSE option flag
30# by default sse is enabled
31#if [ "$SSE" == "withoutSSE" ]; then
32#  GIVARO_SSEFLAG="--disable-sse --disable-sse2 --disable-sse3 --disable-ssse3 --disable-sse4.1 --disable-sse4.2 --disable-avx --disable-avx2 --disable-fma --disable-fma4"
33#fi
34
35JENKINS_DIR=${SOURCE_DIRECTORY%%/workspace/*}
36LOCAL_DIR="$JENKINS_DIR"/local
37
38# Where to install givaro binaries
39# Keep default for local installation.
40PREFIX_INSTALL="$LOCAL_DIR/$CXX"
41
42# Add path to compilers (if needed)
43export PATH="$PATH":"/usr/local/bin":"$LOCAL_DIR/$CXX/bin"
44# Add specific locations (if needed)
45export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"/usr/local/lib":"$LOCAL_DIR/$CXX/lib"
46echo "LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}"
47
48# Where is GMP installed (compiled with cxx interface)
49# Keep empty if in usual folders (i.e. /usr or /usr/local)
50GMP_PATH="$LOCAL_DIR/$CXX"
51
52# /!\ Warning /!\ This could be an issue if you changed
53# the local installation directory
54rm -rf "$PREFIX_INSTALL"/bin/givaro* "$PREFIX_INSTALL"/include/givaro* "$PREFIX_INSTALL"/include/gmp++ "$PREFIX_INSTALL"/include/recint "$PREFIX_INSTALL"/lib/libgivaro*
55
56
57#================#
58# Setup Variables#
59#================#
60
61if [ "$CXX" == "icpc" ]; then
62     distribution=`uname -m`
63     if [ "$distribution" == "i686" ]; then
64	source /usr/local/bin/compilervars.sh ia32
65     else
66	source /usr/local/bin/compilervars.sh intel64
67     fi
68fi
69
70# Particular case for Fedora23: g++=g++-5.3
71if [[ "$ARCH" == "linbox-fedora-amd64" &&  "$CXX" == "g++-6" ]]; then
72    CXX="g++"
73fi
74CC=`echo $CXX | sed  's/icpc/icc/;s/clang++/clang/;s/++/cc/'`
75
76#==================================#
77# Automated installation and tests #
78#==================================#
79
80echo "|=== JENKINS AUTOMATED SCRIPT ===| ./autogen.sh CXX=$CXX CC=$CC CXXFLAGS=$CXXFLAGS --prefix=$PREFIX_INSTALL --with-gmp=$GMP_PATH"
81./autogen.sh CXX=$CXX CC=$CC CXXFLAGS=$CXXFLAGS --prefix="$PREFIX_INSTALL" --with-gmp="$GMP_PATH"
82V="$?"; if test "x$V" != "x0"; then exit "$V"; fi
83
84echo "|=== JENKINS AUTOMATED SCRIPT ===| make install"
85make install
86V="$?"; if test "x$V" != "x0"; then exit "$V"; fi
87
88echo "|=== JENKINS AUTOMATED SCRIPT ===| make perfpublisher"
89make perfpublisher
90
91echo "|=== JENKINS AUTOMATED SCRIPT ===| make examples"
92make examples
93V="$?"; if test "x$V" != "x0"; then exit "$V"; fi
94(cd examples && make clean)
95