File: foamConfigurePaths

package info (click to toggle)
openfoam 1912.200626-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 238,956 kB
  • sloc: cpp: 1,159,641; sh: 15,902; ansic: 5,195; lex: 660; xml: 387; python: 282; awk: 212; makefile: 103; sed: 88; csh: 3
file content (845 lines) | stat: -rwxr-xr-x 23,480 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
#!/bin/sh
#------------------------------------------------------------------------------
# =========                 |
# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
#  \\    /   O peration     |
#   \\  /    A nd           | www.openfoam.com
#    \\/     M anipulation  |
#------------------------------------------------------------------------------
#     Copyright (C) 2011-2016 OpenFOAM Foundation
#     Copyright (C) 2016-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
#     This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
#     foamConfigurePaths
#
# Description
#     Adjust hardcoded installation versions and paths
#     in etc/{bashrc,cshrc} and etc/config.{sh,csh}/
#
# Requires
#     - sed
#     - bin/foamEtcFile
#
# Environment
#     FOAM_CONFIG_ETC
#         Alternative etc directory for shipped files
#
#------------------------------------------------------------------------------
printHelp() {

    case "$1" in
    (*compat*)
        cat<<HELP_COMPAT
Obsolete options:
  -foamInstall DIR    [obsolete]
  -projectName NAME   [obsolete]
  -sigfpe|-no-sigfpe  [obsolete - now under etc/controlDict]
  -archOption 32|64   [obsolete setting of 'WM_ARCH_OPTION' - edit manually]

Equivalent options:
  -version -foamVersion --projectVersion
  -archOption           --archOption
  -third                -ThirdParty
  -paraview             --paraviewVersion | -paraviewVersion
  -paraview-path        --paraviewInstall | -paraviewInstall
  -scotch               --scotchVersion | -scotchVersion
  -scotch-path          --scotchArchPath | -scotchArchPath
  -system-compiler      -system
  -third-compiler       -third

HELP_COMPAT
        exit 0 # A clean exit
        ;;
    esac

    cat<<HELP_HEAD

usage: $0 options

Options
  -h | -help          Display short help and exit
  -help-compat        Display compatibility options and exit
  -help-full          Display full help and exit

Basic
  -etc=DIR            set FOAM_CONFIG_ETC for alternative project files
  -project-path DIR   specify 'WM_PROJECT_DIR' (eg, /opt/openfoam1806-patch1)
  -version VER        specify project version (eg, v1806)
  -sp | -SP | -float32 single precision (WM_PRECISION_OPTION)
  -dp | -DP | -float64 double precision (WM_PRECISION_OPTION)
  -spdp | -SPDP       mixed precision (WM_PRECISION_OPTION)
  -int32 | -int64     label-size (WM_LABEL_SIZE)

Compiler
  -system-compiler NAME The 'system' compiler to use (eg, Gcc, Clang, Icc,...)
  -third-compiler NAME  The 'ThirdParty' compiler to use (eg, Clang40,...)
  -gcc VER            The 'default_gcc_version' for ThirdParty Gcc
  -clang VER          The 'default_clang_version' for ThirdParty Clang
  gmp-VERSION         For ThirdParty gcc (gmp-system for system library)
  mpfr-VERSION        For ThirdParty gcc (mpfr-system for system library)
  mpc-VERSION         For ThirdParty gcc (mpc-system for system library)

MPI
  -mpi NAME           specify 'WM_MPLIB' type (eg, INTELMPI, etc)
  -openmpi VER        use ThirdParty openmpi, with version for 'FOAM_MPI'
  -openmpi-system     use system openmpi
  -openmpi-third      use ThirdParty openmpi (using default version)

Components versions (ThirdParty)
  -adios VER          specify 'adios2_version'
  -boost VER          specify 'boost_version'
  -cgal VER           specify 'cgal_version'
  -cmake VER          specify 'cmake_version'
  -fftw VER           specify 'fffw_version'
  -kahip VER          specify 'KAHIP_VERSION'
  -metis VER          specify 'METIS_VERSION'
  -scotch VER         specify 'SCOTCH_VERSION' (eg, scotch_6.0.4)

HELP_HEAD

    case "$1" in
    (*full*)
        cat<<HELP_FULL
Components specified by absolute path
  -adios-path DIR     Path for 'ADIOS2_ARCH_PATH' (overrides -adios)
  -boost-path DIR     Path for 'BOOST_ARCH_PATH'  (overrides -boost)
  -cgal-path DIR      Path for 'CGAL_ARCH_PATH'   (overrides -cgal)
  -cmake-path DIR     Path for 'CMAKE_ARCH_PATH'  (overrides -cmake)
  -fftw-path DIR      Path for 'FFTW_ARCH_PATH'   (overrides -fftw)
  -kahip-path DIR     Path for 'KAHIP_ARCH_PATH'  (overrides -kahip)
  -metis-path DIR     Path for 'METIS_ARCH_PATH'  (overrides -metis)
  -scotch-path DIR    Path for 'SCOTCH_ARCH_PATH' (overrides -scotch)

Graphics
  -paraview VER       specify 'ParaView_VERSION' (eg, 5.4.1 or system)
  -paraview-qt VER    specify 'ParaView_QT' (eg, qt-system)
  -paraview-path DIR  specify 'ParaView_DIR' (eg, /opt/ParaView-5.4.1)
  -llvm VER           specify 'mesa_llvm'
  -mesa VER           specify 'mesa_version' (eg, mesa-13.0.1)
  -vtk  VER           specify 'vtk_version' (eg, VTK-7.1.0)
  -llvm-path DIR      Path for 'LLVM_ARCH_PATH'   (overrides -llvm)
  -mesa-path DIR      Path for 'MESA_ARCH_PATH'   (overrides -mesa)
  -vtk-path DIR       Path for 'VTK_DIR'          (overrides -vtk)

HELP_FULL
        ;;
    esac

    cat<<HELP_TAIL_COMMON
Adjusts hardcoded versions and installation paths (POSIX and C-shell)
for OpenFOAM.

HELP_TAIL_COMMON

    exit 0 # A clean exit
}


