makeParaView 10.8 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 41 42 43 44 45 46 47 48
_foamEtc -config paraview

# 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
ParaView_VERSION="${ParaView_VERSION##*-}"               # Without prefix
Henry's avatar
Henry committed
51

52 53
# Set initial ParaView_MAJOR based on current value of ParaView_VERSION
setParaViewVersion ${ParaView_VERSION:-none}
Henry's avatar
Henry committed
54

55
# New rendering backend (starting with paraview 5.0).
56
withGL2=auto # auto-config based on version
57

58
#------------------------------------------------------------------------------
Henry's avatar
Henry committed
59
usage() {
60
    exec 1>&2
61
    : ${ParaView_VERSION:=none} # some dummy value for usage information
Henry's avatar
Henry committed
62 63 64
    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
    cat<<USAGE

65
usage: ${0##*/} [OPTION] [paraview-VERSION] [CMAKE-OPTION]
Henry's avatar
Henry committed
66
options:
67
  -gcc              force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
Henry's avatar
Henry committed
68
  -rebuild          for repeated builds (-make -install) *use with caution*
69 70
  -gl2              with new rendering backend (default: auto)
  -mesa             with mesa
71
  -mesa-prefix DIR  location of mesa installation (sets -mesa-include, -mesa-lib)
72 73 74
  -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
75
  -mpi=N            with max 'N' mpi processes. N=0 for no upper-limit.
76
  -python           with python
77 78
  -python-include DIR
                    location of python headers (current: ${PYTHON_INCLUDE:-none})
79
  -python-lib PATH  path to python library (current: ${PYTHON_LIBRARY:-none})
80
  -cmake PATH       with cmake from the path given
Henry's avatar
Henry committed
81 82 83 84 85
  -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
86
  -version VER      specify an alternative version (current: $ParaView_VERSION)
Henry's avatar
Henry committed
87
  -major   VER      specify an alternative major version for special builds
mark's avatar
mark committed
88
  -buildType NAME   specify the build type (default: Release)
89
  -suffix NAME      specify a suffix to distinguish the build
Henry's avatar
Henry committed
90 91
  -help

mark's avatar
mark committed
92
The -no-FEATURE option can be used to forcibly disable these features:
93
  -no-gl2 | -no-mesa | -no-mpi | -no-python | -no-qt
Henry's avatar
Henry committed
94 95 96

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

For finer control, the build stages can be selected or deselected individually:
101
  -patch     -no-patch
Henry's avatar
Henry committed
102 103 104 105 106 107 108
  -config    -no-config
  -make      -no-make
  -install   -no-install


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

111
To make a different paraview version, simply specify on the command-line.
112
For example,
113

114
    ./makeParaview 5.4.1
115

116 117
Or change the \$WM_PROJECT_DIR/etc/config.sh/paraview settings.

Henry's avatar
Henry committed
118 119 120 121
USAGE
    exit 1
}
#------------------------------------------------------------------------------
122
exportCompiler          # Compiler info for CMake/configure
Henry's avatar
Henry committed
123

124
# Various building stages
125
unset runPATCH runCONFIG runMAKE runINSTALL
Henry's avatar
Henry committed
126 127
runDEFAULT=true

128
# Parse options
Henry's avatar
Henry committed
129 130 131
while [ "$#" -gt 0 ]
do
    case "$1" in
132 133 134 135
    '') ;;      # Ignore empty
    -h | -help) usage   ;;
    -gcc)       useGcc  ;;

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

294 295
[ -n "$ParaView_VERSION" ] || die "The paraview-VERSION was not specified"

Mark Olesen's avatar
Mark Olesen committed
296
# Nothing to build
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
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
313 314 315

if [ "$runDEFAULT" = true ]
then
316
    : ${runPATCH:=true}
Henry's avatar
Henry committed
317 318 319 320 321
    : ${runCONFIG:=true}
    : ${runMAKE:=true}
    : ${runINSTALL:=true}
fi

322 323 324 325 326 327 328 329 330 331
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
332 333 334 335 336 337 338

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

342
setParaViewDirs     # where things are or should be put
Henry's avatar
Henry committed
343 344 345 346 347 348 349 350


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

Build stages selected
---------------------
351
    -patch    ${runPATCH:-false}
Henry's avatar
Henry committed
352 353 354 355 356 357 358 359 360 361 362
    -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
363
    paraview  ${ParaView_VERSION:-unknown}
Henry's avatar
Henry committed
364
    major     ${ParaView_MAJOR:-unknown}
365
    build     ${BUILD_TYPE:-unknown}
366
    qt        ${QT_VERSION:-none}
Henry's avatar
Henry committed
367 368 369
---------------------
SUMMARY

370
[ "$runPATCH"   = true ] && patchParaView
Henry's avatar
Henry committed
371 372 373 374 375 376 377 378
[ "$runCONFIG"  = true ] && configParaView
[ "$runMAKE"    = true ] && makeParaView
[ "$runINSTALL" = true ] && installParaView

echo
echo Done

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