forked from OpenFOAM/ThirdParty-2.3.x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
genMSMPIstubs
executable file
·297 lines (229 loc) · 9.34 KB
/
genMSMPIstubs
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
#!/bin/bash
#------------------------------------------------------------------------------
# License
# Copyright (C) 2011-2016 blueCAPE Lda
#
# This file is part of blueCAPE's unofficial mingw patches for OpenFOAM.
# For more information about these patches, visit:
# http://bluecfd.com/Core
#
# This file is a derivative work 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
# genMSMPIstubs
#
# Description
# This script generates the link library and prepares the include
# files for MSMPI, based on:
# * HPC Pack 2008 R2 SP4 MS-MPI Redistributable Package:
# http://www.microsoft.com/download/en/details.aspx?id=14737
# * HPC Pack 2012 MS-MPI Redistributable Package:
# http://www.microsoft.com/en-us/download/details.aspx?id=36045
#
# This is designed to be installed directly on Windows, so that it's ready
# to be used after this script is finished.
#
#------------------------------------------------------------------------------
if ! isMinGW; then
echo "Error: this script is meant to be used for MinGW compilers only!"
exit 1
fi
#check the MSMPI version
case $WM_MPLIB in
MSMPI2008)
#set up variables
INSTPACK_URL="http://download.microsoft.com/download/3/8/D/38D18861-67DE-4E66-92C7-6819D8B07210"
INSTPACK_X86="mpi_x86.msi"
INSTPACK_X86_64="mpi_x64.msi"
# INSTPACK_URL="http://download.microsoft.com/download/7/6/8/768DA318-6642-40F5-AA76-D8AD75A8E498"
# INSTPACK_X86="sdk_x86.msi"
# INSTPACK_X86_64="sdk_x64.msi"
;;
MSMPI2012)
#set up variables
INSTPACK_URL="http://download.microsoft.com/download/A/1/3/A1397A8C-4751-433C-8330-F738C3BE2187"
INSTPACK_X86="mpi_x86.Msi"
INSTPACK_X86_64="mpi_x64.Msi"
;;
*)
echo "Error: Incompatible MPI toolbox chosen."
exit 1
;;
esac
if [ $WM_ARCH_OPTION -eq 64 ]; then
INSTPACK_FILE=$INSTPACK_X86_64
DLLVERNUM="64"
else
INSTPACK_FILE=$INSTPACK_X86
DLLVERNUM=""
fi
FINAL_INSTPACK_FILE=${WM_MPLIB}_${INSTPACK_FILE}
# run from third-party directory only
cd ${0%/*} || exit 1
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
. etc/tools/makeExtraThirdPartyFunctions
#end of initializations -------------------------------------------
download_files()
{
# Make sure wget is installed
if test "x`which wget`" = "x" ; then
echo "You need to install wget."
exit 1
fi
downloadFile $FINAL_INSTPACK_FILE $INSTPACK_URL/$INSTPACK_FILE
}
unpack_files()
{
echo "Unpacking files..."
#Just in case, purge the previous installation
cleanup
createBinIncludeLib $MPI_ARCH_PATH
#depends on the MPI version
case $WM_MPLIB in
MSMPI2008)
relativePath=${MPI_ARCH_PATH#$WM_THIRD_PARTY_DIR/}
if [ $WM_ARCH_OPTION = 32 ]; then
cmd /c "$(echo "msiexec /a download\\${WM_MPLIB}_mpi_x86.msi /qb TARGETDIR=\"%CD%\\${relativePath//\//\\}\"")"
cp "${MPI_ARCH_PATH}/PFiles/Microsoft HPC Pack 2008 R2/Bin"/*.* "${MPI_ARCH_PATH}/bin/"
cp "${MPI_ARCH_PATH}/PFiles/Microsoft HPC Pack 2008 R2/Inc"/*.* "${MPI_ARCH_PATH}/include/"
cp "${MPI_ARCH_PATH}/PFiles/Microsoft HPC Pack 2008 R2/Lib/i386"/*.* "${MPI_ARCH_PATH}/lib/"
cp "${MPI_ARCH_PATH}/PFiles/Microsoft HPC Pack 2008 R2/License"/* "${MPI_ARCH_PATH}/"
cp "${MPI_ARCH_PATH}/PFiles/System"/*.* "${MPI_ARCH_PATH}/bin/"
# The 32-bit version library interface is already compatible with GCC+MinGW
cp "${MPI_ARCH_PATH}/lib/msmpi.lib" "${MPI_ARCH_PATH}/lib/libmpi.a"
else
cmd /c "$(echo "msiexec /a download\\${WM_MPLIB}_mpi_x64.msi /qb TARGETDIR=\"%CD%\\${relativePath//\//\\}\"")"
cp "${MPI_ARCH_PATH}/PFiles/Microsoft HPC Pack 2008 R2/Bin"/*.* "${MPI_ARCH_PATH}/bin/"
cp "${MPI_ARCH_PATH}/PFiles/Microsoft HPC Pack 2008 R2/Inc"/*.* "${MPI_ARCH_PATH}/include/"
cp "${MPI_ARCH_PATH}/PFiles/Microsoft HPC Pack 2008 R2/Lib/amd64"/*.* "${MPI_ARCH_PATH}/lib/"
cp "${MPI_ARCH_PATH}/PFiles/Microsoft HPC Pack 2008 R2/License"/* "${MPI_ARCH_PATH}/"
cp "${MPI_ARCH_PATH}/PFiles/System64"/*.* "${MPI_ARCH_PATH}/bin/"
fi
cp "${MPI_ARCH_PATH}/bin/mpiexec.exe" "${MPI_ARCH_PATH}/bin/mpirun.exe"
;;
MSMPI2012)
relativePath=${MPI_ARCH_PATH#$WM_THIRD_PARTY_DIR/}
if [ $WM_ARCH_OPTION = 32 ]; then
cmd /c "$(echo "msiexec /a download\\${WM_MPLIB}_mpi_x86.msi /qb TARGETDIR=\"%CD%\\${relativePath//\//\\}\"")"
cp "${MPI_ARCH_PATH}/PFiles/Microsoft HPC Pack 2012/Bin"/*.* "${MPI_ARCH_PATH}/bin/"
cp "${MPI_ARCH_PATH}/PFiles/Microsoft HPC Pack 2012/Inc"/*.* "${MPI_ARCH_PATH}/include/"
cp "${MPI_ARCH_PATH}/PFiles/Microsoft HPC Pack 2012/Lib/i386"/*.* "${MPI_ARCH_PATH}/lib/"
cp "${MPI_ARCH_PATH}/PFiles/Microsoft HPC Pack 2012/License"/* "${MPI_ARCH_PATH}/"
cp "${MPI_ARCH_PATH}/PFiles/System"/*.* "${MPI_ARCH_PATH}/bin/"
# The 32-bit version library interface is already compatible with GCC+MinGW
cp "${MPI_ARCH_PATH}/lib/msmpi.lib" "${MPI_ARCH_PATH}/lib/libmpi.a"
else
cmd /c "$(echo "msiexec /a download\\${WM_MPLIB}_mpi_x64.msi /qb TARGETDIR=\"%CD%\\${relativePath//\//\\}\"")"
cp "${MPI_ARCH_PATH}/PFiles/Microsoft HPC Pack 2012/Bin"/*.* "${MPI_ARCH_PATH}/bin/"
cp "${MPI_ARCH_PATH}/PFiles/Microsoft HPC Pack 2012/Inc"/*.* "${MPI_ARCH_PATH}/include/"
cp "${MPI_ARCH_PATH}/PFiles/Microsoft HPC Pack 2012/Lib/amd64"/*.* "${MPI_ARCH_PATH}/lib/"
cp "${MPI_ARCH_PATH}/PFiles/Microsoft HPC Pack 2012/License"/* "${MPI_ARCH_PATH}/"
cp "${MPI_ARCH_PATH}/PFiles/System64"/*.* "${MPI_ARCH_PATH}/bin/"
fi
cp "${MPI_ARCH_PATH}/bin/mpiexec.exe" "${MPI_ARCH_PATH}/bin/mpirun.exe"
;;
esac
}
function create_gcccompatible_library
{
echo -e "\033[1m creating libmpi.a \033[0m"
if [ -n "${DLLVERNUM}" ]; then
cd $BUILDDIR/lib
gendef - ../bin/msmpi.dll > libmpi.def
dlltool -d libmpi.def -l libmpi.a -D msmpi.dll
fi
}
function patch_mpi_includes
{
echo -e "\033[1m patching mpi.h \033[0m"
cd $BUILDDIR/include
cat mpi.h | sed -e ':a;N;$!ba;s/\r\n/\n/g' > mpi.h_tmp
mv -f mpi.h_tmp mpi.h
if [ "$WM_ARCH_OPTION" = "64" ]; then
patch -p0 --binary < $WM_THIRD_PARTY_DIR/etc/patches/patch_msmpi_mpi_h
fi
echo '--- mpi.h_orig 2011-01-18 15:11:38.284485101 +0000
+++ mpi.h 2011-01-18 15:11:43.739068567 +0000
@@ -16,6 +16,7 @@
#define MSMPI_VER 0x100
#endif
+#include <stdint.h>
/*---------------------------------------------------------------------------*/
/* SAL ANNOTATIONS */
@@ -5319,6 +5319,15 @@
/* Chapter 15: Depricated Functions */
/*---------------------------------------------------------------------------*/
+#if defined( __GNUC__ ) && defined( __GNUC_MINOR__ )
+ #if (__GNUC__ == 4) && (__GNUC_MINOR__ == 4)
+ //this will override an issue that is already fixed in gcc 4.5.x and above
+ //namely a problem with "deprecated" not allowing messages in 4.4.x and below.
+ //#define MSMPI_NO_DEPRECATE_20
+ #define deprecated(x) deprecated
+ #endif
+#endif
+
#ifdef MSMPI_NO_DEPRECATE_20
#define MSMPI_DEPRECATE_20( x )
#else
' | patch -p0
if [ "$WM_MPLIB" = "MSMPI2012" ]; then
patch -p0 --binary < $WM_THIRD_PARTY_DIR/etc/patches/patch_msmpi2012_mpi_h
fi
if [ -n "${DLLVERNUM}" ]; then
cat mpi.h | sed -e 's=\#define MPIAPI __stdcall=\#define MPIAPI=' > mpi.h_tmp
mv -f mpi.h_tmp mpi.h
fi
}
function cleanup
{
if [ -n "$BUILDDIR" -a -e "$BUILDDIR" ]; then
rm -rf "$BUILDDIR"
fi
}
#script start ------------------------------------------------------
BUILDDIR="$MPI_ARCH_PATH"
SRCDIR="$MPI_HOME/source"
if [ $# -eq 1 -a "$1" = "clean" ]; then
echo -e "\033[1m Cleaning up MSMPI stub... \033[0m"
cleanup
else
if test -z "x`which msiexec`" ; then
echo "The installation application msiexec was not found. Cannot proceed."
exit 1
elif ! onWin; then
echo "This script was designed to be used on Windows (using MSYS/MinGW). Cannot proceed."
exit 1
fi
if [ ! -e "$BUILDDIR/lib/libmpi.a" ]; then
echo -e "\033[1m Downloading necessary MSMPI installation files...\033[0m"
download_files
echo -e "\033[1m Unpacking necessary MSMPI installation files...\033[0m"
unpack_files
echo -e "\033[1m Generating MSMPI stub... \033[0m"
create_gcccompatible_library
patch_mpi_includes
echo -e "\033[1m All done. \033[0m"
else
echo -e "\033[1m MSMPI stub is already built and ready to use. \033[0m"
fi
cd $WM_THIRD_PARTY_DIR
fi