# Report error and exit
die()
{
    exec 1>&2
    echo
    echo "Error encountered:"
    while [ "$#" -ge 1 ]; do echo "    $1"; shift; done
    echo
    echo "See '$0 -help' for usage"
    echo
    exit 1
}

# -----------------------------------------------------------------------------
projectDir="$(\pwd -L)"     # Project dir

# Check that it appears to be an OpenFOAM installation
if [ -f etc/bashrc ] && [ -d "META-INFO" ]
then
    echo "Configuring OpenFOAM ($projectDir)" 1>&2
else
    die "Please run from the OpenFOAM top-level installation directory" \
        "No etc/bashrc or META-INFO/ found"
fi

# Use foamEtcFile to locate files, but only edit shipped files
if [ -x bin/foamEtcFile ]
then
    _foamEtc() {
        ./bin/foamEtcFile -mode=o "$@"
    }
else
    die "No bin/foamEtcFile found in installation"
fi


# Check if argument matches the expected input. Respects case.
# Uses sed for consistency with the replacement routines.
#
# _matches <arg> <matcher> [... <matcherN>]
#
_matches()
{
    local input="$1"
    shift
    local result
    for regexp
    do
        result=$(echo "$input" | sed -ne "/^$regexp"'$/p')
        test -n "$result" && return 0  # successful match
    done
    return 1
}


# Function to do replacement on file. Checks if any replacement has been done.
# _inlineSed <file> <regexp> <replacement> <msg>
_inlineSed()
{
    local file="$1"
    local regexp="$2"
    local replacement="$3"
    local msg="$4"
    local cmd='/^[^#]/s@'"$regexp"'@'"$replacement"'@'
    local localFile

    [ -f "$file" ] || {
        echo "Missing file: $file"
        exit 2 # Fatal
    }

    # Local filename (for reporting)
    localFile="$(echo "$file" | sed -e "s#^$projectDir/##")"

    grep -q "$regexp" "$file" && sed -i -e "$cmd" "$file" || { \
        echo "Failed: ${msg:-replacement} in $localFile"
        return 1
    }

    [ -n "$msg" ] && echo "    $msg  ($localFile)"

    return 0
}


# Standard <key> <val> type of replacements.
# replace <file> <key1> <val1> .. <keyN> <valN>
# looks for KEYWORD=.*
replace()
{
    local file="$1"
    shift

    local key val

    while [ "$#" -ge 2 ]
    do
        key=$1
        val=$2
        shift 2

        _inlineSed \
            "$file"  \
            "$key=.*" \
            "$key=$val" \
            "Replaced $key by '$val'"
    done
}

