-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcompile_libraries.sh
2379 lines (2082 loc) · 72.1 KB
/
compile_libraries.sh
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
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# -*- coding: utf-8 -*-
set -e
#set -x
usage()
{
cat << EOF
usage: $0 [OPTIONS] LIBRARY1 [LIBRARY2 LIBRARY3 ...]
This script compiles third party libraries/solvers necessary to build daetools.
Typical usage (configure and then build all libraries/solvers):
sh $0 all
Compiling only specified libraries:
sh $0 superlu bonmin trilinos
Achtung, Achtung!!
On MACOS gcc should be used (the XCode does not provide OpenMP).
getopt command might be missing - that line should be commented out.
OPTIONS:
-h | --help Show this message.
Control options (if not set default is: --clean and --build):
--configure Configure the specified library(ies)/solver(s).
--build Build the specified library(ies)/solver(s).
--clean Clean the specified library(ies)/solver(s).
Python options (if not set use system's default python). One of the following:
--with-python-binary Path to python binary to use.
--with-python-version Version of the system's python in the format: major.minor (i.e 2.7).
Cross compiling options:
--host Example: --host i686-w64-mingw32 (defines --host option for cross-compiling with the GNU gcc toolchain).
--cross-compile-python-root An absolute path to the python root folder (for the native python cannot be run under the build OS).
Has to be: ~/daetools/trunk/Python[Major][Minor]-[arch] (i.e. ~/daetools-win32-cross/trunk/Python27-win32)
LIBRARY:
all All libraries and solvers.
On GNU/Linux equivalent to: boost ref_blas_lapack umfpack idas superlu superlu_mt bonmin nlopt coolprop trilinos deal.ii
On Windows equivalent to: boost cblas_clapack idas superlu nlopt coolprop trilinos deal.ii
Individual libraries/solvers:
boost Boost libraries (system, filesystem, thread, python)
boost_static Boost static libraries (system, filesystem, thread, regex, no python nor --buildid set)
ref_blas_lapack reference BLAS and Lapack libraries
cblas_clapack CBLAS and CLapack libraries
mumps Mumps linear solver
umfpack Umfpack solver
idas IDAS solver
idas_mpi IDAS solver with MPI interface enabled
superlu SuperLU solver
superlu_mt SuperLU_MT solver
bonmin Bonmin solver
nlopt NLopt solver
trilinos Trilinos Amesos and AztecOO solvers
deal.ii deal.II finite elements library
coolprop CoolProp thermophysical property library
opencs OpenCS library
Requires cblas_clapack, idas (with MPI support enabled), metis, hdf5 and trilinos libraries
compiled using the compile_opencs.sh script from the OpenCS directory.
CROSS-COMPILATION (GNU/Linux -> Windows):
Prerequisities:
1. Install the mingw-w64 package from the main Debian repository.
2. Install Python on Windows using the binary from the python.org website
and copy it to trunk/PythonXY-arch (i.e. Python34-win32).
Modify PYTHON_MAJOR and PYTHON_MINOR in the crossCompile section in the dae.pri file (line ~90):
PYTHON_MAJOR = 3
PYTHON_MINOR = 4
3. cmake cross-compilation requires the toolchain file: set it up using -DCMAKE_TOOLCHAIN_FILE=[path_to_toolchain_file].cmake
Cross-compile .cmake files are provided by daetools and located in the trunk folder.
cross-compile-i686-w64-mingw32.cmake file targets a toolchain located in /usr/mingw32-i686 directory.
cross-compile-x86_64-w64-mingw32.cmake file targets a toolchain located in /usr/mingw32-x86_64 directory.
4. deal.II specific options:
The native "expand_instantiations_exe" is required but cannot be run under the build architecture.
and must be used from the native build.
Therefore, set up a native deal.II build directory first and run the following command in it:
make expand_instantiations_exe
Typically, it is located in the deal.II/common/scripts directory.
That directory will be added to the PATH environment variable by this script.
If necessary, modify the line 'export PATH=...:${PATH}' to match the actual location.
5. Boost specific options:
boost-python linking will fail. Append the value of:
${DAE_CROSS_COMPILE_PYTHON_ROOT}/libs/libpython${PYTHON_MAJOR}${PYTHON_MINOR}.a
at the end of the failed linking command, re-run it, and manually copy the stage/lib/*.dll(s) to the "daetools/solibs/${PLATFORM}_${HOST_ARCH}" directory.
Win64 (x86_64-w64-mingw32):
- Python 2.7 won't compile (probably issues with the MS Universal CRT voodoo mojo)
- dl and util libraries are missing when compiling with x86_64-w64-mingw32.
solution: just remove -ldl and -lutil from the linking line.
6. Trilinos specific options
i686-w64-mingw32 specific:
1. In the file:
- trilinos/packages/teuchos/src/Teuchos_BLAS.cpp
"template BLAS<...>" (lines 96-104)
#ifdef _WIN32
#ifdef HAVE_TEUCHOS_COMPLEX
template class BLAS<long int, std::complex<float> >;
template class BLAS<long int, std::complex<double> >;
#endif
template class BLAS<long int, float>;
template class BLAS<long int, double>;
#endif
should be replaced by "template class BLAS<...>"
2. In the files:
- trilinos/packages/ml/src/Utils/ml_epetra_utils.cpp,
- trilinos/packages/ml/src/Utils/ml_utils.c
- trilinos/packages/ml/src/MLAPI/MLAPI_Workspace.cpp:
the functions "gethostname" and "sleep" do not exist
a) Add include file:
#include <winsock2.h>
and if that does not work (getting unresolved _gethostname function in pyTrilinos),
then comment-out all "gethostname" occurences (they are not important - just for printing some info)
b) Rename sleep() to Sleep() (if needed, wasn't needed for 10.12.2)
x86_64-w64-mingw32 specific:
All the same as above. Additionally:
1. trilinos/packages/teuchos/src/Teuchos_SerializationTraits.hpp
Comment lines: UndefinedSerializationTraits<T>::notDefined();
2. trilinos/packages/epetra/src/Epetra_C_wrappers.cpp
Add lines at the beggining of the file:
#pragma GCC diagnostic push
#pragma GCC diagnostic warning "-fpermissive"
Cross compiling notes:
1. Requirements for Boost:
--with-python-version 3.4
--cross-compile-python-root .../trunk/Python35-win32
--host i686-w64-mingw32
2. The other libraries:
--host i686-w64-mingw32 (the only necessary)
Example cross-compile call:
sh compile_libraries.sh --with-python-version 3.4 --cross-compile-python-root ~/daetools-win32-cross/trunk/Python34-win32 --host i686-w64-mingw32 boost
sh compile_libraries.sh --host i686-w64-mingw32 ref_blas_lapack umfpack idas superlu superlu_mt trilinos bonmin nlopt deal.ii
EOF
}
# Default python binary:
PYTHON=python
PYTHON_MAJOR=
PYTHON_MINOR=
PYTHON_VERSION=
PYTHON_INCLUDE_DIR=
PYTHON_LIB_DIR=
TRUNK="$( cd "$( dirname "$0" )" && pwd )"
HOST_ARCH=`uname -m`
PLATFORM=`uname -s`
if [[ "${PLATFORM}" == *"MSYS_"* ]]; then
PLATFORM="Windows"
# Platform should be set by i.e. vcbuildtools.bat
VC_PLAT=`cmd "/C echo %Platform%"`
echo $VC_PLAT
if [[ "${VC_PLAT}" == *"X86"* ]]; then
HOST_ARCH="win32"
elif [[ "${VC_PLAT}" == *"x86"* ]]; then
HOST_ARCH="win32"
elif [[ "${VC_PLAT}" == *"x64"* ]]; then
HOST_ARCH="win64"
elif [[ "${VC_PLAT}" == *"X64"* ]]; then
HOST_ARCH="win64"
else
echo unknown HOST_ARCH: $HOST_ARCH
exit 1
fi
fi
#if [ ${PLATFORM} = "Darwin" ]; then
args=
#else
#args=`getopt -a -o "h" -l "help,with-python-binary:,with-python-version:,cross-compile-python-root:,configure,build,clean:,host:" -n "compile_libraries" -- $*`
#fi
# daetools specific compiler flags
DAE_COMPILER_FLAGS="-fPIC"
BOOST_MACOSX_FLAGS=
DO_CONFIGURE="no"
DO_BUILD="no"
DO_CLEAN="no"
DAE_IF_CROSS_COMPILING=0
DAE_CROSS_COMPILE_FLAGS=
DAE_CROSS_COMPILER_PREFIX=
DAE_CROSS_COMPILE_TOOLCHAIN_FILE=
DAE_CROSS_COMPILE_PYTHON_ROOT=
# Process options
for i; do
case "$i" in
-h|--help) usage
exit 1
;;
--with-python-binary) PYTHON=$2
shift ; shift
;;
--with-python-version ) PYTHON=python$2
PYTHON_MAJOR=${2%.*}
PYTHON_MINOR=${2##*.}
shift ; shift
;;
--cross-compile-python-root) DAE_CROSS_COMPILE_PYTHON_ROOT=$2
shift ; shift
;;
--configure) DO_CONFIGURE="yes"
shift
;;
--build) DO_BUILD="yes"
shift
;;
--clean) DO_CLEAN="yes"
shift
;;
--host) DAE_IF_CROSS_COMPILING=1
DAE_CROSS_COMPILER=$2
DAE_CROSS_COMPILER_PREFIX="$2-"
DAE_CROSS_COMPILE_FLAGS="--host=$2"
DAE_CROSS_COMPILE_TOOLCHAIN_FILE="-DCMAKE_TOOLCHAIN_FILE=${TRUNK}/cross-compile-$2.cmake"
DAE_COMPILER_FLAGS=
HOST_ARCH="win32"
PLATFORM="Windows"
shift ; shift
;;
--) shift; break
;;
esac
done
MINGW_MAKE=
if [ "${PLATFORM}" = "Windows" ]; then
MINGW_MAKE="mingw32-make"
fi
if [ ${PLATFORM} = "Darwin" ]; then
Ncpu=$(/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | awk '/Total Number Of Cores/ {print $5};')
echo $Ncpu
# If there are problems with memory and speed of compilation set:
Ncpu=1
elif [ ${PLATFORM} = "Linux" ]; then
Ncpu=`cat /proc/cpuinfo | grep processor | wc -l`
else
Ncpu=4
fi
MAKE="make"
MAKE_Ncpu="make -j${Ncpu}"
CMAKE_GENERATOR="Unix Makefiles"
WGET="wget"
if [ ${PLATFORM} = "Windows" ]; then
DAE_COMPILER_FLAGS=""
MAKE="nmake"
MAKE_Ncpu="nmake"
CMAKE_GENERATOR="NMake Makefiles"
WGET="wget --no-check-certificate"
fi
if [ "${DAE_IF_CROSS_COMPILING}" = "0" ]; then
PYTHON_MAJOR=`${PYTHON} -c "import sys; print(sys.version_info[0])"`
PYTHON_MINOR=`${PYTHON} -c "import sys; print(sys.version_info[1])"`
PYTHON_INCLUDE_DIR=`${PYTHON} -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())"`
PYTHON_LIB_DIR=`${PYTHON} -c "import sys; print(sys.prefix)"`/lib
fi
PYTHON_VERSION=$PYTHON_MAJOR.$PYTHON_MINOR
SOLIBS_DIR="${TRUNK}/daetools-package/daetools/solibs/${PLATFORM}_${HOST_ARCH}/lib"
if [ ! -e ${SOLIBS_DIR} ]; then
mkdir -p ${SOLIBS_DIR}
fi
BIN_DIR="${TRUNK}/daetools-package/daetools/solibs/${PLATFORM}_${HOST_ARCH}/bin"
if [ ! -e ${BIN_DIR} ]; then
mkdir -p ${BIN_DIR}
fi
DAE_DEV_INCLUDE_DIR="${TRUNK}/daetools-dev/include"
if [ ! -e ${DAE_DEV_INCLUDE_DIR} ]; then
mkdir -p ${DAE_DEV_INCLUDE_DIR}
fi
DAE_DEV_LIB_DIR="${TRUNK}/daetools-dev/${PLATFORM}_${HOST_ARCH}/lib"
if [ ! -e ${DAE_DEV_LIB_DIR} ]; then
mkdir -p ${DAE_DEV_LIB_DIR}
fi
DAE_DEV_BIN_DIR="${TRUNK}/daetools-dev/${PLATFORM}_${HOST_ARCH}/bin"
if [ ! -e ${DAE_DEV_BIN_DIR} ]; then
mkdir -p ${DAE_DEV_BIN_DIR}
fi
if [ ${PLATFORM} = "Darwin" ]; then
DAE_COMPILER_FLAGS="${DAE_COMPILER_FLAGS} -arch x86_64"
BOOST_MACOSX_FLAGS="architecture=x86"
export CC=/usr/local/bin/gcc-8
export CXX=/usr/local/bin/g++-8
export CPP=/usr/local/bin/cpp-8
export LD=/usr/local/bin/gcc-8
export F77=/usr/local/bin/gfortran-8
alias gcc=/usr/local/bin/gcc-8
alias g++=/usr/local/bin/g++-8
alias cc=/usr/local/bin/gcc-8
alias c++=/usr/local/bin/c++-8
alias ld=/usr/local/bin/gcc-8
if type "wget" > /dev/null ; then
echo "wget found"
else
echo "cURL have problems to get files from Source Forge: geting wget instead..."
curl -O ftp://ftp.gnu.org/gnu/wget/wget-1.13.tar.gz
tar -xvzf wget-1.13.tar.gz
cd wget-1.13
./configure --with-ssl=openssl
make
sudo make install
fi
elif [ ${PLATFORM} = "Linux" ]; then
if [ ${HOST_ARCH} != "x86_64" ]; then
DAE_COMPILER_FLAGS="${DAE_COMPILER_FLAGS} -march=pentium4 -mfpmath=sse -msse -msse2"
#SSE_TAGS=`grep -m 1 flags /proc/cpuinfo | grep -o 'sse\|sse2\|sse3\|ssse3\|sse4a\|sse4.1\|sse4.2\|sse5'`
#for SSE_TAG in ${SSE_TAGS}
#do
# DAE_COMPILER_FLAGS="${DAE_COMPILER_FLAGS} -m${SSE_TAG}"
#done
fi
fi
if [ ${Ncpu} -gt 1 ]; then
Ncpu=$(($Ncpu+1))
fi
export DAE_COMPILER_FLAGS
export DAE_CROSS_COMPILER_PREFIX
DAE_UMFPACK_INSTALL_DIR="${TRUNK}/umfpack/build"
export DAE_UMFPACK_INSTALL_DIR
vBOOST=1.74.0
vBOOST_=1_74_0
vBONMIN=1.8.6
vBONMIN_WIN="1.8.6-msvc++-2015"
vLAPACK=3.4.1
vCLAPACK=3.2.1
vMUMPS_WIN="4.10.0-gfortran-win"
vNLOPT=2.4.2
vIDAS=1.3.0
vTRILINOS=12.10.1
vUMFPACK=5.6.2
vAMD=2.3.1
vMETIS=5.1.0
vCHOLMOD=2.1.2
vCAMD=2.3.1
vCOLAMD=2.8.0
vCCOLAMD=2.8.0
vSUITESPARSE_CONFIG=4.2.1
vOPENBLAS=0.2.8
vDEALII=8.5.0
vSUPERLU=5.2.1
vSUPERLU_MT=3.1
vCOOLPROP=6.1.0
#BOOST_BUILD_ID=daetools-py${PYTHON_MAJOR}${PYTHON_MINOR}
BOOST_BUILD_ID=daetools
BOOST_PYTHON_BUILD_ID=
BOOST_HTTP=http://sourceforge.net/projects/boost/files/boost
DAETOOLS_HTTP=http://sourceforge.net/projects/daetools/files/gnu-linux-libs
DAETOOLS_WIN_HTTP=http://sourceforge.net/projects/daetools/files/windows-libs
LAPACK_HTTP=http://www.netlib.org/lapack
CLAPACK_HTTP=${DAETOOLS_HTTP}
MUMPS_WIN_HTTP=${DAETOOLS_WIN_HTTP}
BONMIN_HTTP=${DAETOOLS_HTTP}
BONMIN_WIN_HTTP=${DAETOOLS_WIN_HTTP}
IDAS_HTTP=${DAETOOLS_HTTP}
BONMIN_HTTP=${DAETOOLS_HTTP}
#Old: SUPERLU_HTTP=http://crd.lbl.gov/~xiaoye/SuperLU
SUPERLU_HTTP=${DAETOOLS_HTTP}
#Old: TRILINOS_HTTP=http://trilinos.csbsju.edu/download/files
TRILINOS_HTTP=http://sourceforge.net/projects/daetools/files/gnu-linux-libs
#Old: NLOPT_HTTP=http://ab-initio.mit.edu/nlopt
NLOPT_HTTP=${DAETOOLS_HTTP}
METIS_HTTP=http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis
UMFPACK_HTTP=http://www.cise.ufl.edu/research/sparse/umfpack
AMD_HTTP=http://www.cise.ufl.edu/research/sparse/amd
CHOLMOD_HTTP=http://www.cise.ufl.edu/research/sparse/cholmod
CAMD_HTTP=http://www.cise.ufl.edu/research/sparse/camd
COLAMD_HTTP=http://www.cise.ufl.edu/research/sparse/colamd
CCOLAMD_HTTP=http://www.cise.ufl.edu/research/sparse/ccolamd
SUITESPARSE_CONFIG_HTTP=http://www.cise.ufl.edu/research/sparse/UFconfig
LIBMESH_HTTP=http://sourceforge.net/projects/libmesh/files/libmesh
DEALII_HTTP=https://github.com/dealii/dealii/releases/download
COOLPROP_HTTP=https://sourceforge.net/projects/coolprop/files/CoolProp/${vCOOLPROP}/source
# If no option is set use defaults
if [ "${DO_CONFIGURE}" = "no" -a "${DO_BUILD}" = "no" -a "${DO_CLEAN}" = "no" ]; then
DO_CONFIGURE="yes"
DO_BUILD="yes"
DO_CLEAN="no"
fi
if [ -z "$@" ]; then
# If no project is specified print usage and exit
usage
exit
else
# Check if requested solver exist
for solver in "$@"
do
case "$solver" in
all) ;;
boost) ;;
boost_static) ;;
ref_blas_lapack) ;;
cblas_clapack) ;;
mumps) ;;
openblas) ;;
umfpack) ;;
idas) ;;
idas_mpi) ;;
trilinos) ;;
superlu) ;;
superlu_mt) ;;
bonmin) ;;
nlopt) ;;
libmesh) ;;
deal.ii) ;;
coolprop) ;;
opencs) ;;
*) echo Unrecognized solver: "$solver"
exit
;;
esac
done
fi
echo ""
echo "###############################################################################"
echo "Proceed with the following options:"
echo " - Python: ${PYTHON}"
echo " - Python version: ${PYTHON_MAJOR}${PYTHON_MINOR}"
echo " - Python include dir: ${PYTHON_INCLUDE_DIR}"
echo " - Python lib dir: ${PYTHON_LIB_DIR}"
echo " - Platform: $PLATFORM"
echo " - Architecture: $HOST_ARCH"
echo " - Additional compiler flags: ${DAE_COMPILER_FLAGS}"
echo " - Cross-compile flags: ${DAE_CROSS_COMPILE_FLAGS}"
echo " - Number of threads: ${Ncpu}"
echo " - Projects to compile: $@"
echo " + Configure: [$DO_CONFIGURE]"
echo " + Build: [$DO_BUILD]"
echo " + Clean: [$DO_CLEAN]"
echo "###############################################################################"
echo ""
# ACHTUNG! cd to TRUNK (in case the script is called from some other folder)
cd "${TRUNK}"
#######################################################
# BOOST #
#######################################################
configure_boost()
{
if [ -e boost${PYTHON_VERSION} ]; then
rm -r boost${PYTHON_VERSION}
fi
echo ""
echo "[*] Setting-up boost"
echo ""
if [ ${PLATFORM} = "Windows" ]; then
if [ ! -e boost_${vBOOST_}.zip ]; then
$WGET ${BOOST_HTTP}/${vBOOST}/boost_${vBOOST_}.zip
fi
unzip boost_${vBOOST_}.zip
mv boost_${vBOOST_} boost
cd boost
else
if [ ! -e boost_${vBOOST_}.tar.gz ]; then
$WGET ${BOOST_HTTP}/${vBOOST}/boost_${vBOOST_}.tar.gz
fi
tar -xzf boost_${vBOOST_}.tar.gz
mv boost_${vBOOST_} boost
cd boost
fi
cd "${TRUNK}"
echo ""
echo "[*] Done!"
echo ""
}
compile_boost()
{
if [ "${DAE_IF_CROSS_COMPILING}" = "1" ]; then
cd boost${PYTHON_VERSION}
echo ""
echo "[*] Building boost"
echo ""
sh bootstrap.sh --with-python=${PYTHON}
BOOST_USER_CONFIG=~/user-config.jam
#GCC_CROSS="${DAE_CROSS_COMPILER}-g++ -Wl,${DAE_CROSS_COMPILE_PYTHON_ROOT}/libs/libpython${PYTHON_MAJOR}${PYTHON_MINOR}.a"
echo "using gcc : : ${DAE_CROSS_COMPILER}-g++ ;" > ${BOOST_USER_CONFIG}
echo "using python" >> ${BOOST_USER_CONFIG}
echo " : ${PYTHON_MAJOR}.${PYTHON_MINOR}" >> ${BOOST_USER_CONFIG}
echo " : " >> ${BOOST_USER_CONFIG}
echo " : ${DAE_CROSS_COMPILE_PYTHON_ROOT}/include " >> ${BOOST_USER_CONFIG}
echo " : ${DAE_CROSS_COMPILE_PYTHON_ROOT}/libs/libpython${PYTHON_MAJOR}${PYTHON_MINOR}.a" >> ${BOOST_USER_CONFIG}
echo " : <toolset>gcc" >> ${BOOST_USER_CONFIG}
echo " ;" >> ${BOOST_USER_CONFIG}
# https://stackoverflow.com/questions/3778370/python-extensions-for-win64-via-gcc
# There is a mechanism in Python to prevent linking a module against the wrong version of the library.
# The Py_InitModule4 function is renamed to Py_InitModule4_64 (via a macro) when the library / module is compiled
# for a 64-bit architecture (see modsupport.h) :
# #if SIZEOF_SIZE_T != SIZEOF_INT
# /* On a 64-bit system, rename the Py_InitModule4 so that 2.4
# modules cannot get loaded into a 2.5 interpreter */
# #define Py_InitModule4 Py_InitModule4_64
# #endif
if [ "${DAE_CROSS_COMPILER}" = "x86_64-w64-mingw32" ]; then
export CXX=MS_WIN64
export CPPFLAGS=MS_WIN64
fi
export CPLUS_INCLUDE_PATH=${DAE_CROSS_COMPILE_PYTHON_ROOT}/include
./bjam --build-dir=./build --debug-building --layout=system --buildid=${BOOST_BUILD_ID} \
--with-date_time --with-system --with-filesystem --with-regex --with-serialization --with-thread \
toolset=gcc target-os=windows threadapi=win32 \
variant=release link=shared threading=multi runtime-link=shared ${BOOST_MACOSX_FLAGS}
# To copy only i.e. libboost_system-*.so.1.70.0 on GNU/Linux (skip the symlinks).
if [ ${PLATFORM} = "Linux" ]; then
BOOST_PYTHON_BUILD_ID=${vBOOST}
fi
# Copy to daetools-package
cp -fa stage/lib/libboost_system-${BOOST_BUILD_ID}*${BOOST_PYTHON_BUILD_ID} ${SOLIBS_DIR}
cp -fa stage/lib/libboost_thread_win32-${BOOST_BUILD_ID}*${BOOST_PYTHON_BUILD_ID} ${SOLIBS_DIR}
cp -fa stage/lib/libboost_filesystem-${BOOST_BUILD_ID}*${BOOST_PYTHON_BUILD_ID} ${SOLIBS_DIR}
# Copy to daetools-dev
cp -fa stage/lib/libboost_system-${BOOST_BUILD_ID}*${BOOST_PYTHON_BUILD_ID} ${DAE_DEV_LIB_DIR}
cp -fa stage/lib/libboost_thread_win32-${BOOST_BUILD_ID}*${BOOST_PYTHON_BUILD_ID} ${DAE_DEV_LIB_DIR}
cp -fa stage/lib/libboost_filesystem-${BOOST_BUILD_ID}*${BOOST_PYTHON_BUILD_ID} ${DAE_DEV_LIB_DIR}
# Achtung, Achtung!
# The following will fail at the linking phase!
# Redo the link with the value of:
# ${DAE_CROSS_COMPILE_PYTHON_ROOT}/libs/libpython${PYTHON_MAJOR}${PYTHON_MINOR}.a
# appended at the end of the linking line, and manually copy the .dll to the "daetools/solibs/${PLATFORM}_${HOST_ARCH}" directory.
./bjam --build-dir=./build --debug-building --layout=system --buildid=${BOOST_BUILD_ID} \
--with-python \
toolset=gcc target-os=windows threadapi=win32 \
variant=release link=shared threading=multi runtime-link=shared ${BOOST_MACOSX_FLAGS}
# Restore the variables
export CXX=
export CPPFLAGS=
export CPLUS_INCLUDE_PATH=
LIBBOOST_PYTHON_SUF="${PYTHON_MAJOR}"
if [ "${PYTHON_MAJOR}" = "2" ]; then
LIBBOOST_PYTHON_SUF=""
fi
cp -fa stage/lib/libboost_python${LIBBOOST_PYTHON_SUF}-${BOOST_BUILD_ID}*${BOOST_PYTHON_BUILD_ID} ${SOLIBS_DIR}
cp -fa stage/lib/libboost_python${LIBBOOST_PYTHON_SUF}-${BOOST_BUILD_ID}*${BOOST_PYTHON_BUILD_ID} ${DAE_DEV_LIB_DIR}
else # regular compiler (not a cross-compiler)
cd boost # ${PYTHON_VERSION}
echo ""
echo "[*] Building boost"
echo ""
BOOST_USER_CONFIG=~/user-config.jam
if [ ${PLATFORM} = "Windows" ]; then
# There is a problem with executing bootstrap.bat with arguments from bash.
# Solution: create a proxy batch file which runs 'bootstrap vc14'.
echo "call bootstrap vc14" > dae_bootstrap.bat
cmd "/C dae_bootstrap"
# There is a problem when there are multiple vc++ version installed.
# Therefore, specify the version in the jam file.
echo "using msvc : 14.0 : : ;" > ${BOOST_USER_CONFIG}
echo "using python" >> ${BOOST_USER_CONFIG}
echo " : " >> ${BOOST_USER_CONFIG}
echo " : " >> ${BOOST_USER_CONFIG}
echo " : " >> ${BOOST_USER_CONFIG}
echo " : " >> ${BOOST_USER_CONFIG}
echo " : <toolset>msvc" >> ${BOOST_USER_CONFIG}
echo " ;" >> ${BOOST_USER_CONFIG}
if [ $HOST_ARCH = "win64" ]; then
ADDRESS_MODEL="address-model=64 architecture=x86"
else
ADDRESS_MODEL="address-model=32 architecture=x86"
fi
./bjam --build-dir=./build --debug-building --layout=system --buildid=${BOOST_BUILD_ID} \
--with-date_time --with-system --with-filesystem --with-regex --with-serialization --with-thread --with-python \
variant=release link=shared threading=multi runtime-link=shared ${ADDRESS_MODEL}
LIBBOOST_PYTHON_SUF="${PYTHON_MAJOR}${PYTHON_MINOR}"
# Copy to daetools-package
cp -fa stage/lib/boost_python${LIBBOOST_PYTHON_SUF}-${BOOST_BUILD_ID}${BOOST_PYTHON_BUILD_ID}*.dll ${SOLIBS_DIR}
cp -fa stage/lib/boost_system-${BOOST_BUILD_ID}${BOOST_PYTHON_BUILD_ID}*.dll ${SOLIBS_DIR}
cp -fa stage/lib/boost_thread-${BOOST_BUILD_ID}${BOOST_PYTHON_BUILD_ID}*.dll ${SOLIBS_DIR}
cp -fa stage/lib/boost_filesystem-${BOOST_BUILD_ID}${BOOST_PYTHON_BUILD_ID}*.dll ${SOLIBS_DIR}
cp -fa stage/lib/boost_chrono-${BOOST_BUILD_ID}${BOOST_PYTHON_BUILD_ID}*.dll ${SOLIBS_DIR}
# Copy to daetools-dev (.dll and .lib files)
cp -fa stage/lib/boost_python${LIBBOOST_PYTHON_SUF}-${BOOST_BUILD_ID}${BOOST_PYTHON_BUILD_ID}*.* ${DAE_DEV_LIB_DIR}
cp -fa stage/lib/boost_system-${BOOST_BUILD_ID}${BOOST_PYTHON_BUILD_ID}*.* ${DAE_DEV_LIB_DIR}
cp -fa stage/lib/boost_thread-${BOOST_BUILD_ID}${BOOST_PYTHON_BUILD_ID}*.* ${DAE_DEV_LIB_DIR}
cp -fa stage/lib/boost_filesystem-${BOOST_BUILD_ID}${BOOST_PYTHON_BUILD_ID}*.* ${DAE_DEV_LIB_DIR}
cp -fa stage/lib/boost_chrono-${BOOST_BUILD_ID}${BOOST_PYTHON_BUILD_ID}*.* ${DAE_DEV_LIB_DIR}
else
sh bootstrap.sh --with-python=${PYTHON}
echo "using python" > ${BOOST_USER_CONFIG}
echo " : ${PYTHON_MAJOR}.${PYTHON_MINOR}" >> ${BOOST_USER_CONFIG}
echo " : ${PYTHON}" >> ${BOOST_USER_CONFIG}
echo " : ${PYTHON_INCLUDE_DIR}" >> ${BOOST_USER_CONFIG}
echo " : ${PYTHON_LIB_DIR}" >> ${BOOST_USER_CONFIG}
echo " : <toolset>gcc" >> ${BOOST_USER_CONFIG}
echo " ;" >> ${BOOST_USER_CONFIG}
./tools/build/src/engine/bjam --build-dir=./build --debug-building --buildid=${BOOST_BUILD_ID} --layout=system \
--with-python \
variant=release link=shared threading=multi runtime-link=shared ${BOOST_MACOSX_FLAGS}
LIBBOOST_PYTHON_SUF="${PYTHON_MAJOR}${PYTHON_MINOR}"
# To copy only i.e. libboost_system-*.so.1.70.0 on GNU/Linux (skip the symlinks).
if [ ${PLATFORM} = "Linux" ]; then
BOOST_PYTHON_BUILD_ID=${vBOOST}
fi
# Copy to daetools-package
cp -fa stage/lib/libboost_python${LIBBOOST_PYTHON_SUF}-${BOOST_BUILD_ID}*${BOOST_PYTHON_BUILD_ID} ${SOLIBS_DIR}
# Copy to daetools-dev
cp -fa stage/lib/libboost_python${LIBBOOST_PYTHON_SUF}-${BOOST_BUILD_ID}*${BOOST_PYTHON_BUILD_ID} ${DAE_DEV_LIB_DIR}
fi
fi
echo ""
echo "[*] Done!"
echo ""
cd "${TRUNK}"
}
clean_boost()
{
echo ""
echo "[*] Cleaning boost..."
echo ""
cd boost${PYTHON_VERSION}
./bjam --clean
cd "${TRUNK}"
echo ""
echo "[*] Done!"
echo ""
}
#######################################################
# BOOST STATIC #
#######################################################
configure_boost_static()
{
if [ -e boost ]; then
rm -r boost
fi
echo ""
echo "[*] Setting-up boost_static"
echo ""
BOOST_USER_CONFIG=~/user-config.jam
echo "using mpi ;" > ${BOOST_USER_CONFIG}
if [ ${PLATFORM} = "Windows" ]; then
if [ ! -e boost_${vBOOST_}.zip ]; then
$WGET ${BOOST_HTTP}/${vBOOST}/boost_${vBOOST_}.zip
fi
unzip boost_${vBOOST_}.zip
mv boost_${vBOOST_} boost-static
cd boost-static
# There is a problem when there are multiple vc++ version installed.
# Therefore, specify the version in the jam file.
echo "using msvc : 14.0 : : ;" >> ${BOOST_USER_CONFIG}
# There is a problem with executing bootstrap.bat with arguments from bash.
# Solution: create a proxy batch file which runs 'bootstrap vc14'.
echo "call bootstrap vc14" > dae_bootstrap.bat
cmd "/C dae_bootstrap"
else
if [ ! -e boost_${vBOOST_}.tar.gz ]; then
$WGET ${BOOST_HTTP}/${vBOOST}/boost_${vBOOST_}.tar.gz
fi
tar -xzf boost_${vBOOST_}.tar.gz
mv boost_${vBOOST_} boost-static
cd boost-static
sh bootstrap.sh
fi
cd "${TRUNK}"
echo ""
echo "[*] Done!"
echo ""
}
compile_boost_static()
{
cd boost-static
echo ""
echo "[*] Building boost_static"
echo ""
BOOST_USER_CONFIG=~/user-config.jam
if [ ${PLATFORM} = "Windows" ]; then
if [ $HOST_ARCH = "win64" ]; then
ADDRESS_MODEL="address-model=64 architecture=x86"
else
ADDRESS_MODEL="address-model=32 architecture=x86"
fi
./bjam --build-dir=./build --debug-building --layout=system \
--with-system --with-filesystem --with-thread --with-regex --with-mpi --with-serialization \
variant=release link=static threading=multi runtime-link=shared cxxflags="\MD" ${ADDRESS_MODEL}
else
./bjam --build-dir=./build --debug-building --layout=system \
--with-system --with-filesystem --with-thread --with-regex --with-mpi --with-serialization \
variant=release link=static threading=multi runtime-link=shared cxxflags="-fPIC"
fi
echo ""
echo "[*] Done!"
echo ""
cd "${TRUNK}"
}
clean_boost_static()
{
echo ""
echo "[*] Cleaning boost_static..."
echo ""
cd boost-static
./bjam --clean
cd "${TRUNK}"
echo ""
echo "[*] Done!"
echo ""
}
#######################################################
# OpenBLAS #
#######################################################
configure_openblas()
{
if [ "${DAE_IF_CROSS_COMPILING}" = 1 ]; then
echo "OpenBLAS not configured for cross-compiling at the moment"
exit
fi
if [ -e openblas ]; then
rm -r openblas
fi
echo ""
echo "Setting-up openblas..."
echo ""
if [ ! -e openblas-${vOPENBLAS}.tar.gz ]; then
$WGET ${DAETOOLS_HTTP}/openblas-${vOPENBLAS}.tar.gz
fi
if [ ! -e Makefile-openblas.rule ]; then
$WGET ${DAETOOLS_HTTP}/Makefile-openblas.rule
fi
tar -xzf openblas-${vOPENBLAS}.tar.gz
cp Makefile-openblas.rule openblas/Makefile.rule
cd openblas
mkdir build
cd "${TRUNK}"
echo ""
echo "[*] Done!"
echo ""
}
compile_openblas()
{
cd openblas
echo ""
echo "[*] Building openblas..."
echo ""
${MAKE_Ncpu} libs
${MAKE_Ncpu}
${MAKE} prefix=build install
cp -a libopenblas_daetools* ${SOLIBS_DIR}
cp -a libopenblas_daetools* ${DAE_DEV_LIB_DIR}
echo ""
echo "[*] Done!"
echo ""
cd "${TRUNK}"
}
clean_openblas()
{
echo ""
echo "[*] Cleaning openblas..."
echo ""
cd openblas
${MAKE} clean
cd "${TRUNK}"
echo ""
echo "[*] Done!"
echo ""
}
#######################################################
# Reference BLAS and LAPACK #
#######################################################
configure_ref_blas_lapack()
{
if [ -e lapack ]; then
rm -r lapack
fi
echo ""
echo "[*] Setting-up reference blas & lapack..."
echo ""
if [ ! -e lapack-${vLAPACK}.tgz ]; then
$WGET ${LAPACK_HTTP}/lapack-${vLAPACK}.tgz
fi
if [ ! -e daetools_lapack_make.inc ]; then
$WGET ${DAETOOLS_HTTP}/daetools_lapack_make.inc
fi
tar -xzf lapack-${vLAPACK}.tgz
mv lapack-${vLAPACK} lapack
cd lapack
cmake \
-G"${CMAKE_GENERATOR}" \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_INSTALL_PREFIX:STRING="${TRUNK}/lapack" \
-DBUILD_DOUBLE:BOOL=ON \
-DBUILD_STATIC_LIBS:BOOL=ON \
-DCMAKE_Fortran_FLAGS:STRING="${DAE_COMPILER_FLAGS}" \
${DAE_CROSS_COMPILE_TOOLCHAIN_FILE}
cd "${TRUNK}"
echo ""
echo "[*] Done!"
echo ""
}
compile_ref_blas_lapack()
{
cd lapack
echo ""
echo "[*] Building reference blas & lapack..."
echo ""
${MAKE_Ncpu} lapack
${MAKE_Ncpu} blas
echo ""
echo "[*] Done!"
echo ""
cd "${TRUNK}"
}
clean_ref_blas_lapack()
{
echo ""
echo "[*] Cleaning reference blas & lapack..."
echo ""
cd lapack
${MAKE} clean
cd "${TRUNK}"
echo ""
echo "[*] Done!"
echo ""
}
#######################################################
# CBLAS and CLAPACK #
#######################################################
configure_cblas_clapack()
{
if [ -e clapack ]; then
rm -r clapack
fi
echo ""
echo "[*] Setting-up cblas & clapack..."
echo ""
if [ ! -e clapack-${vCLAPACK}-CMAKE.tgz ]; then
$WGET ${CLAPACK_HTTP}/clapack-${vCLAPACK}-CMAKE.tgz
fi
tar -xzf clapack-${vCLAPACK}-CMAKE.tgz
mv clapack-${vCLAPACK}-CMAKE clapack
cd clapack
mkdir -p build
# Might need configure from the cmake-gui
cmake \
-G"${CMAKE_GENERATOR}" \
-DBUILD_TESTING:BOOL=OFF \
-DUSE_BLAS_WRAP:BOOL=OFF \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_INSTALL_PREFIX:PATH="${TRUNK}/clapack/build" \
-DBUILD_STATIC_LIBS:BOOL=ON
cmake-gui .
cd "${TRUNK}"
echo ""
echo "[*] Done!"
echo ""
}
compile_cblas_clapack()
{
cd clapack
echo ""
echo "[*] Building cblas & clapack..."
echo ""
${MAKE_Ncpu} install
echo ""
echo "[*] Done!"
echo ""
cd "${TRUNK}"
}
clean_cblas_clapack()
{
echo ""
echo "[*] Cleaning cblas & clapack..."
echo ""
cd clapack
cd build
${MAKE} clean
cd "${TRUNK}"
echo ""
echo "[*] Done!"
echo ""
}
#######################################################
# CoolProp #
#######################################################
configure_coolprop()
{
if [ -e coolprop ]; then
rm -r coolprop
fi
echo ""
echo "[*] Setting-up coolprop..."
echo ""
if [ ! -e CoolProp_sources.zip ]; then
$WGET ${COOLPROP_HTTP}/CoolProp_sources.zip
fi
unzip CoolProp_sources.zip
mv CoolProp.sources coolprop
# Patch for the expected unqualified-id before numeric constant error (line 1890 and gcc 7.1):
# const unsigned CHAR_WIDTH = 1;
# CHAR_WIDTH is already defined in <limits.h> as a macro.
sed -i -e 's/CHAR_WIDTH/CHAR_WIDTH_1/g' coolprop/externals/cppformat/fmt/format.h
cd coolprop
mkdir -p build
cd build
COOLPROP_CXX_FLAGS=
if [ ${PLATFORM} = "Windows" ]; then
COOLPROP_CXX_FLAGS="/MD /EHsc"
fi
cmake \
-G"${CMAKE_GENERATOR}" \
-DCMAKE_BUILD_TYPE:STRING=Release \