Commit 23a0f806 authored by Antonio Cervone's avatar Antonio Cervone
Browse files

add installation scripts

parent d25aaeba
INSTALLATION PROCEDURE
======================
this instruction will guide you through the installation of all the libraries
that are needed to get a working copy of the LifeV library
1) clone the LifeV github repo
```bash
git clone https://github.com/lifev/lifev.git
```
2) move to the tools/install_scripts directory
```bash
cd tools/install_scripts
```
3) copy config_example in config and edit it for your needs
```bash
cp config_example config
edit config
```
this file contains the basic configurations for the installation, such as
the installation directory.
4) copy libpath_example in libpath and edit it for your needs
```bash
cp libpath_example libpath
edit libpath
```
this file sets the configuration for the libraries that will be used or
installed.
5) run the build script
```bash
./build
```
cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
# Default compilers
set(CMAKE_C_COMPILER "mpicc" CACHE STRING "Default C compiler")
set(CMAKE_CXX_COMPILER "mpicxx" CACHE STRING "Default C++ compiler")
# Default build type
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Default build type")
set(APPLIFEV_USE_MPI_WRAPPER ON CACHE BOOL "By default, use the MPI wrappers")
# Project options
project(AppLifeV)
set(PROJECT_SHORT_NAME "app-lifev")
# Languages
enable_language(C CXX)
# MPI
if(NOT APPLIFEV_USE_MPI_WRAPPER)
find_package (MPI REQUIRED)
if(MPI_FOUND)
include_directories(${MPI_CXX_INCLUDE_PATH})
set(LIBS ${LIBS} ${MPI_CXX_LIBRARIES})
endif()
endif()
# LIFEV
find_package(LIFEV REQUIRED)
message(STATUS "LifeV include dirs: " ${LIFEV_INCLUDE_DIRS})
include_directories(${LIFEV_INCLUDE_DIRS})
message(STATUS "LifeV libraries: " ${LIFEV_LIBRARIES})
set(LIBS ${LIBS} ${LIFEV_LIBRARIES})
# dummy test application
add_subdirectory(dummy)
# - Try to find the LifeV library
# Once done this will define
#
# LIFEV_FOUND - System has LifeV
# LIFEV_INCLUDE_DIR - The LifeV include directory
# LIFEV_LIBRARIES - The libraries needed to use LifeV
#=============================================================================
# Copyright 2006-2009 Kitware, Inc.
# Copyright 2012 Antonio Cervone <ant.cervone@gmail.com>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# FIND_PATH(LIFEV_INCLUDE_DIRS NAMES lifev/core/LifeV.hpp
# HINTS
# ${LifeV_DIR}/include
# ${LIFEV_ROOT}/include
# ${LIFEV_INCLUDEDIR}
# ${LIFEV_INCLUDE_DIRS}
# )
# FIND_LIBRARY(LIFEV_LIBRARIES NAMES lifevcore liblifevcore
# HINTS
# ${LifeV_DIR}/lib
# ${LIFEV_ROOT}/lib
# ${LIFEV_LIBDIR}
# ${LIFEV_LIBRARY_DIRS}
# )
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE(LifeV
NO_MODULE
PATHS
${LifeV_DIR}
${LIFEV_ROOT}
)
SET(LIFEV_INCLUDE_DIRS
${LifeV_INCLUDE_DIRS}
${LifeV_TPL_INCLUDE_DIRS}
)
SET(LIFEV_LIBRARIES
${LifeV_LIBRARIES}
${LifeV_TPL_LIBRARIES}
)
# FIND_PROGRAM(LIFEV_VECTORSMALLTEST_EXECUTABLE Core_VectorSmall.exe)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LifeV
DEFAULT_MSG
LIFEV_LIBRARIES
LIFEV_INCLUDE_DIRS
)
MARK_AS_ADVANCED(
LIFEV_INCLUDE_DIRS
LIFEV_LIBRARIES
# LIFEV_VECTORSMALLTEST_EXECUTABLE
)
# this is a dummy application to test cmake configuration
ADD_EXECUTABLE(dummyApp dummy.cpp)
TARGET_LINK_LIBRARIES(dummyApp ${LIBS})
#include <lifev/core/LifeV.hpp>
using namespace LifeV;
int main(int argc, char** argv)
{
#ifdef HAVE_MPI
MPI_Init( &argc, &argv );
#endif
std::cout << "End Result: TEST PASSED" << std::endl;
#ifdef HAVE_MPI
MPI_Finalize();
#endif
return 0;
}
#! /bin/bash
#
# author: Antonio Cervone <ant.cervone@gmail.com>
# date: 28-03-2012
#
# include configuration file
source libpath
pushd app > /dev/null # app
SRC_DIR=${PWD}
mkdir -p ${BUILD_DIR}/app
pushd ${BUILD_DIR}/app > /dev/null # ${BUILD_DIR}/app
rm -fr CMake*
${cmake_bin}/cmake \
-D CMAKE_INSTALL_PREFIX:PATH=${INSTALL_DIR}/app_install \
-D LifeV_DIR:PATH=${INSTALL_DIR}/lib/lifev \
${SRC_DIR} || exit
make -j${NUM_PROC} || exit
popd > /dev/null # ${BUILD_DIR}/app
popd > /dev/null # app
#! /bin/bash
#
# author: Antonio Cervone <ant.cervone@gmail.com>
# date: 30-08-2012
#
# list of packages
# the key should be:
# - INSTALL : the package will be installed by this script
# - YES : the package is already installed in the system, and its paths
# must be specified in the following variables
# - NO : the package will not be used
# BEWARE! some packages are required and cannot be set to NO!!
source libpath
package_install=()
package_yes=()
package_no=()
for pack in "${package_array[@]}"; do
if [ "${!pack}" == "INSTALL" ]; then
echo "$pack will be installed"
package_install=( ${package_install[@]} $pack )
elif [ "${!pack}" == "YES" ]; then
echo "$pack is already installed"
package_yes=( ${package_yes[@]} $pack )
elif [ "${!pack}" == "NO" ]; then
echo "$pack will not be used"
package_no=( ${package_no[@]} $pack )
fi
# pack_bin=${pack}_bin
# pack_include=${pack}_include
# pack_lib=${pack}_lib
# echo ${!pack_include}
# echo
done
echo
echo "following packages will be installed:"
echo ${package_install[@]}
echo
echo "following packages are already installed: "
echo ${package_yes[@]}
echo
echo "following packages will not be used:"
echo ${package_no[@]}
pushd lib >/dev/null
source pkgbuild ${package_install[@]}
popd >/dev/null
#! /bin/bash
#
# author: Antonio Cervone <ant.cervone@gmail.com>
# date: 28-03-2012
#
# comment next line to disable debug output
#DBG=1
# select library installation path
INSTALL_DIR=${HOME}/lifev/install
# select temporary build directory
BUILD_DIR=${HOME}/lifev/build
# comment next line to keep build files
RM_TMP=1
# comment next line to avoid log files
#LOG=1
# comment next line to disable download
DOWNLOAD=1
# comment next line to disable unpack
UNPACK=1
# check if we are using a mox machine
if [ $( uname -a | grep polimi ) ]; then MOX_MACHINE=1; fi
# set number of parallel builds to use
NUM_PROC=$(grep processor /proc/cpuinfo | wc -l)
if [ $NUM_PROC -gt 8 ]; then NUM_PROC=8; fi
echo "using $NUM_PROC parallel builds"
#! /bin/bash
#
# author: Antonio Cervone <ant.cervone@gmail.com>
# date: 22-03-2012
#
# include configuration file
source ../config
# abort if no package is specified
if [ $# -lt 1 ]; then
echo "usage: pkgbuild <package_list>"
exit
fi
# define list of library packages
package_list=("$@")
package_number=$#
main() {
# define list of library packages
#package_list=( "boost" "parmetis" "trilinos" )
#package_list=( "dummy" "parmetis" )
#package_list=( "dummy" )
echo
echo "installing to $INSTALL_DIR"
echo
package_root=$PWD
# iterate on packages
for(( i=0; i < $package_number; i++ )); do
package=${package_list[$i]}
echo "====================================="
echo " $i: installing $package package"
echo "====================================="
build_package $package || exit
done
}
build_package() {
package=$1
# load package specific functions
echo_dbg "loading pkgbuild_$package script"
source pkgbuild_$package || return 1
# redirect stdout to log file is requested
if [ $LOG ]; then exec >$BUILD_DIR/scratch/$package.log; fi
# set directory
mkdir -p $BUILD_DIR/scratch/$package
pushd $BUILD_DIR/scratch/$package >/dev/null
src_dir=$PWD/src
build_dir=$PWD/build
install_dir=$INSTALL_DIR/lib/$package
# download library sources
mkdir -p $src_dir
pushd src >/dev/null
if [ $DOWNLOAD ]; then
echo_dbg "downloading $package package"
download_$package || return 1
fi
# unpack
if [ $UNPACK ]; then
echo_dbg "unpacking $package package"
unpack_$package || return 1
fi
popd >/dev/null # $src_dir
# build
mkdir -p $build_dir
pushd build >/dev/null
echo_dbg "building $package package"
build_$package || return 1
# install
echo_dbg "installing $package package to $install_dir"
install_$package || return 1
popd >/dev/null # $build_dir
popd >/dev/null # $BUILD_DIR/scratch/$package
# clean build directory if RM_DIR defined
if [ $RM_TMP ]; then rm -rf $BUILD_DIR/scratch/$package; fi
}
echo_dbg() {
if [ $DBG ]; then echo "DBG: " $* >&2; fi
}
# execute main function
main
#! /bin/bash
#
# author: Antonio Cervone <ant.cervone@gmail.com>
# date: 23-03-2012
#
# this script takes care of just the headers, no library is compiled
ver="1.48.0"
download_boost() {
wget http://gitorious.org/boost/cmake/archive-tarball/cmake-${ver}
}
unpack_boost() {
mv cmake-${ver} boost-cmake-${ver}.tar.gz
tar xzf boost-cmake-${ver}.tar.gz
}
build_boost() {
:
}
install_boost() {
install -m 755 -d $install_dir
install -m 755 -d $install_dir/include
cp -r $src_dir/boost-cmake/boost $install_dir/include
}
#! /bin/bash
#
# author: Antonio Cervone <ant.cervone@gmail.com>
# date: 22-03-2012
#
ver="1.48.0"
download_boostlib() {
# wget http://gitorious.org/boost/cmake/archive-tarball/cmake-$ver
: # empty functions are not allowed!
}
unpack_boostlib() {
mv cmake-$ver boost-cmake-${ver}.tar.gz
tar xvf boost-cmake-${ver}.tar.gz
}
build_boostlib() {
cmake \
-DCMAKE_INSTALL_PREFIX=${install_dir} \
-DINSTALL_VERSIONED:BOOL=OFF \
${src_dir}/boost-cmake || return 1
make -j${NUM_PROC} || return 1
}
install_boostlib() {
make -j${NUM_PROC} install || return 1
}
#! /bin/bash
#
# author: Antonio Cervone <ant.cervone@gmail.com>
# date: 11-12-2012
#
ver="3.1"
download_clang() {
wget http://llvm.org/releases/${ver}/llvm-${ver}.src.tar.gz
wget http://llvm.org/releases/${ver}/clang-${ver}.src.tar.gz
wget http://llvm.org/releases/${ver}/compiler-rt-${ver}.src.tar.gz
}
unpack_clang() {
tar xzf llvm-${ver}.src.tar.gz
tar xzf clang-${ver}.src.tar.gz
mv clang-${ver}.src llvm-${ver}.src/tools/clang
tar xzf compiler-rt-${ver}.src.tar.gz
mv compiler-rt-${ver}.src llvm-${ver}.src/projects/compiler-rt
}
build_clang() {
# due to a bug in the compiler-rt package we need to add a fake CmakeLists.txt
touch ${src_dir}/llvm-${ver}.src/projects/compiler-rt/test/CMakeLists.txt
rm -f CMakeCache.txt
rm -fr CMakeFiles
${cmake_bin}/cmake \
-D CMAKE_BUILD_TYPE:STRING="Release" \
-D CMAKE_INSTALL_PREFIX:PATH=${install_dir} \
\
${src_dir}/llvm-${ver}.src
# -D LLVM_ENABLE_FFI:BOOL=ON \
# \
# -D FFI_INCLUDE_DIR:PATH="/usr/include/i386-linux-gnu" \
# -D FFI_LIBRARY_DIR:PATH="/usr/lib/i386-linux-gnu" \
# \
make -j${NUM_PROC}
}
install_clang() {
make -j${NUM_PROC} install
}
#! /bin/bash
#
# author: Antonio Cervone <ant.cervone@gmail.com>
# date: 11-12-2012
#
ver="2.8.10"
download_cmake() {
wget http://www.cmake.org/files/v2.8/cmake-${ver}.tar.gz
}
unpack_cmake() {
tar xzf cmake-${ver}.tar.gz
}
build_cmake() {
cd ${src_dir}/cmake-${ver}
./bootstrap --prefix=${install_dir} \
--parallel=${NUM_PROC}
# --system-libs \
make -j${NUM_PROC}
}
install_cmake() {
cd ${src_dir}/cmake-${ver}
make -j${NUM_PROC} install
}
#! /bin/bash
#
# author: Antonio Cervone <ant.cervone@gmail.com>
# date: 22-03-2012
#
download_dummy() {
cat > libdummy.hpp <<EOF
void foo();
EOF
cat > libdummy.cpp <<EOF
#include <iostream>
void foo()
{
std::cout << "this is foo" << std::endl;
}
EOF
}
unpack_dummy() {
echo no unpacking here...
}
build_dummy() {
cp $src_dir/* $build_dir
cat > Makefile <<EOF
SRCS=\$(wildcard *.cpp)
OBJS=\$(SRCS:.cpp=.o)
all: libdummy.a(\$(OBJS))
EOF
make || return 1
}
install_dummy() {
install -m 755 -d $install_dir
install -m 755 -d $install_dir/include
install -m 644 libdummy.hpp $install_dir/include
install -m 755 -d $install_dir/lib
install -m 644 libdummy.a $install_dir/lib
}
#! /bin/bash
#
# author: Antonio Cervone <ant.cervone@gmail.com>
# date: 11-12-2012
#
ver='1.8.8'
download_hdf5() {
wget "ftp://ftp.hdfgroup.org/HDF5/releases/hdf5-${ver}/src/hdf5-${ver}.tar.gz"
}
unpack_hdf5() {
tar xzf hdf5-${ver}.tar.gz