# Standard <key> <val> type of replacements.
# replace <file> <key1> <val1> .. <keyN> <valN>
# looks for "setenv KEYWORD value"
# but avoids "setenv KEYWORD" without a value
replaceCsh()
{
    local file="$1"
    shift

    local key val

    while [ "$#" -ge 2 ]
    do
        key=$1
        val=$2
        shift 2

        _inlineSed \
            "$file"  \
            "setenv [ ]*$key [^ #]*" \
            "setenv $key $val" \
            "Replaced $key by '$val'"
    done
}

# Locate file with foamEtcFile -mode=o and forward to replace()
replaceEtc()
{
    local file="$1"
    shift

    file=$(_foamEtc "$file")
    replace $file "$@"
}


# Locate file with foamEtcFile -mode=o and forward to replaceCsh()
replaceEtcCsh()
{
    local file="$1"
    shift

    file=$(_foamEtc "$file")
    replaceCsh $file "$@"
}


# Get the option's value (argument), or die on missing or empty argument
# $1 option
# $2 value
getOptionValue()
{
   [ -n "$2" ] || die "'$1' option requires an argument"
   echo "$2"
}


# Remove BASH_SOURCE and projectDir=... magic that looks like this:
# ----
#     projectDir=$BASH_SOURCE
#     [ -n "$projectDir" ] && projectDir= ...
#     projectDir=...
# ----
removeBashMagic()
{
    local file="$1"

    [ -f "$file" ] || {
        echo "Missing file: $file"
        exit 2 # Fatal
    }

    echo "    Remove automatic projectDir setting ($file)"

    sed -i \
        -e '/^ *#/!{/\(BASH_SOURCE\|projectDir=\)/s/^/##IGNORE## /}' \
        "$file"
}


# Remove set projectName=, set projectDir= magic that looks like this:
# ----
# set projectName="$WM_PROJECT"
# set projectDir=`lsof +p $$ |& \
#     sed -ne 'something /etc/cshrc something'`
# ----
removeCshMagic()
{
    local file="$1"

    [ -f "$file" ] || {
        echo "Missing file: $file"
        exit 2 # Fatal
    }

    echo "    Remove automatic projectDir setting ($file)"

    sed -i \
        -e '/^ *#/!{\@\(projectName=\|projectDir=\|/etc/cshrc\)@s/^/##IGNORE## /}' \
        "$file"
}


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

unset adjusted optMpi
# Parse options
while [ "$#" -gt 0 ]
do
    case "$1" in
    -help-c*)   # Compat help
        printHelp -compat
        ;;
    -help-f*)   # Full help
        printHelp -full
        ;;
    -h | -help*) # Short help
        printHelp
        ;;
    '')
        # Discard empty arguments
        ;;

    -debug-list)
        # Undocumented (experimental)
        # TDB: List files that can be edited by this script
        cat << CONFIG_SH
etc/bashrc
etc/config.sh/adios2
etc/config.sh/compiler
etc/config.sh/paraview
etc/config.sh/vtk
etc/config.sh/CGAL
etc/config.sh/FFTW
etc/config.sh/metis
etc/config.sh/kahip
etc/config.sh/scotch
CONFIG_SH

        cat << CONFIG_CSH
etc/cshrc
etc/config.csh/adios2
etc/config.csh/compiler
etc/config.csh/paraview
etc/config.csh/vtk
etc/config.csh/CGAL
etc/config.csh/FFTW
CONFIG_CSH
        exit 0
        ;;

