Forward compatibility: flex
[foam-extend-3.2.git] / ThirdParty / mingwBuild / build.sh
blobd095c544346a41794953477a43342a81cbbcea9c
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | foam-extend: Open Source CFD
5 # \\ / O peration | Version: 3.2
6 # \\ / A nd | Web: http://www.foam-extend.org
7 # \\/ M anipulation | For copyright notice see file Copyright
8 #------------------------------------------------------------------------------
9 # License
10 # This file is part of foam-extend.
12 # foam-extend is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by the
14 # Free Software Foundation, either version 3 of the License, or (at your
15 # option) any later version.
17 # foam-extend is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 # General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 # Script
26 # build.sh
28 # Description
29 # Downloads, extracts, builds and installs thirdy-party dependencies.
31 # Author:
32 # Cesare Guardino, Alstom Power Ltd., (2015)
34 #------------------------------------------------------------------------------
36 # {{{ DEFINE UTILITY FUNCTIONS
37 download() {
38 file=$1
39 url=$2
41 if [ -f $BUILD_HOME/downloads/$file ] ; then
42 echo "Using already existing file $BUILD_HOME/downloads/$file"
43 else
44 wget --no-check-certificate $url -O $BUILD_HOME/downloads/$file
48 extract() {
49 file=$1
50 program=$2
52 cp -p $BUILD_HOME/downloads/$file .
53 package=`basename $file`
54 if [ "$program" = "7zip" ] ; then
55 "$ZIP_EXE" x $package
56 else
57 $program -cd $package | tar xvf -
59 rm $package
62 unzip_dir() {
63 dir=$1
65 mkdir $dir
66 cd $dir
67 extract $dir.zip 7zip
68 cd ..
71 patch() {
72 dir=$1
74 cp -rp $BUILD_HOME/$ARCH/patches/$dir .
77 mkchk() {
78 dir=$1
80 if [ ! -d $dir ] ; then
81 mkdir $dir
85 mkdel() {
86 dir=$1
88 rm -rf $dir > /dev/null 2>&1
89 mkdir $dir
91 # }}}
93 # {{{ DEFINE PROCESS FUNCTIONS
94 start() {
95 echo "======================== FOAM-EXTEND THIRD-PARTY DEPENDENCIES WINDOWS BUILD SCRIPT ========================"
98 initialise() {
99 echo ""
101 if [ ! "$MINGW_HOME" ] ; then
102 echo "*** ERROR: MINGW_HOME environment variable not specified."
103 exit 1
104 else
105 echo "Using MINGW_HOME=$MINGW_HOME"
108 BUILD_HOME=`pwd`
109 ZIP_EXE="7z.exe"
110 ARCH="x64"
112 BUILD_DIR=$BUILD_HOME/$ARCH/build
113 INSTALL_DIR=$BUILD_HOME/$ARCH/install
114 OUT_DIR=$BUILD_HOME/$ARCH/output
116 mkchk $BUILD_HOME/downloads
118 echo ""
119 echo "All stdout/stderr output is redirected to the directory $OUT_DIR"
120 echo "All builds occur in the directory $BUILD_DIR"
121 echo "The script will install the completed builds in the directory $INSTALL_DIR"
124 cleanup() {
125 echo ""
126 echo "Removing previous builds ..."
128 mkdel $BUILD_DIR
129 mkdel $INSTALL_DIR
130 mkdel $OUT_DIR
133 build_library() {
134 PACKAGE=$1
136 echo "- Building $PACKAGE ..."
137 LOG_FILE=$OUT_DIR/$PACKAGE.log
138 cd $BUILD_DIR
140 case $PACKAGE in
142 dlfcn-win32-master)
143 download $PACKAGE.zip https://github.com/dlfcn-win32/dlfcn-win32/archive/master.zip > $LOG_FILE 2>&1
144 extract $PACKAGE.zip 7zip >> $LOG_FILE 2>&1
145 cd $PACKAGE
146 ./configure --prefix=$INSTALL_DIR/system >> $LOG_FILE 2>&1
147 make >> $LOG_FILE 2>&1
148 mkdir $INSTALL_DIR/system
149 make install >> $LOG_FILE 2>&1
152 system)
153 cd $INSTALL_DIR
154 patch $PACKAGE
157 pthreads-w32-2-9-1-release)
158 download $PACKAGE.zip ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip > $LOG_FILE 2>&1
159 unzip_dir $PACKAGE >> $LOG_FILE 2>&1
160 patch $PACKAGE
161 mv $PACKAGE $INSTALL_DIR
164 metis-5.1.0)
165 download $PACKAGE.tar.gz http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/$PACKAGE.tar.gz > $LOG_FILE 2>&1
166 extract "$PACKAGE.tar.gz" gzip >> $LOG_FILE 2>&1
167 patch $PACKAGE
168 cd $PACKAGE
169 mkdir build/windows
170 cd build/windows
171 cmake -G "MSYS Makefiles" -DCMAKE_CONFIGURATION-TYPES="Release" -DGKLIB_PATH="../../GKlib" ../.. >> $LOG_FILE 2>&1
172 make >> $LOG_FILE 2>&1
173 mkdir $INSTALL_DIR/$PACKAGE
174 mkdir $INSTALL_DIR/$PACKAGE/bin
175 mkdir $INSTALL_DIR/$PACKAGE/include
176 mkdir $INSTALL_DIR/$PACKAGE/lib
177 cp -p programs/*.exe $INSTALL_DIR/$PACKAGE/bin
178 cp -p ../../include/metis.h $INSTALL_DIR/$PACKAGE/include
179 cp -p libmetis/libmetis.a $INSTALL_DIR/$PACKAGE/lib
182 parmetis-4.0.3)
183 download $PACKAGE.tar.gz http://glaros.dtc.umn.edu/gkhome/fetch/sw/parmetis/$PACKAGE.tar.gz > $LOG_FILE 2>&1
184 extract "$PACKAGE.tar.gz" gzip >> $LOG_FILE 2>&1
185 patch $PACKAGE
186 cd $PACKAGE
187 mkdir build/windows
188 cd build/windows
189 cmake -G "MSYS Makefiles" -DCMAKE_CONFIGURATION-TYPES="Release" -DGKLIB_PATH="../../metis/GKlib" ../.. >> $LOG_FILE 2>&1
190 $BUILD_HOME/parmetis_includes_hack.pl
191 make >> $LOG_FILE 2>&1
192 mkdir $INSTALL_DIR/$PACKAGE
193 mkdir $INSTALL_DIR/$PACKAGE/bin
194 mkdir $INSTALL_DIR/$PACKAGE/include
195 mkdir $INSTALL_DIR/$PACKAGE/lib
196 cp -p programs/*.exe $INSTALL_DIR/$PACKAGE/bin
197 cp -p ../../metis/include/metis.h $INSTALL_DIR/$PACKAGE/include
198 cp -p ../../include/parmetis.h $INSTALL_DIR/$PACKAGE/include
199 cp -p libmetis/libmetis.a $INSTALL_DIR/$PACKAGE/lib
200 cp -p libparmetis/libparmetis.a $INSTALL_DIR/$PACKAGE/lib
203 ParMGridGen-1.0)
204 export EXTRA_SYSTEM_HOME=$INSTALL_DIR/system
205 download $PACKAGE.tar.gz http://www.mgnet.org/mgnet/Codes/parmgridgen/$PACKAGE.tar.gz > $LOG_FILE 2>&1
206 extract "$PACKAGE.tar.gz" gzip >> $LOG_FILE 2>&1
207 patch $PACKAGE
208 cd $PACKAGE
209 make serial >> $LOG_FILE 2>&1
210 make parallel >> $LOG_FILE 2>&1
211 mkdir $INSTALL_DIR/$PACKAGE
212 mkdir $INSTALL_DIR/$PACKAGE/bin
213 mkdir $INSTALL_DIR/$PACKAGE/include
214 mkdir $INSTALL_DIR/$PACKAGE/lib
215 cp -p *.exe $INSTALL_DIR/$PACKAGE/bin
216 cp -p libmgrid.a $INSTALL_DIR/$PACKAGE/lib
217 cp -p libparmgrid.a $INSTALL_DIR/$PACKAGE/lib
218 cp -p MGridGen/IMlib/libIMlib.a $INSTALL_DIR/$PACKAGE/lib
219 cp -p ParMGridGen/IMParMetis-2.0/libIMparmetis.a $INSTALL_DIR/$PACKAGE/lib
220 cp -p MGridGen/IMlib/*.h $INSTALL_DIR/$PACKAGE/include
221 cp -p MGridGen/Lib/*.h $INSTALL_DIR/$PACKAGE/include
222 export EXTRA_SYSTEM_HOME=
225 scotch_6.0.4)
226 export PTHREADS_HOME=$INSTALL_DIR/pthreads-w32-2-9-1-release
227 download $PACKAGE.tar.gz https://gforge.inria.fr/frs/download.php/34618 > $LOG_FILE 2>&1
228 extract "$PACKAGE.tar.gz" gzip >> $LOG_FILE 2>&1
229 patch $PACKAGE
230 cd $PACKAGE/src
231 make scotch >> $LOG_FILE 2>&1
232 make ptscotch >> $LOG_FILE 2>&1
233 mkdir $INSTALL_DIR/$PACKAGE
234 make install prefix=$INSTALL_DIR/$PACKAGE >> $PACKAGE.log 2>&1
235 export PTHREADS_HOME=
238 mesquite-2.1.2)
239 export CPPFLAGS=-fpermissive
240 download $PACKAGE.tar.gz http://downloads.sourceforge.net/project/openfoam-extend/foam-extend-3.0/ThirdParty/$PACKAGE.tar.gz > $LOG_FILE 2>&1
241 extract "$PACKAGE.tar.gz" gzip >> $LOG_FILE 2>&1
242 cd $PACKAGE
243 cp -p $MINGW_HOME/bin/libstdc++-6.dll utils
244 ./configure --prefix=$INSTALL_DIR >> $LOG_FILE 2>&1
245 make >> $LOG_FILE 2>&1
246 mkdir $INSTALL_DIR/$PACKAGE
247 make install prefix=$INSTALL_DIR/$PACKAGE >> $LOG_FILE 2>&1
248 export CPPFLAGS=
252 echo "*** ERROR: Unknown package '$PACKAGE'"
253 exit 1
255 esac
258 build_libraries() {
259 echo ""
260 echo "Building libraries ..."
261 build_library dlfcn-win32-master
262 build_library system
263 build_library pthreads-w32-2-9-1-release
264 build_library metis-5.1.0
265 build_library parmetis-4.0.3
266 build_library ParMGridGen-1.0
267 build_library scotch_6.0.4
268 build_library mesquite-2.1.2
271 create_dirs() {
272 echo ""
273 echo "Checking for build directories and creating them if required ..."
275 mkchk $BUILD_DIR
276 mkchk $INSTALL_DIR
277 mkchk $OUT_DIR
280 finish() {
281 echo ""
282 echo "All done!"
284 # }}}
286 # {{{ MAIN EXECUTION
287 cd ${0%/*} || exit 1 # run from this directory
288 start
289 initialise
290 mkchk $ARCH
291 cleanup
292 build_libraries
293 finish
294 # }}}