forked from OpenFOAM/ThirdParty-8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeGcc
executable file
·306 lines (267 loc) · 7.55 KB
/
makeGcc
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
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
# \\/ M anipulation |
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# makeGcc
#
# Description
# Build script for gmp, mpfr and gcc-[4-9].?.?
#
#------------------------------------------------------------------------------
# get default GCC, mpfr, gmp and mpc versions
. $WM_PROJECT_DIR/etc/config.sh/functions
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler)
gmpPACKAGE=${gmp_version:-gmp-5.1.2}
mpfrPACKAGE=${mpfr_version:-mpfr-3.1.2}
mpcPACKAGE=${mpc_version:-mpc-1.0.1}
gccPACKAGE=$gcc_version
#------------------------------------------------------------------------------
# Run from third-party directory only
wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
echo " The environment variables are inconsistent with the installation."
echo " Check the OpenFOAM entries in your dot-files and source them."
exit 1
}
. etc/tools/ThirdPartyFunctions
#------------------------------------------------------------------------------
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: ${0##*/} [option] [gmp-VERSION] [mpfr-VERSION] [mpc-VERSION] <gcc-VERSION>
options:
-no-multilib for 64-bit systems that don't have 32-bit support
-help
* build combinations of gmp, mpfr, mpc and gcc
$gmpPACKAGE
$mpfrPACKAGE
$mpcPACKAGE
$gccPACKAGE
USAGE
exit 1
}
GCC_BUILD_OPTIONS="--enable-multilib"
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-no-multilib)
GCC_BUILD_OPTIONS="--disable-multilib"
shift
;;
gmp-[4-9]*)
gmpPACKAGE="${1%%/}"
shift
;;
mpfr-[2-9]*)
mpfrPACKAGE="${1%%/}"
shift
;;
mpc-[0-9]*)
mpcPACKAGE="${1%%/}"
shift
;;
gcc-[4-9]*)
gccPACKAGE="${1%%/}"
shift
;;
*)
usage "unknown option/argument: '$*'"
;;
esac
done
if [ -z "$gccPACKAGE" ]
then
usage "Please specify gcc-VERSION"
exit 1
fi
# Set 32 or 64 bit ABI
case "$WM_ARCH_OPTION" in
32 | 64)
ABI=$WM_ARCH_OPTION
;;
*)
usage "Please set WM_ARCH_OPTION to either 32 or 64'$*'"
;;
esac
#------------------------------------------------------------------------------
# Build/install without compiler name
buildBASE=$WM_THIRD_PARTY_DIR/build/$WM_ARCH$WM_COMPILER_ARCH
installBASE=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH
GCC_ARCH_PATH=$installBASE/$gccPACKAGE
GMP_ARCH_PATH=$installBASE/$gmpPACKAGE
MPFR_ARCH_PATH=$installBASE/$mpfrPACKAGE
MPC_ARCH_PATH=$installBASE/$mpcPACKAGE
#
# Build GMP
#
echo "---------------"
if [ -d $GMP_ARCH_PATH ]
then
echo "Already built: $gmpPACKAGE"
else
echo "Starting build: $gmpPACKAGE"
echo
(
sourceDIR=$WM_THIRD_PARTY_DIR/$gmpPACKAGE
buildDIR=$buildBASE/$gmpPACKAGE
cd $sourceDIR || exit 1
make distclean 2>/dev/null
rm -rf $buildDIR
mkdir -p $buildDIR
cd $buildDIR
set -x
$sourceDIR/configure ABI=$ABI \
--prefix=$GMP_ARCH_PATH \
--libdir=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
--enable-cxx \
&& make -j $WM_NCOMPPROCS \
&& make install \
&& echo "Built: $gmpPACKAGE"
) || {
echo "Error building: $gmpPACKAGE"
exit 1
}
fi
export LD_LIBRARY_PATH="$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH:$LD_LIBRARY_PATH"
#
# Build MPFR
#
echo "---------------"
if [ -d $MPFR_ARCH_PATH ]
then
echo "Already built: $mpfrPACKAGE"
else
echo "Starting build: $mpfrPACKAGE"
echo
(
sourceDIR=$WM_THIRD_PARTY_DIR/$mpfrPACKAGE
buildDIR=$buildBASE/$mpfrPACKAGE
cd $sourceDIR || exit 1
make distclean 2>/dev/null
rm -rf $buildDIR
mkdir -p $buildDIR
cd $buildDIR
set -x
$sourceDIR/configure ABI=$ABI \
--prefix=$MPFR_ARCH_PATH \
--libdir=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
--with-gmp-include=$GMP_ARCH_PATH/include \
--with-gmp-lib=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
&& make -j $WM_NCOMPPROCS \
&& make install \
&& echo "Built: $mpfrPACKAGE"
) || {
echo "Error building: $mpfrPACKAGE"
exit 1
}
fi
export LD_LIBRARY_PATH="$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH:$LD_LIBRARY_PATH"
#
# Build mpc
#
echo "---------------"
if [ -d $MPC_ARCH_PATH ]
then
echo "Already built: $mpcPACKAGE"
else
echo "Starting build: $mpcPACKAGE"
echo
(
sourceDIR=$WM_THIRD_PARTY_DIR/$mpcPACKAGE
buildDIR=$buildBASE/$mpcPACKAGE
cd $sourceDIR || exit 1
make distclean 2>/dev/null
rm -rf $buildDIR
mkdir -p $buildDIR
cd $buildDIR
set -x
$sourceDIR/configure ABI=$ABI \
--prefix=$MPC_ARCH_PATH \
--libdir=$MPC_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
--with-gmp-include=$GMP_ARCH_PATH/include \
--with-gmp-lib=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
--with-mpfr-include=$MPFR_ARCH_PATH/include \
--with-mpfr-lib=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
&& make -j $WM_NCOMPPROCS \
&& make install \
&& echo "Built: $mpcPACKAGE"
) || {
echo "Error building: $mpcPACKAGE"
exit 1
}
fi
if [ -d "$MPC_ARCH_PATH" ]
then
export LD_LIBRARY_PATH="$MPC_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH:$LD_LIBRARY_PATH"
fi
#
# Build GCC
# might need 32-bit glibc-devel headers to compile
# E.g. on ubuntu install g++-multilib
#
echo "---------------"
if [ -d $GCC_ARCH_PATH ]
then
echo "Already built: $gccPACKAGE"
else
echo "Starting build: $gccPACKAGE"
echo
(
sourceDIR=$WM_THIRD_PARTY_DIR/$gccPACKAGE
buildDIR=$buildBASE/$gccPACKAGE
cd $sourceDIR || exit 1
make distclean 2>/dev/null
rm -rf $buildDIR
mkdir -p $buildDIR
cd $buildDIR
set -x
$sourceDIR/configure \
--prefix=$GCC_ARCH_PATH \
--with-gmp-include=$GMP_ARCH_PATH/include \
--with-gmp-lib=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
--with-mpfr-include=$MPFR_ARCH_PATH/include \
--with-mpfr-lib=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
--with-mpc-include=$MPC_ARCH_PATH/include \
--with-mpc-lib=$MPC_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
--with-pkgversion=OpenFOAM \
--enable-languages=c,c++ \
--enable-__cxa_atexit \
--enable-libstdcxx-allocator=new \
--with-system-zlib \
$GCC_BUILD_OPTIONS \
MAKEINFO=missing \
&& make -j $WM_NCOMPPROCS \
&& make install \
&& echo "Built: $gccPACKAGE"
) || {
echo "Error building: $gccPACKAGE"
exit 1
}
fi
#------------------------------------------------------------------------------