STYLE: date
[OpenFOAM-2.0.x.git] / bin / tools / foamConfigurePaths
blobd5fe1ba0ff7f971e741920ebc82c591eeab2d190
1 #!/bin/sh
2 #---------------------------------*- sh -*-------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
7 # \\/ M anipulation |
8 #------------------------------------------------------------------------------
9 # License
10 # This file is part of OpenFOAM.
12 # OpenFOAM is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your option) any later version.
17 # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
18 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 # for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 # Script
26 # foamConfigurePaths
28 # Description
29 # hardcode installation directory
31 #------------------------------------------------------------------------------
32 usage() {
33 exec 1>&2
34 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
35 cat<<USAGE
37 usage: ${0##*/}
38 --foamInstall dir specify installation directory (e.g. /opt)
39 --projectName name specify project name (e.g. openfoam170)
40 --projectVersion ver specify project version (e.g. 1.7.x)
41 --archOption arch specify architecture option (only 32 or 64 applicable)
42 --paraviewInstall dir specify ParaView_DIR (e.g. /opt/paraviewopenfoam380)
44 * hardcode paths to installation
46 USAGE
47 exit 1
51 # Function to do replacement on file. Checks if any replacement has been done.
52 # inlineSed <file> <sedCommand> <description>
53 _inlineSed()
55 [ -f "$1" ] || {
56 echo "Missing file: $1"
57 exit 1
60 backup="temp.$$"
61 cp $1 $backup
62 sed -i -e "$2" $1
64 if cmp $1 $backup > /dev/null 2>&1
65 then
66 echo "Failed: $3 in $1"
67 rm $backup 2>/dev/null
68 exit 1
69 else
70 echo "Okay: $3 in $1"
71 rm $backup 2>/dev/null
74 return 0
78 [ -f etc/bashrc ] || usage "Please run from top-level directory of installation"
80 unset foamInstall projectName projectVersion archOption paraviewInstall
82 # parse options
83 while [ "$#" -gt 0 ]
85 case "$1" in
86 -h | -help | --help)
87 usage
89 -foamInstall | --foamInstall)
90 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
91 foamInstall="$2"
92 # replace foamInstall=...
93 _inlineSed \
94 etc/bashrc \
95 '/^[^#]/s@foamInstall=.*@foamInstall='"$foamInstall@" \
96 "Replacing foamInstall setting by '$foamInstall'"
97 shift 2
99 -projectName | --projectName)
100 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
101 projectName="$2"
102 # replace WM_PROJECT_DIR=...
103 _inlineSed \
104 etc/bashrc \
105 '/^[^#]/s@WM_PROJECT_DIR=.*@WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/'"$projectName@" \
106 "Replacing WM_PROJECT_DIR setting by $projectName"
107 shift 2
109 --projectVersion)
110 # [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
111 # projectVersion="$2"
112 # # replace WM_PROJECT_VERSION=...
113 # _inlineSed \
114 # etc/bashrc \
115 # '/^[^#]/s@WM_PROJECT_VERSION=.*@WM_PROJECT_VERSION='"$projectVersion@" \
116 # "Replacing WM_PROJECT_VERSION setting by $projectVersion"
117 shift 2
119 -archOption | --archOption)
120 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
121 archOption="$2"
122 # replace WM_ARCH_OPTION=...
123 _inlineSed \
124 etc/bashrc \
125 '/^[^#]/s@WM_ARCH_OPTION=.*@WM_ARCH_OPTION='"$archOption@" \
126 "Replacing WM_ARCH_OPTION setting by '$archOption'"
127 shift 2
129 -paraviewInstall | --paraviewInstall)
130 [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
131 paraviewInstall="$2"
132 # replace ParaView_DIR=...
133 _inlineSed \
134 etc/config/paraview.sh \
135 '/^[^#]/s@ParaView_DIR=.*@ParaView_DIR='"$paraviewInstall@" \
136 "Replacing ParaView_DIR setting by '$paraviewInstall'"
137 shift 2
140 usage "unknown option/argument: '$*'"
142 esac
143 done
145 [ -n "$foamInstall" -o -n "$projectName" -o -n "$archOption" -o -n "$paraviewInstall" ] || usage "Please specify at least one configure option"
147 #echo "Replacing WM_PROJECT setting by '$projectName'"
148 #sed -i -e 's@WM_PROJECT=.*@WM_PROJECT='"$projectName@" etc/bashrc
150 # Set WM_MPLIB=SYSTEMOPENMPI always
151 _inlineSed \
152 etc/bashrc \
153 '/^[^#]/s@export WM_MPLIB=.*@export WM_MPLIB=SYSTEMOPENMPI@' \
154 "Replacing WM_MPLIB setting by 'SYSTEMOPENMPI'"
156 ## set foamCompiler=system always
157 #_inlineSed \
158 # etc/bashrc \
159 # '/^[^#]/s@foamCompiler=.*@foamCompiler=system@' \
160 # "Replacing foamCompiler setting by 'system'"
162 #------------------------------------------------------------------------------