## Basic ##

   -etc=*)
        # Define FOAM_CONFIG_ETC for finding files
        export FOAM_CONFIG_ETC="${1#*=}"
        ;;

   -project-path)
        # Replace WM_PROJECT_DIR=...
        optionValue=$(getOptionValue "$@")
        replaceEtc     bashrc  WM_PROJECT_DIR "\"$optionValue\""
        replaceEtcCsh  cshrc   WM_PROJECT_DIR "\"$optionValue\""

        removeBashMagic $(_foamEtc bashrc)
        removeCshMagic  $(_foamEtc cshrc)

        adjusted=true
        shift
        ;;

   -version | -foamVersion | --projectVersion)
        # Replace WM_PROJECT_VERSION=...
        optionValue=$(getOptionValue "$@")
        replaceEtc     bashrc  WM_PROJECT_VERSION "$optionValue"
        replaceEtcCsh  cshrc   WM_PROJECT_VERSION "$optionValue"
        adjusted=true
        shift
        ;;

    -archOption | --archOption)
        # Replace WM_ARCH_OPTION=...
        optionValue=$(getOptionValue "$@")
        echo "Ignoring $1 option: no longer supported" 1>&2
        shift
        ;;

    -sp | -SP | -float32)
        # Replace WM_PRECISION_OPTION=...
        replaceEtc     bashrc  WM_PRECISION_OPTION "SP"
        replaceEtcCsh  cshrc   WM_PRECISION_OPTION "SP"
        adjusted=true
        ;;

    -dp | -DP | -float64)
        # Replace WM_PRECISION_OPTION=...
        replaceEtc     bashrc  WM_PRECISION_OPTION "DP"
        replaceEtcCsh  cshrc   WM_PRECISION_OPTION "DP"
        adjusted=true
        ;;

    -spdp | -SPDP)
        # Replace WM_PRECISION_OPTION=...
        replaceEtc     bashrc  WM_PRECISION_OPTION "SPDP"
        replaceEtcCsh  cshrc   WM_PRECISION_OPTION "SPDP"
        adjusted=true
        ;;

    -int32 | -int64)
        # Replace WM_LABEL_SIZE=...
        optionValue="${1#-int}"
        replaceEtc     bashrc  WM_LABEL_SIZE "$optionValue"
        replaceEtcCsh  cshrc   WM_LABEL_SIZE "$optionValue"
        adjusted=true
        ;;


## Compiler ##

    -clang)
        # Replace default_clang_version=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  config.sh/compiler   default_clang_version "$optionValue"
        replaceEtc  config.csh/compiler  default_clang_version "$optionValue"
        adjusted=true
        shift
        ;;

    -gcc)
        # Replace default_gcc_version=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  config.sh/compiler   default_gcc_version "$optionValue"
        replaceEtc  config.csh/compiler  default_gcc_version "$optionValue"
        adjusted=true
        shift
        ;;

    -system-compiler | -system)
        # Replace WM_COMPILER_TYPE=... and WM_COMPILER=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  bashrc  \
            WM_COMPILER_TYPE system \
            WM_COMPILER "$optionValue"
        replaceEtcCsh  cshrc \
            WM_COMPILER_TYPE system \
            WM_COMPILER "$optionValue"
        adjusted=true
        shift
        ;;

    -third-compiler | -third | -ThirdParty)
        # Replace WM_COMPILER_TYPE=... and WM_COMPILER=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  bashrc  \
            WM_COMPILER_TYPE ThirdParty \
            WM_COMPILER "$optionValue"
        replaceEtcCsh  cshrc  \
            WM_COMPILER_TYPE ThirdParty \
            WM_COMPILER "$optionValue"
        adjusted=true
        shift
        ;;

    gmp-[4-9]* | gmp-system)
        # gcc-related package
        replaceEtc  config.sh/compiler   default_gmp_version "$1"
        replaceEtc  config.csh/compiler  default_gmp_version "$1"
        adjusted=true
        ;;

    mpfr-[2-9]* | mpfr-system)
        # gcc-related package
        replaceEtc  config.sh/compiler   default_mpfr_version "$1"
        replaceEtc  config.csh/compiler  default_mpfr_version "$1"
        adjusted=true
        ;;

    mpc-[0-9]* | mpc-system)
        # gcc-related package
        replaceEtc  config.sh/compiler   default_mpc_version "$1"
        replaceEtc  config.csh/compiler  default_mpc_version "$1"
        adjusted=true
        ;;


