makeGperftools 3.53 KB
Newer Older
Henry's avatar
Henry committed
1 2 3 4 5 6
#!/bin/sh
#------------------------------------------------------------------------------
# =========                 |
# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
#  \\    /   O peration     |
#   \\  /    A nd           | Copyright (C) 2012 OpenFOAM Foundation
7
#    \\/     M anipulation  | Copyright (C) 2016-2018 OpenCFD Ltd.
Henry's avatar
Henry committed
8 9
#------------------------------------------------------------------------------
# License
Mark Olesen's avatar
Mark Olesen committed
10 11
#     This file is part of OpenFOAM, licensed under GNU General Public License
#     <http://www.gnu.org/licenses/>.
Henry's avatar
Henry committed
12 13 14 15 16 17 18
#
# Script
#     makeGperftools
#
# Description
#     Build script for gperftools
#
19 20
# ----------------------------------------------
# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
Henry's avatar
Henry committed
21
#------------------------------------------------------------------------------
22
# Run from third-party directory only
23
cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
24 25 26 27 28 29
    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
    echo "    Check your OpenFOAM environment and installation"
    exit 1
}
. etc/tools/ThirdPartyFunctions
#------------------------------------------------------------------------------
30

31
# Gperftools version from OpenFOAM etc/config.sh file:
32
_foamConfig gperftools
Henry's avatar
Henry committed
33

34
gperftoolsPACKAGE=${gperftools_version:-gperftools-system}
35

Henry's avatar
Henry committed
36 37 38 39 40 41 42
#------------------------------------------------------------------------------
usage() {
    exec 1>&2
    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
    cat<<USAGE

usage: ${0##*/} [gperftools-VERSION]
43 44 45
options:
  -gcc              Force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
  -help
Henry's avatar
Henry committed
46 47 48 49 50 51 52

* build gperftools
      $gperftoolsPACKAGE

USAGE
    exit 1
}
53
#------------------------------------------------------------------------------
54
exportCompiler          # Compiler info for CMake/configure
Henry's avatar
Henry committed
55

56
# Parse options
Henry's avatar
Henry committed
57 58 59
while [ "$#" -gt 0 ]
do
    case "$1" in
60 61 62 63
    '') ;;      # Ignore empty
    -h | -help) usage   ;;
    -gcc)       useGcc  ;;

64
    gperftools-[0-9]* | gperftools-svn* | gperftools-git)
Henry's avatar
Henry committed
65 66 67
        gperftoolsPACKAGE="${1%%/}"
        ;;
    *)
68
        die "unknown option/argument: '$1'"
Henry's avatar
Henry committed
69 70
        ;;
    esac
71
    shift
Henry's avatar
Henry committed
72 73
done

74
[ -n "$gperftoolsPACKAGE" ] || die "The gperftools-VERSION was not specified"
Henry's avatar
Henry committed
75

76 77 78 79 80 81 82 83 84 85 86 87
# Nothing to build
if _foamIsNone $gperftoolsPACKAGE
then
    echo "Using gperftools-none (skip ThirdParty build of gperftools)"
    exit 0
elif _foamIsSystem $gperftoolsPACKAGE
then
    echo "Using gperftools-system (skip ThirdParty build of gperftools)"
    exit 0
fi

#------------------------------------------------------------------------------
Henry's avatar
Henry committed
88 89 90
#
# Build gperftools
#
91
GPERFTOOLS_SOURCE_DIR=$sourceBASE/$gperftoolsPACKAGE
92 93
GPERFTOOLS_ARCH_PATH=$installBASE/$gperftoolsPACKAGE

Henry's avatar
Henry committed
94
echo "---------------"
95
if [ -d "$GPERFTOOLS_ARCH_PATH" ]
Henry's avatar
Henry committed
96 97 98 99
then
    echo "Already built: $gperftoolsPACKAGE"
else
    echo "Starting build: $gperftoolsPACKAGE"
100 101 102 103
    (
        buildDIR=$buildBASE/$gperftoolsPACKAGE

        cd $GPERFTOOLS_SOURCE_DIR || exit 1
104 105
        export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
        [ -e Makefile ] && make distclean 2>/dev/null
106 107 108 109 110 111 112 113 114

        rm -rf $GPERFTOOLS_ARCH_PATH
        rm -rf $buildDIR
        mkdir -p $buildDIR
        cd $buildDIR

        set -x
        $GPERFTOOLS_SOURCE_DIR/configure \
            --prefix=$GPERFTOOLS_ARCH_PATH \
115
        && set +x \
116 117 118 119 120 121 122
        && make -j $WM_NCOMPPROCS \
        && make install \
        && echo "Built: $gperftoolsPACKAGE" \
    ) || {
        echo "Error building: $gperftoolsPACKAGE"
        exit 1
    }
Henry's avatar
Henry committed
123 124
fi

125
#------------------------------------------------------------------------------