makeCCMIO 3.83 KB
Newer Older
1 2 3 4 5 6
#!/bin/sh
#------------------------------------------------------------------------------
# =========                 |
# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
#  \\    /   O peration     |
#   \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
7
#    \\/     M anipulation  | Copyright (C) 2016-2018 OpenCFD Ltd.
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/>.
12 13 14 15 16
#
# Script
#     makeCCMIO
#
# Description
17
#     Build the libccmio library
18
#
19 20
# ----------------------------------------------
# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
21
#------------------------------------------------------------------------------
22 23 24
# Dynamic library endings (default is .so)
[ "$(uname -s)" = Darwin ] && SO=dylib || SO=so

25
# Run from third-party directory only
26
cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
27 28
    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
    echo "    Check your OpenFOAM environment and installation"
29 30 31
    exit 1
}
[ -n "$FOAM_EXT_LIBBIN" ] || {
32 33
    echo "Error (${0##*/}) : \$FOAM_EXT_LIBBIN not set"
    echo "    Check your OpenFOAM environment and installation"
34 35 36 37
    exit 1
}
. etc/tools/ThirdPartyFunctions
#------------------------------------------------------------------------------
38 39

# libccmio version from OpenFOAM etc/config.sh file:
40
_foamConfig ccmio
41 42

ccmioPACKAGE=${ccmio_version:-libccmio-2.6.1}
43 44
targetType=lib  # Default is static linkage

45
#------------------------------------------------------------------------------
46 47 48 49 50 51 52 53
usage()
{
    exec 1>&2
    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
    /bin/cat<<USAGE

Usage: ${0##*/} [OPTION] [lib|libso] [libccmio-VERSION]
options:
54
  -gcc              Force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
55 56 57
  -help

* Compile the proprietary libccmio library
mark's avatar
mark committed
58
      $ccmioPACKAGE
59

60 61
  Users wishing to obtain the library should contact Siemens PLM (cd-adapco)
  for terms of use.
62

mark's avatar
mark committed
63
  After obtaining the $ccmioPACKAGE library, place in folder
64

mark's avatar
mark committed
65
      $WM_THIRD_PARTY_DIR/$ccmioPACKAGE/
66 67 68 69 70 71

  prior to running this script.

USAGE
    exit 1
}
72
#------------------------------------------------------------------------------
73 74 75 76 77

# Parse options
while [ "$#" -gt 0 ]
do
    case "$1" in
78 79 80 81
    '') ;;      # Ignore empty
    -h | -help) usage   ;;
    -gcc)       useGcc  ;;

82 83 84 85
    lib|libso)
        targetType="$1"
        ;;
    libccmio-[1-9]*)
mark's avatar
mark committed
86
        ccmioPACKAGE="${1%%/}"
87 88
        ;;
    *)
89
        die "unknown option/argument: '$1'"
90 91
        ;;
    esac
92
    shift
93 94
done

95 96
requireWMakeToolchain

97 98 99 100
#------------------------------------------------------------------------------
#
# Build LIBCCMIO
#
101 102 103 104 105 106
CCMIO_SOURCE_DIR=$sourceBASE/$ccmioPACKAGE
CCMIO_ARCH_PATH=$installBASE/$ccmioPACKAGE

# Sources must be available
[ -d "$CCMIO_SOURCE_DIR" ] || die "Missing sources: '$ccmioPACKAGE'"

107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
#
# Manual installation
#
install()
{
    # Ensure a clean build next time
    wclean

    local incdir=$CCMIO_ARCH_PATH/include/libccmio

    # Make headers available:
    mkdir -m 0755 -p $incdir

    /bin/cp -pv libccmio/ccmio*.h $incdir
}

echo "Starting build: $ccmioPACKAGE ($targetType)"
echo
125
(
126
    cd $CCMIO_SOURCE_DIR || exit 1
127 128
    export GIT_DIR=$PWD/.git # Mask seeing our own git-repo

129
    rm -rf $CCMIO_ARCH_PATH
130
    rm -f $FOAM_EXT_LIBBIN/libccmio.$SO
131

132
    libdir=$CCMIO_ARCH_PATH/lib
133 134

    cpMakeFiles libccmio 2>/dev/null
135 136 137 138

    # Place static libraries in sub-directory:
    if [ "$targetType" = lib ]
    then
139 140
        mkdir -m 0755 -p $libdir 2>/dev/null
        export FOAM_EXT_LIBBIN=$libdir
141 142
    fi

143 144 145 146 147 148 149
    wmake -j $WM_NCOMPPROCS -s $targetType \
    && echo "Built: ccmio" \
    && install
) || {
    echo "Error building: ccmio"
    exit 1
}
150 151

#------------------------------------------------------------------------------