## MPI ##

    -mpi)
        # Explicitly set WM_MPLIB=...
        optionValue=$(getOptionValue "$@")
        replaceEtc     bashrc  WM_MPLIB "$optionValue"
        replaceEtcCsh  cshrc   WM_MPLIB "$optionValue"
        optMpi=system
        adjusted=true
        shift
        ;;

    -openmpi)
        # Replace FOAM_MPI=openmpi-<digits>.. and set to use third-party
        #  The edit is slightly fragile, but works
        expected="openmpi-[1-9][.0-9]*"
        optMpi=$(getOptionValue "$@")

        _matches "$optMpi" "$expected" || \
            die "'$1' has bad value: '$optMpi'"

        _inlineSed  $(_foamEtc config.sh/mpi) \
            "FOAM_MPI=$expected" \
            "FOAM_MPI=$optMpi" \
            "Replaced 'FOAM_MPI=$expected' by 'FOAM_MPI=$optMpi'"

        _inlineSed  $(_foamEtc config.csh/mpi) \
            "FOAM_MPI $expected" \
            "FOAM_MPI $optMpi" \
            "Replaced 'FOAM_MPI $expected' by 'FOAM_MPI $optMpi'"

        replaceEtc     bashrc  WM_MPLIB OPENMPI
        replaceEtcCsh  cshrc   WM_MPLIB OPENMPI
        adjusted=true
        shift
        ;;

    -openmpi-system)
        # Explicitly set WM_MPLIB=SYSTEMOPENMPI
        replaceEtc     bashrc  WM_MPLIB SYSTEMOPENMPI
        replaceEtcCsh  cshrc   WM_MPLIB SYSTEMOPENMPI
        optMpi=system
        adjusted=true
        ;;

    -openmpi-third)
        # Explicitly set WM_MPLIB=OPENMPI, using default setting for openmpi
        replaceEtc     bashrc  WM_MPLIB OPENMPI
        replaceEtcCsh  cshrc   WM_MPLIB OPENMPI
        optMpi=third
        adjusted=true
        ;;


## Components ##

    -adios | -adios2)
        # Replace adios2_version=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  config.sh/adios2   adios2_version "$optionValue"
        replaceEtc  config.csh/adios2  adios2_version "$optionValue"
        adjusted=true
        shift
        ;;

    -adios-path | -adios2-path)
        # Replace ADIOS2_ARCH_PATH=...
        optionValue=$(getOptionValue "$@")
        replaceEtc     config.sh/adios2   ADIOS2_ARCH_PATH "\"$optionValue\""
        replaceEtcCsh  config.csh/adios2  ADIOS2_ARCH_PATH "\"$optionValue\""
        adjusted=true
        shift
        ;;

    -boost)
        # Replace boost_version=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  config.sh/CGAL   boost_version "$optionValue"
        replaceEtc  config.csh/CGAL  boost_version "$optionValue"
        adjusted=true
        shift
        ;;

    -boost-path)
        # Replace BOOST_ARCH_PATH=...
        optionValue=$(getOptionValue "$@")
        replaceEtc     config.sh/CGAL   BOOST_ARCH_PATH "\"$optionValue\""
        replaceEtcCsh  config.csh/CGAL  BOOST_ARCH_PATH "\"$optionValue\""
        adjusted=true
        shift
        ;;

    -cgal)
        # Replace cgal_version=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  config.sh/CGAL   cgal_version "$optionValue"
        replaceEtc  config.csh/CGAL  cgal_version "$optionValue"
        adjusted=true
        shift
        ;;

    -cgal-path)
        # Replace CGAL_ARCH_PATH=...
        optionValue=$(getOptionValue "$@")
        replaceEtc     config.sh/CGAL   CGAL_ARCH_PATH "$optionValue"
        replaceEtcCsh  config.csh/CGAL  CGAL_ARCH_PATH "$optionValue"
        adjusted=true
        shift
        ;;

    -fftw)
        # Replace fftw_version=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  config.sh/FFTW   fftw_version "$optionValue"
        replaceEtc  config.csh/FFTW  fftw_version "$optionValue"
        adjusted=true
        shift
        ;;

    -fftw-path)
        # Replace FFTW_ARCH_PATH=...
        optionValue=$(getOptionValue "$@")
        replaceEtc     config.sh/FFTW   FFTW_ARCH_PATH "\"$optionValue\""
        replaceEtcCsh  config.csh/FFTW  FFTW_ARCH_PATH "\"$optionValue\""
        adjusted=true
        shift
        ;;

    -cmake)
        # Replace cmake_version=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  config.sh/cmake   cmake_version "$optionValue"
        adjusted=true
        shift
        ;;

    -cmake-path)
        # Replace CMAKE_ARCH_PATH=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  config.sh/cmake   CMAKE_ARCH_PATH "$optionValue"
        adjusted=true
        shift
        ;;

    -kahip)
        # Replace KAHIP_VERSION=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  config.sh/kahip  KAHIP_VERSION "$optionValue"
        adjusted=true
        shift
        ;;

    -kahip-path)
        # Replace KAHIP_ARCH_PATH=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  config.sh/kahip  KAHIP_ARCH_PATH "\"$optionValue\""
        adjusted=true
        shift
        ;;

    -metis)
        # Replace METIS_VERSION=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  config.sh/metis  METIS_VERSION "$optionValue"
        adjusted=true
        shift
        ;;

    -metis-path)
        # Replace METIS_ARCH_PATH=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  config.sh/metis  METIS_ARCH_PATH "\"$optionValue\""
        adjusted=true
        shift
        ;;

    -scotch | -scotchVersion | --scotchVersion)
        # Replace SCOTCH_VERSION=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  config.sh/scotch  SCOTCH_VERSION "$optionValue"
        adjusted=true
        shift
        ;;

    -scotch-path | -scotchArchPath | --scotchArchPath)
        # Replace SCOTCH_ARCH_PATH=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  config.sh/scotch  SCOTCH_ARCH_PATH "\"$optionValue\""
        adjusted=true
        shift
        ;;


