makeCCMIO 3.66 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
#     Copyright (C) 2011-2016 OpenFOAM Foundation
Mark Olesen's avatar
Mark Olesen committed
10
#     Copyright (C) 2016-2020 OpenCFD Ltd.
11 12
#------------------------------------------------------------------------------
# License
Mark Olesen's avatar
Mark Olesen committed
13
#     This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
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
# Run from third-party directory only
25 26
cd "${0%/*}" || exit
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 32
    exit 1
}
. etc/tools/ThirdPartyFunctions
#------------------------------------------------------------------------------
33 34

# libccmio version from OpenFOAM etc/config.sh file:
35
_foamConfig ccmio
36 37

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

40
#------------------------------------------------------------------------------
41 42 43 44 45 46 47 48
usage()
{
    exec 1>&2
    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
    /bin/cat<<USAGE

Usage: ${0##*/} [OPTION] [lib|libso] [libccmio-VERSION]
options:
49
  -gcc          Force use of gcc/g++
50 51 52
  -help

* Compile the proprietary libccmio library
mark's avatar
mark committed
53
      $ccmioPACKAGE
54

55 56
  Users wishing to obtain the library should contact Siemens PLM (cd-adapco)
  for terms of use.
57

mark's avatar
mark committed
58
  After obtaining the $ccmioPACKAGE library, place in folder
59

mark's avatar
mark committed
60
      $WM_THIRD_PARTY_DIR/$ccmioPACKAGE/
61 62 63 64

  prior to running this script.

USAGE
65
    showDownloadHint CCMIO
66 67
    exit 1
}
68
#------------------------------------------------------------------------------
69 70 71 72 73

# Parse options
while [ "$#" -gt 0 ]
do
    case "$1" in
74 75 76 77
    '') ;;      # Ignore empty
    -h | -help) usage   ;;
    -gcc)       useGcc  ;;

78 79 80
    lib|libso)
        targetType="$1"
        ;;
Mark Olesen's avatar
Mark Olesen committed
81
    libccmio-[0-9]*)
mark's avatar
mark committed
82
        ccmioPACKAGE="${1%%/}"
83 84
        ;;
    *)
85
        die "unknown option/argument: '$1'"
86 87
        ;;
    esac
88
    shift
89 90
done

91
requireWMakeToolchain
92
requireExtLibBin
93

94 95 96 97
#------------------------------------------------------------------------------
#
# Build LIBCCMIO
#
98 99 100 101 102 103
CCMIO_SOURCE_DIR=$sourceBASE/$ccmioPACKAGE
CCMIO_ARCH_PATH=$installBASE/$ccmioPACKAGE

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

104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
#
# 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
122
(
123 124
    cd "$CCMIO_SOURCE_DIR" || exit
    export GIT_DIR="$PWD/.git" # Mask seeing our own git-repo
125

126
    rm -rf $CCMIO_ARCH_PATH
127
    rm -f $FOAM_EXT_LIBBIN/libccmio$EXT_SO
128

129
    libdir=$CCMIO_ARCH_PATH/lib
130 131

    cpMakeFiles libccmio 2>/dev/null
132 133 134 135

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

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

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