makeParaView 10.9 KB
Newer Older
Henry's avatar
Henry committed
1 2 3 4 5
#!/bin/sh
#------------------------------------------------------------------------------
# =========                 |
# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
#  \\    /   O peration     |
6
#   \\  /    A nd           | Copyright (C) 2011-2016 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
#
# Script
#     makeParaView
#
# Description
17
#     Make and install ParaView.
18 19 20 21 22
#     The ParaView sources should be located under one of these locations:
#       - $WM_THIRD_PARTY_DIR/ParaView-VERSION
#       - $WM_THIRD_PARTY_DIR/ParaView-vVERSION
#
#     Note the capitalization of ParaView in the directory names.
Henry's avatar
Henry committed
23
#
24 25
# ----------------------------------------------
# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
26
#------------------------------------------------------------------------------
27
# Run from third-party directory only
28
cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
29 30 31 32 33 34 35
    echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
    echo "    Check your OpenFOAM environment and installation"
    exit 1
}
. etc/tools/ThirdPartyFunctions
. etc/tools/ParaViewFunctions
#------------------------------------------------------------------------------
36

37 38 39
unset ParaView_VERSION                                   # Purge current values

# ParaView_VERSION from etc/config.sh file:
40
_foamConfig paraview
41 42 43 44 45 46 47 48

# Avoid any potential conflicts (especially if building from git)
if [ -d "$ParaView_DIR" ]
then
    _foamClean PATH "$ParaView_DIR"
    _foamClean LD_LIBRARY_PATH "$ParaView_DIR"
fi
unset ParaView_DIR ParaView_INCLUDE_DIR PV_PLUGIN_PATH
Henry's avatar
Henry committed
49

50 51 52 53 54 55 56
case "$ParaView_VERSION" in
[Pp]*)
    ParaView_VERSION="${ParaView_VERSION##*-}"  # Without "ParaView-" prefix
    ;;
esac
ParaView_VERSION="${ParaView_VERSION%%-*}"      # Without suffix (eg, -python)

Henry's avatar
Henry committed
57

58 59
# Set initial ParaView_MAJOR based on current value of ParaView_VERSION
setParaViewVersion ${ParaView_VERSION:-none}
Henry's avatar
Henry committed
60

61
# New rendering backend (starting with paraview 5.0).
62
withGL2=auto # auto-config based on version
63

64
#------------------------------------------------------------------------------
Henry's avatar
Henry committed
65
usage() {
66
    exec 1>&2
67
    : ${ParaView_VERSION:=none} # some dummy value for usage information
Henry's avatar
Henry committed
68 69 70
    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
    cat<<USAGE

71
usage: ${0##*/} [OPTION] [paraview-VERSION] [CMAKE-OPTION]
Henry's avatar
Henry committed
72
options:
73
  -gcc              force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
Henry's avatar
Henry committed
74
  -rebuild          for repeated builds (-make -install) *use with caution*
75 76
  -gl2              with new rendering backend (default: auto)
  -mesa             with mesa
77
  -mesa-prefix DIR  location of mesa installation (sets -mesa-include, -mesa-lib)
78 79 80
  -mesa-include DIR location of mesa headers (current: ${MESA_INCLUDE:-none})
  -mesa-lib PATH    path to mesa library     (current: ${MESA_LIBRARY:-none})
  -mpi              with mpi
81
  -mpi=N            with max 'N' mpi processes. N=0 for no upper-limit.
82
  -python           with python
83 84
  -python-include DIR
                    location of python headers (current: ${PYTHON_INCLUDE:-none})
85
  -python-lib PATH  path to python library (current: ${PYTHON_LIBRARY:-none})
86
  -cmake PATH       with cmake from the path given
Henry's avatar
Henry committed
87 88 89 90 91
  -qmake PATH       with the Qt version corresponding to the qmake path given
  -qt               with extra Qt gui support (if not already enabled)
  -qt-VER           with Qt version corresponding to
                        \$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/qt-VER/bin/qmake
  -verbose          verbose output in Makefiles
92
  -version VER      specify an alternative version (current: $ParaView_VERSION)
Henry's avatar
Henry committed
93
  -major   VER      specify an alternative major version for special builds
mark's avatar
mark committed
94
  -buildType NAME   specify the build type (default: Release)
95
  -suffix NAME      specify a suffix to distinguish the build
Henry's avatar
Henry committed
96 97
  -help

mark's avatar
mark committed
98
The -no-FEATURE option can be used to forcibly disable these features:
99
  -no-gl2 | -no-mesa | -no-mpi | -no-python | -no-qt
Henry's avatar
Henry committed
100 101 102

CMake options start with a capital letter and contain an '='.
For example,
103
    ${0##*/} BUILD_TESTING=ON
104
to add tests
Henry's avatar
Henry committed
105 106

For finer control, the build stages can be selected or deselected individually:
107
  -patch     -no-patch
Henry's avatar
Henry committed
108 109 110 111 112 113 114
  -config    -no-config
  -make      -no-make
  -install   -no-install


* Make and install paraview-$ParaView_VERSION located under
      \$WM_THIRD_PARTY_DIR/ParaView-$ParaView_VERSION
115
  ->  \$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/paraview-$ParaView_VERSION$BUILD_SUFFIX
Henry's avatar
Henry committed
116

117
To make a different paraview version, simply specify on the command-line.
118
For example,
119

120
    ./makeParaview 5.4.1
121

122 123
Or change the \$WM_PROJECT_DIR/etc/config.sh/paraview settings.

Henry's avatar
Henry committed
124 125 126 127
USAGE
    exit 1
}
#------------------------------------------------------------------------------
128
exportCompiler          # Compiler info for CMake/configure
Henry's avatar
Henry committed
129

130
# Various building stages
131
unset runPATCH runCONFIG runMAKE runINSTALL
Henry's avatar
Henry committed
132 133
runDEFAULT=true

134
# Parse options
Henry's avatar
Henry committed
135 136 137
while [ "$#" -gt 0 ]
do
    case "$1" in
138 139 140 141
    '') ;;      # Ignore empty
    -h | -help) usage   ;;
    -gcc)       useGcc  ;;