## Graphics ##

    -paraview | -paraviewVersion | --paraviewVersion)
        # Replace ParaView_VERSION=...
        expected="[5-9][.0-9]*"  # but also accept system
        optionValue=$(getOptionValue "$@")
        _matches "$optionValue" "$expected" || \
            [ "$optionValue" != "${optionValue%system}" ] || \
            die "'$1' has bad value: '$optionValue'"
        replaceEtc  config.sh/paraview   ParaView_VERSION "$optionValue"
        replaceEtc  config.csh/paraview  ParaView_VERSION "$optionValue"
        adjusted=true
        shift
        ;;

    -paraview-qt)
        # Replace ParaView_QT=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  config.sh/paraview   ParaView_QT "$optionValue"
        replaceEtc  config.csh/paraview  ParaView_QT "$optionValue"
        adjusted=true
        shift
        ;;

    -paraview-path | -paraviewInstall | --paraviewInstall)
        # Replace ParaView_DIR=...
        optionValue=$(getOptionValue "$@")
        replaceEtc     config.sh/paraview   ParaView_DIR \""$optionValue\""
        replaceEtcCsh  config.csh/paraview  ParaView_DIR \""$optionValue\""
        adjusted=true
        shift
        ;;

    -llvm)
        # Replace mesa_llvm=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  config.sh/vtk   mesa_llvm "$optionValue"
        replaceEtc  config.csh/vtk  mesa_llvm "$optionValue"
        adjusted=true
        shift
        ;;

    -mesa)
        # Replace mesa_version=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  config.sh/vtk   mesa_version "$optionValue"
        replaceEtc  config.csh/vtk  mesa_version "$optionValue"
        adjusted=true
        shift
        ;;

    -vtk)
        # Replace vtk_version=...
        optionValue=$(getOptionValue "$@")
        replaceEtc  config.sh/vtk   vtk_version "$optionValue"
        replaceEtc  config.csh/vtk  vtk_version "$optionValue"
        adjusted=true
        shift
        ;;

    -llvm-path)
        # Replace LLVM_ARCH_PATH=...
        optionValue=$(getOptionValue "$@")
        replaceEtc     config.sh/vtk   LLVM_ARCH_PATH \""$optionValue\""
        replaceEtcCsh  config.csh/vtk  LLVM_ARCH_PATH \""$optionValue\""
        adjusted=true
        shift
        ;;

    -mesa-path)
        # Replace MESA_ARCH_PATH...
        optionValue=$(getOptionValue "$@")
        replaceEtc     config.sh/vtk   MESA_ARCH_PATH \""$optionValue\""
        replaceEtcCsh  config.csh/vtk  MESA_ARCH_PATH \""$optionValue\""
        adjusted=true
        shift
        ;;

    -vtk-path)
        # Replace VTK_DIR...
        optionValue=$(getOptionValue "$@")
        replaceEtc     config.sh/vtk   VTK_DIR \""$optionValue\""
        replaceEtcCsh  config.csh/vtk  VTK_DIR \""$optionValue\""
        adjusted=true
        shift
        ;;


## Misc ##

    -sigfpe | -no-sigfpe)
        echo "Enable/disable FOAM_SIGFPE now via controlDict" 1>&2
        ;;

    -foamInstall | --foamInstall | -projectName | --projectName)
        # Removed for 1812
        optionValue=$(getOptionValue "$@")
        echo "Ignoring obsolete option $1" 1>&2
        shift
        ;;

    *)
        die "unknown option/argument: '$1'"
        ;;
    esac
    shift
done

if [ "$adjusted" = false ]
then
    echo "Nothing adjusted"
    exit 0
elif [ -z "$adjusted" ]
then
    die "Please specify at least one configure option"
fi

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