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

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

# libccmio version from OpenFOAM etc/config.sh file:
42
_foamConfig ccmio
43 44

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

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

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

* Compile the proprietary libccmio library
60
      $ccmioPACKAGE
61

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

65
  After obtaining the $ccmioPACKAGE library, place in folder
66

67
      $WM_THIRD_PARTY_DIR/$ccmioPACKAGE/
68 69 70 71 72 73

  prior to running this script.

USAGE
    exit 1
}
74
#------------------------------------------------------------------------------
75 76 77 78 79

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

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

97 98
requireWMakeToolchain

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

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

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

131
    rm -rf $CCMIO_ARCH_PATH
132
    rm -f $FOAM_EXT_LIBBIN/libccmio$EXT_SO
133

134
    libdir=$CCMIO_ARCH_PATH/lib
135 136

    cpMakeFiles libccmio 2>/dev/null
137 138 139 140

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

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

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