142
    [0-9]* | paraview-[0-9]* | ParaView-[0-9]*) # paraview version
143
        setParaViewVersion "${1%%/}"
144
        ;;
Henry's avatar
Henry committed
145 146 147
    [A-Z]*=*)            # cmake variables
        addCMakeVariable "$1"
        ;;
148 149 150 151 152 153 154
    -patch)              # stage 0: patch sources
        runPATCH=true
        unset runDEFAULT
        ;;
    -no-patch)
        runPATCH=false
        ;;
Henry's avatar
Henry committed
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
    -config)             # stage 1: config only
        runCONFIG=true
        unset runDEFAULT
        ;;
    -no-config)
        runCONFIG=false
        ;;
    -make)               # stage 2: make only
        runMAKE=true
        unset runDEFAULT
        ;;
    -no-make)
        runMAKE=false
        ;;
    -install)            # stage 3: install only
        runINSTALL=true
        unset runDEFAULT
        ;;
    -no-install)
        runINSTALL=false
        ;;
    -rebuild)            # shortcut for rebuilding
        runMAKE=true
        runINSTALL=true
        unset runDEFAULT
        ;;
181 182 183 184 185 186
    -gl2)
        withGL2=true
        ;;
    -no-gl2)
        withGL2=false
        ;;
Henry's avatar
Henry committed
187 188 189
    -mesa)
        withMESA=true
        ;;
190 191 192 193 194 195 196
    -osmesa)
        echo
        echo "The -osmesa option is currently ignored"
        echo
        # withMESA=true
        # withOSMESA=true
        ;;
Henry's avatar
Henry committed
197 198
    -no-mesa)
        withMESA=false
199
        withOSMESA=false
Henry's avatar
Henry committed
200
        ;;
201 202 203 204
    -mesa-prefix)
        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
        withMESA=true
        MESA_INCLUDE="${2%%/}/include"
205
        # Could be under (lib64 | lib)
206
        MESA_LIBRARY="${2%%/}/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so"
207
        [ -f "$MESA_LIBRARY" ] || MESA_LIBRARY="${2%%/}/lib/libOSMesa.so"
208 209
        shift
        ;;
Henry's avatar
Henry committed
210
    -mesa-include)
211
        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
212
        withMESA=true
213
        MESA_INCLUDE="${2%%/}"
214
        shift
Henry's avatar
Henry committed
215 216
        ;;
    -mesa-lib)
217
        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
218
        withMESA=true
219
        MESA_LIBRARY="${2%%/}"
220
        shift
Henry's avatar
Henry committed
221 222 223 224
        ;;
    -mpi)
        withMPI=true
        ;;
225 226 227 228
    -mpi=[0-9]*) # mpi and max mpi processes
        withMPI=true
        MPI_MAX_PROCS="${1##*=}"
        ;;
Henry's avatar
Henry committed
229 230 231 232 233 234 235 236 237
    -no-mpi)
        withMPI=false
        ;;
    -python)
        withPYTHON=true
        ;;
    -no-python)
        withPYTHON=false
        ;;
238 239 240 241 242 243
    -python-include)
        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
        withPYTHON=true
        PYTHON_INCLUDE="${2%%/}"
        shift
        ;;
Henry's avatar
Henry committed
244
    -python-lib)
245
        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
246
        withPYTHON=true
247
        PYTHON_LIBRARY="${2%%/}"
248
        shift
Henry's avatar
Henry committed
249 250
        ;;
    -cmake)
251
        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
