OpenFOAM: v1912 released! - For more information see https://www.openfoam.com/releases/openfoam-v1912

makeCCMIO 3.92 KB
Newer Older
1 2 3 4 5
#!/bin/sh
#------------------------------------------------------------------------------
# =========                 |
# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
#  \\    /   O peration     |
6
#   \\  /    A nd           | www.openfoam.com
OpenFOAM bot's avatar
OpenFOAM bot committed
7 8
#    \\/     M anipulation  |
#------------------------------------------------------------------------------
9 10
#     Copyright (C) 2011-2016 OpenFOAM Foundation
#     Copyright (C) 2016-2019 OpenCFD Ltd.
11 12
#------------------------------------------------------------------------------
# License
Mark Olesen's avatar
Mark Olesen committed
13 14
#     This file is part of OpenFOAM, licensed under GNU General Public License
#     <http://www.gnu.org/licenses/>.
15 16 17 18 19
#
# Script
#     makeCCMIO
#
# Description
20
#     Build the libccmio library
21
#
22 23
# ----------------------------------------------
# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
24
#------------------------------------------------------------------------------
25 26
# Dynamic library ending (default is .so)
[ "$(uname -s)" = Darwin ] && EXT_SO=.dylib || EXT_SO=.so
27

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

# libccmio version from OpenFOAM etc/config.sh file:
44
_foamConfig ccmio
45 46

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

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

Usage: ${0##*/} [OPTION] [lib|libso] [libccmio-VERSION]
options:
58
  -gcc          Force use of gcc/g++
59 60 61
  -help

* Compile the proprietary libccmio library
62
      $ccmioPACKAGE
63

64 65
  Users wishing to obtain the library should contact Siemens PLM (cd-adapco)
  for terms of use.
66

67
  After obtaining the $ccmioPACKAGE library, place in folder
68

69
      $WM_THIRD_PARTY_DIR/$ccmioPACKAGE/
70 71 72 73 74 75

  prior to running this script.

USAGE
    exit 1
}
76
#------------------------------------------------------------------------------
77 78 79 80 81

# Parse options
while [ "$#" -gt 0 ]
do
    case "$1" in
82 83 84 85
    '') ;;      # Ignore empty
    -h | -help) usage   ;;
    -gcc)       useGcc  ;;

86 87 88 89
    lib|libso)
        targetType="$1"
        ;;
    libccmio-[1-9]*)
90
        ccmioPACKAGE="${1%%/}"
91 92
        ;;
    *)
93
        die "unknown option/argument: '$1'"
94 95
        ;;
    esac
96
    shift
97 98
done

99 100
requireWMakeToolchain

101 102 103 104
#------------------------------------------------------------------------------
#
# Build LIBCCMIO
#
105 106 107 108 109 110
CCMIO_SOURCE_DIR=$sourceBASE/$ccmioPACKAGE
CCMIO_ARCH_PATH=$installBASE/$ccmioPACKAGE

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

111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
#
# 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
129
(
130 131
    cd "$CCMIO_SOURCE_DIR" || exit
    export GIT_DIR="$PWD/.git" # Mask seeing our own git-repo
132

133
    rm -rf $CCMIO_ARCH_PATH
134
    rm -f $FOAM_EXT_LIBBIN/libccmio$EXT_SO
135

136
    libdir=$CCMIO_ARCH_PATH/lib
137 138

    cpMakeFiles libccmio 2>/dev/null
139 140 141 142

    # Place static libraries in sub-directory:
    if [ "$targetType" = lib ]
    then
143 144
        mkdir -m 0755 -p $libdir 2>/dev/null
        export FOAM_EXT_LIBBIN=$libdir
145 146
    fi

147 148 149 150 151 152 153
    wmake -j $WM_NCOMPPROCS -s $targetType \
    && echo "Built: ccmio" \
    && install
) || {
    echo "Error building: ccmio"
    exit 1
}
154 155

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