252
        CMAKE_PATH="${2%%/}"
253
        shift
Henry's avatar
Henry committed
254 255
        ;;
    -qmake)
256
        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
257
        QMAKE_PATH="${2%%/}"
258
        shift
Henry's avatar
Henry committed
259 260 261 262 263 264 265 266
        ;;
    -qt)
        withQT=true
        ;;
    -no-qt)
        withQT=false
        ;;
    -qt-[1-9]*)
267
        withQT=true
Henry's avatar
Henry committed
268 269 270 271 272 273
        QMAKE_PATH="$installBASE/${1##-}"
        ;;
    -verbose)
        withVERBOSE=true
        ;;
    -version)
274
        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
275
        setParaViewVersion "${2%%/}"
276
        shift
Henry's avatar
Henry committed
277 278
        ;;
    -major)
279
        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
Henry's avatar
Henry committed
280
        export ParaView_MAJOR="$2"
281
        shift
Henry's avatar
Henry committed
282
        ;;
283
    -buildType)
284
        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
285
        BUILD_TYPE="$2"
286
        shift
287
        ;;
288 289 290 291 292
    -suffix)
        [ "$#" -ge 2 ] || die "'$1' option requires an argument"
        setBuildSuffix "$2"
        shift
        ;;
Henry's avatar
Henry committed
293
    *)
294
        die "unknown option/argument: '$1'"
Henry's avatar
Henry committed
295 296
        ;;
    esac
297
    shift
Henry's avatar
Henry committed
298 299
done

300 301
[ -n "$ParaView_VERSION" ] || die "The paraview-VERSION was not specified"

Mark Olesen's avatar
Mark Olesen committed
302
# Nothing to build
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
if _foamIsNone "$ParaView_VERSION"
then
    echo "Using paraview-none (skip ThirdParty build of ParaView)"
    exit 0
fi

# Version-specific adjustments
if [ "$withGL2" = auto ]
then
    if [ "${ParaView_VERSION%%.*}" = 4 ]
    then
        withGL2=false
    else
        withGL2=true
    fi
fi
Henry's avatar
Henry committed
319 320 321

if [ "$runDEFAULT" = true ]
then
322
    : ${runPATCH:=true}
Henry's avatar
Henry committed
323 324 325 326 327
    : ${runCONFIG:=true}
    : ${runMAKE:=true}
    : ${runINSTALL:=true}
fi

328 329 330 331 332 333 334 335 336 337
if [ "$withMESA" = true ]
then
    : ${withQT:=false}  # No QT unless explicitly requested
    addCMakeVariable "VTK_USE_X=OFF"
    # addCMakeVariable "OPENGL_INCLUDE_DIR=IGNORE"
    # addCMakeVariable "OPENGL_gl_LIBRARY=IGNORE"
    # addCMakeVariable "OPENGL_xmesa_INCLUDE_DIR=IGNORE"
    ## seems to be unnecessary => addCMakeVariable "VTK_USE_OFFSCREEN=OFF"
fi

Henry's avatar
Henry committed
338 339 340 341 342 343 344

# Set configure options
#~~~~~~~~~~~~~~~~~~~~~~
addVerbosity        # verbose makefiles
addMpiSupport       # set MPI-specific options
addPythonSupport    # set Python-specific options
addMesaSupport      # set MESA-specific options
345
addGL2Support       # new rendering backend
Henry's avatar
Henry committed
346 347
addQtSupport        # add extra Qt support

348
setParaViewDirs     # where things are or should be put
Henry's avatar
Henry committed
349 350 351 352 353 354 355 356


# Build and install
# ~~~~~~~~~~~~~~~~~
cat<<SUMMARY

Build stages selected
---------------------
357
    -patch    ${runPATCH:-false}
Henry's avatar
Henry committed
358 359 360 361 362 363 364 365 366 367 368
    -config   ${runCONFIG:-false}
    -make     ${runMAKE:-false}
    -install  ${runINSTALL:-false}
---------------------
Features selected
    mesa      ${withMESA:-false}
    mpi       ${withMPI:-false}
    python    ${withPYTHON:-false}
    qt        ${withQT:-false}
---------------------
Version information
369
    paraview  ${ParaView_VERSION:-unknown}
Henry's avatar
Henry committed
370
    major     ${ParaView_MAJOR:-unknown}
371
    build     ${BUILD_TYPE:-unknown}
372
    qt        ${QT_VERSION:-none}
Henry's avatar
Henry committed
373 374 375
---------------------
SUMMARY

376
[ "$runPATCH"   = true ] && patchParaView
Henry's avatar
Henry committed
377 378 379 380 381 382 383 384
[ "$runCONFIG"  = true ] && configParaView
[ "$runMAKE"    = true ] && makeParaView
[ "$runINSTALL" = true ] && installParaView

echo
echo Done

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