forked from ESP-rCommunity/ESP-rSource
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Install
executable file
·2143 lines (2036 loc) · 77.2 KB
/
Install
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
#
# This script coordinates the installation of ESP-r executables,
# databases, example models and support materials. It can be used
# on linux, cygwin, mingw, OS X and Windows platforms.
# Source and target directories.
HOMEdir=`pwd` # Current directory.
DESTdir=/opt/esp-r # Installation directory.
ESPdir=$DESTdir
DATdir="${HOMEdir}/data" # Source data directory.
DOCdir="${HOMEdir}/doc" # Source documents directory.
SCRIPTdir="${HOMEdir}/src/bin" # Source scripts directory.
MODdir="${HOMEdir}/models" # Source models directory.
TRAdir="${MODdir}/training" # Source training models.
VALdir="${MODdir}/validation" # Source validation models.
SRCdir="${HOMEdir}/src" # Source code directory.
COSIMdir=" " # Harmonizer installation directory.
# Compilation settings.
mode="interactive" # Feedback during installation.
xml_support="yes" # Support for XML output.
SQLite_support="no" # Support for SQLite output.
FMI_support="no" # Support for FMI connectivity.
debugging="no" # Support for debugging symbols.
EXE="" # Executable file extension.
debian_copy="no" # no=standard make install yes=make bincopy
opt="-O1" # Optimisation to be applied
FFLAGS="-I../include " # Fortran compiler flags.
CFLAGS="-I../include " # C compiler flags.
LD_FLAGS=" " # Link-loader flags.
complexity="2" # Model complexity (medium by default).
platform="auto-detect" # Installation platform.
install_dbs="yes" # Install databases.
install_training="yes" # Install training models.
install_exes="yes" # Install executables.
delete_temp_files="yes" # Delete temporary files.
preserve_espr_dir="yes" # Preserve installation directory.
gnu_version="gcc4" # Required gcc version.
make_msg_file=".make_msg" # Dump messages from 'make' to file.
compiler_version="none" # Compiler version.
xLibs="X11" # Required x-library.
enable_cosim="no" # TRNSYS co-simulation.
extendedDebug="no" # Extended debugging.
use_intel="no" # Use Intel compilers.
skip_ish_calcs="no" # Binary shading file creation.
reuse_ish_calcs="yes" # Map ascii shading files to binary.
clean="yes" # Clean object files after compilation.
unversioned="no" # Check for versioning info.
# ESP-r executables (bld & plt not included by default because their
# functionality is automatically encapsulated in bps).
programs="aco b2e bps dfs dfv cdb c2e clm e2r ecnv eco enet grd ish mfs mld mrt pdb prj res vew"
programs=" ${programs} " # Leading/ trailing space added for regexp matching.
targets=" " # Will be overwitten later.
third_party="no" # Suggest installation of third party tools at end of script.
# Determine computer architecture and availability of stat.
architecture=`uname -s` # Kernel name.
machine=`uname -m` # Hardware name.
case $machine in
x86_64) echo "Detected Intel chipset";;
arm64) echo "Detected Mx chipset";;
aarch64)echo "Detected arm chipset";;
esac
if [ -x /usr/bin/stat ]; then
stat_avail="yes"
elif [ -x /bin/stat ]; then
stat_avail="yes"
else
stat_avail="no"
fi
# Process Install script command line options.
help=0
input="no"
if [ $# -ne 0 ]; then
for i do
if [ "${input}" = "yes" ]; then
input="no"
else
case "$i" in
-h | --help) help=1; shift;;
--debug) debugging=yes; clean=no; shift;;
-d) shift; DESTdir=$1; input="yes";
ESPdir=$DESTdir; shift;;
--force) preserve_espr_dir="no"; shift;;
--debian) debian_copy="yes"; shift;;
--no_training | --no-training)
install_training="no"; shift;;
--no_dbs | --no-dbs)
install_dbs="no"; shift;;
--no_exes | --no-exes)
install_exes="no"; shift;;
--extra-debug | --extra_debug)
debugging="yes"; clean=no;
extendedDebugging="yes"; shift;;
--silent) mode="silent"; shift;;
--xml) xml_support=yes; shift;;
--SQLite) SQLite_support="yes"; shift;;
--FMI) FMI_support="yes"; shift;;
--co-sim) shift;
COSIMdir=$1;
input="yes";
enable_cosim="yes"; shift;;
--gcc4) gnu_version="gcc4"; shift;;
--opt0) opt="-O0"; shift;;
--opt1) opt="-O1"; shift;;
--opt2) opt="-O2"; shift;;
--opt3) opt="-O3"; shift;;
--small) complexity="1"; shift;;
--medium) complexity="2"; shift;;
--complex) complexity="3"; shift;;
--intel) use_intel="yes"; shift;;
--X11) xLibs="X11"; shift;;
--GTK) xLibs="GTK"; shift;;
--noX) xLibs="noX"; shift;;
--compiler_version | --compiler-version)
shift;
input="yes";
compiler_version=$1; shift;;
-v | --verbose) make_msg_file=""; shift;;
--reuse_ish_calcs) reuse_ish_calcs="yes"; shift;;
--unversioned) unversioned="yes"; shift;;
--quick_rebuild) clean="no"; shift;;
--skip_ish_calcs | --skip-ish-calcs )
skip_ish_calcs="yes"; shift;;
--quick_rebuild | --quick-rebuild )
clean="no"; shift;;
--no-svn-query | --no_svn_query)
unversioned="yes"; shift;;
clean) targets="${targets} clean" shift;;
*)
# Check if target is buildable.
match="no"
position=`expr match " $programs " ".* ${i} .*"`
if [ "${position}" != 0 ]; then
targets="${targets} ${i}"
shift
else
# Trap unsupported arguments.
echo " "
echo " Error: argument $i is not supported."
echo " Run ./Install --help."
echo " "
exit
fi
;;
esac
fi
done
fi
# If Targets is empty, build all programs.
if [ "${targets}" = " " ]; then
targets="${programs}"
third_party="yes"
else
# Add a trailing space for regexp search.
targets="${targets} "
fi
if [ "$enable_cosim" == "yes" ]; then
targets="harmonizer harmonizerdll bpsdll"
fi
# Install script help.
if [ $help -eq 1 ]; then
echo " "
echo " Usage: ./Install [OPTIONS] [NAME]"
echo " "
echo " This script will install all or parts of ESP-r"
echo " on your computer. A complete default installation"
echo " is typically achieved by executing the script with"
echo " no arguments:"
echo " "
echo " $ ./Install"
echo " "
echo " Alternatively, command line arguments can be used"
echo " to control specific aspects; some examples follow."
echo " "
echo " To install ESP-r in a directory other than the"
echo " default (/opt/esp-r):"
echo " "
echo " $ ./Install -d <directory>"
echo " "
echo " To build specific executables (bps, prj etc.):"
echo " "
echo " $ ./Install <program list>"
echo " "
echo " To build and install in a specific location:"
echo " "
echo " $ ./Install -d <directory> <program list>"
echo " "
echo " To install ESP-r in silent mode:"
echo " "
echo " $ ./Install --silent"
echo " "
echo " Command line arguments:"
echo " "
echo " <NAME>"
echo " Install one or more named programs"
echo " (e.g.'./Install clm')"
echo " "
echo " --compiler-version <STRING>"
echo " Append STRING to the default compiler"
echo " (e.g. '--compiler_version -4.3')"
echo " "
echo " -d <PATH>, --destination <PATH>"
echo " Install ESP-r components in directory PATH"
echo " (default is ${DESTdir})."
echo " "
echo " --debug"
echo " Include debugging symbols in ESP-r binaries"
echo " (preserves object files allowing an executable"
echo " to be rapidly rebuilt during development)."
echo " "
echo " --extra-debug"
echo " Adds pedantic range checking, floating-point"
echo " exception handling and stack dump capabilities"
echo " (supported by Intel and gcc compilers)."
echo " "
echo " --quick_rebuild"
echo " Preserve object files after running the Install"
echo " script to facilitate rapid recompilation in cases"
echo " where a limited number of source files are being"
echo " modified."
echo " "
echo " --force"
echo " Overwrite a corrupted installation."
echo " "
echo " --gcc4"
echo " Use the gcc4 or newer compilers (gcc, g++ and gFortran)."
echo " (the default)."
echo " "
echo " --opt0"
echo " No compiler optimisation"
echo " "
echo " --opt1"
echo " -O1 compiler optimisation ~x1.5 speed"
echo " "
echo " --opt2"
echo " -O2 compiler optimisation ~x1.7 speed"
echo " "
echo " --opt3"
echo " -O3 compiler optimisation ~x1.8 speed"
echo " "
echo " --small"
echo " Smallest executable size for computers with"
echo " limited memory, e.g. a virtual machine."
echo " "
echo " --medium"
echo " Medium executable size (default)."
echo " "
echo " --complex"
echo " Large executable size to accommodate complex"
echo " models (requires high memory and disk capacity)."
echo " "
echo " -h, --help"
echo " Display this help message."
echo " "
echo " --intel"
echo " Use the Intel compiler suite (icc,ifort,icpc)."
echo " "
echo " --no-dbs"
echo " Skip installation of database."
echo " "
echo " --no-exes"
echo " Do not copy executable files to the"
echo " installation directory."
echo " "
echo " --no-training"
echo " Skip installation of training models."
echo " "
echo " --no-svn-query"
echo " Do not query svn for versioning information."
echo " "
echo " --skip-ish-calcs"
echo " Skip recalculation of shading files associated"
echo " with example and validation models."
echo " "
echo " --reuse_ish_calcs"
echo " Convert existing ascii shading files associated"
echo " with example and validation models."
echo " "
echo " --silent"
echo " Invoke a silent installation using default"
echo " options (perhaps replaced by command-line"
echo " alternatives)."
echo " "
echo " --X11, --GTK, --noX"
echo " Use the specified graphics library."
echo " "
echo " --xml"
echo " Compile bps with support for results exporting"
echo " in xml and csv formats (requires the GNU libxml2"
echo " and libstdc++ libraries)."
echo " "
echo " --SQLite"
echo " Compile bps with support for results exporting"
echo " to a SQLite database (requires the libsqlite3.so"
echo " library)."
echo " "
echo " --FMI"
echo " Add Functional Mockup Interface functionality"
echo " to prj and bps (the required header files and"
echo " libraries must be available - see the FMI"
echo " developers guide in doc/manual/FMI/Developers)."
echo " "
echo " --co-sim <PATH>"
echo " Compile Harmonizer.exe, Harmonizer.dll and bps.dll"
echo " for ESP-r/ TRNSYS co-simulation and install the"
echo " executable in PATH (works only under MinGW)."
echo " "
echo " -v, --verbose"
echo " Print compilation messages to screen."
echo " "
echo " --platform <OS>"
echo " Specify platform operating system (e.g. '--platform Linux')"
echo " "
echo " Notes:"
echo " "
echo " 1. From ESP-r Version 12.3 on it is not possible to compile"
echo " with gcc3/ g77, which are obsolete. Use gcc4/ gFortran."
echo " "
echo " 2. There are two flavours of ESP-r: the full distribution"
echo " based on X11 graphic libraries and a version based on"
echo " GTK graphic libraries that lacks some features."
exit
fi
# xml support.
if [ "$xml_support" = "yes" ] || [ "$xml_support" = "prompt" ]; then
if [ ! -d /usr/include/libxml2 ] && [ ! -d /usr/local/include/libxml2 ] && [ ! -d /usr/local/opt/libxml2 ] && [ ! -d /opt/homebrew/opt/libxml2 ]; then
xml_support="no"
xml_libs_found="no"
if [ "$mode" = "silent" ]; then
echo " "
echo "Warning: libxml2 headers not found in /usr/include"
echo "or /usr/local/include - xml output support disabled."
fi
else
xml_libs_found="yes"
LIBXML2_INCLUDE="-I/usr/include -I/usr/include/libxml2 -I/usr/local/include/libxml2 -I/opt/homebrew/opt/libxml2/include/libxml2 -I/usr/include/libxslt -I/local/include/libxslt -I/opt/homebrew/opt/libxslt/include/libxslt"
# xml support may optionally include support for xslt & exslt
# (following code tested only with GNU ld).
if [ "${architecture:0:6}" = "CYGWIN" ]; then
ld_output=`cygcheck -c libxslt | grep libxslt`
elif [ "${architecture:0:5}" = "MINGW" ] || [ "${architecture:0:4}" = "MSYS" ]; then
ld_output=`ld -l libxslt`
else
ld_output=`ldconfig -p | grep libxslt`
fi
case $ld_output in
"") xsl_libs_available="no";;
*) xsl_libs_available="yes";;
esac
fi
fi
# SQLite support.
if [ "$SQLite_support" = "yes" ]; then
if [ "${architecture:0:6}" = "CYGWIN" ]; then
ld_output=`cygcheck -c libsqlite | grep libsqlite`
elif [ "${architecture:0:5}" = "MINGW" ] || [ "${architecture:0:4}" = "MSYS" ]; then
ld_output=`ld -l libsqlite`
else
ld_output=`ldconfig -p | grep libsqlite`
fi
case $ld_output in
"" ) SQLite_libs_found="no";
SQLite_support="no";
if [ "$mode" = "silent" ]; then
echo " "
echo "Warning: Library libsqlite3 not found."
echo "SQLite support disabled."
fi
;;
* ) SQLite_libs_found="yes";
if [ "$xml_support" = "no" ]; then
SQLite_support="no"
if [ "$mode" = "silent" ]; then
echo " "
echo "Warning: SQLite requires the xml option which"
echo "has not been enabled. SQLite support disabled."
fi
else
LIBSQLITE3_INCLUDE="-I/usr/lib -lsqlite3"
fi
;;
esac
fi
# FMI support.
if [ "$FMI_support" = "prompt" ]; then
found=true
if [ ! -f "/usr/lib/libfmilib_shared.so" ]; then
found=false
if [ "$mode" = "silent" ]; then
echo " "
echo "Warning: FMI library libfmilib_shared.so not"
echo "found in /usr/lib. FMI support disabled."
fi
fi
if [ ! -d "/usr/include/FMI" ] &&
[ ! -d "/usr/include/FMI1" ] &&
[ ! -d "/usr/include/FMI2" ] &&
[ ! -d "/usr/include/JM" ] &&
[ ! -f "/usr/include/fmilib.h" ] &&
[ ! -f "/usr/include/fmilib_config.h" ]; then
found=false
if [ "$mode" = "silent" ]; then
echo " "
echo "Warning: FMI header files not found in"
echo "in /usr/include. FMI support disabled."
fi
fi
if $found; then
FMI_libs_found="yes"
else
FMI_libs_found="no"
fi
elif [ "$FMI_support" = "yes" ]; then
# Assume FMI library resources are within linker/ compiler paths.
FMI_libs_found="assume"
fi
# Determine computer architecture.
if [ "$platform" = "auto-detect" ]; then
if [ "$architecture" != "Linux" ] &&
[ "$architecture" != "CYGWIN_NT-5.1" ] &&
[ "$architecture" != "CYGWIN_NT-5.0" ] &&
[ "$architecture" != "CYGWIN_NT-5.2" ] &&
[ "$architecture" != "CYGWIN_NT-6.0" ] &&
[ "$architecture" != "CYGWIN_NT-6.1" ] &&
[ "$architecture" != "CYGWIN_NT-6.1-WOW64" ] &&
[ "$architecture" != "CYGWIN_NT-10.0" ] &&
[ "$architecture" != "MINGW32_NT-5.1" ] &&
[ "$architecture" != "MINGW32_NT-5.2" ] &&
[ "$architecture" != "MINGW32_NT-6.1" ] &&
[ "$architecture" != "MINGW64_NT-6.1" ] &&
[ "$architecture" != "MINGW64_NT-10.0" ] &&
[ "$architecture" != "MSYS_NT-6.1" ] &&
[ "$architecture" != "Darwin" ] &&
[ "$architecture" != "SunOS" ]; then
platform="prompt";
if [ "$mode" = "silent" ]; then
echo " "
echo "Error: could not determine computer architecture"
echo "${architecture}. Specify using the --platform switch"
echo "or run script in interactive mode."
exit
fi
fi
fi
echo " "
echo "Executing ESP-r installation script."
echo " "
echo "This creates the ESP-r system based on the source files found in"
echo "directory ${HOMEdir}"
echo "and installs the result in directory ${DESTdir}."
echo " "
echo "If you are new to this procedure, please consult"
echo "file ${SRCdir}/Readme before proceeding."
echo " "
echo "Use Install --help to obtain a list of the avaiable options."
# Prompt user for basic options if script is running interactively.
if [ "$mode" = "interactive" ]; then
echo " "
echo "Please answer the following questions. Default answers"
echo "are in []; press return to accept."
if [ "${platform}" = "auto-detect" ]; then
YN=none;
echo " "
echo "Your computer identifies itself as ${architecture} with"
echo "${machine} processor. Is this correct (y/n)? [y]"
while [ "$YN" != "y" ] && [ "$YN" != "n" ] && [ "$YN" != "" ]
do
if [ "$YN" != "none" ]; then
echo " "
echo "Please answer 'y' or 'n' [y]."
fi
read YN
done
if [ "$YN" = "n" ]; then
platform="prompt" # Ask user.
fi
fi
if [ "${platform}" = "prompt" ]; then
A=none;
while [ $A != "1" ] &&
[ $A != "2" ] &&
[ $A != "3" ] &&
[ $A != "4" ] &&
[ $A != "5" ] &&
[ $A != "6" ]
do
if [ $A != "none" ]; then
echo " "
echo "Choose an option from the list."
fi
echo " "
echo "Computer type:"
echo " (1) Solaris;"
echo " (2) Linux;"
echo " (3) Cygwin;"
echo " (4) MinGW;"
echo " (5) MacOS X (10.4 or later)."
read A
# Use the 'known_host' keyword to permit compilation
# on frequently used, nonstandard hosts.
if [ "$A" = "known_host" ]; then
echo " "
echo "Host: "
echo " (1) nrn7 (SunOS)"
read A
case $A in
1) custom_host="nrn7"
A=1
mode="silent";;
*) echo "Error: unknown host."
exit;;
esac
fi
done
case "$A" in
1) platform=sun;;
2) platform=linux;;
3) platform=cygwin;;
4) platform=mingw;;
5) platform=mac;;
esac
fi
fi
if [ "$platform" = "auto-detect" ]; then
case $architecture in
Linux) platform="linux";;
CYGWIN_NT-5.2 | CYGWIN_NT-5.1 | CYGWIN_NT-5.0 | CYGWIN_NT-6.0 | CYGWIN_NT-6.1 | CYGWIN_NT-6.1-WOW64 | CYGWIN_NT-10.0 ) platform="cygwin";;
MINGW64_NT-10.0 | MINGW64_NT-6.1 | MINGW32_NT-6.1 | MINGW32_NT-5.2 | MINGW32_NT-5.1 | MSYS_NT-6.1 ) platform="mingw";;
Darwin) platform="mac";;
SunOS) platform="sun";;
esac
fi
# If architecture is sun, prompt for compiler; otherwise use the GNU set.
if [ "$mode" = "interactive" ]; then
if [ "$platform" = "sun" ] || [ "$platform" = "linux" ]; then
compiler="prompt"
fi
fi
if [ "$compiler" != "prompt" ]; then
if [ "$use_intel" = "yes" ]; then
compiler="intel"
else
compiler="GNU"
fi
fi
if [ "$compiler" = "prompt" ] && [ "$mode" = "interactive" ]; then
A=none;
while [ $A != "1" ] &&
[ $A != "2" ] &&
[ $A != "3" ]
do
if [ $A != "none" ]; then
echo " "
echo "Please select a compiler set [2]."
fi
echo "Select a compiler set [2]:"
echo " (1) Sun 90 (cc and f90);"
echo " (2) GNU (gcc 4.X and gfortran);"
echo " (3) Intel (icc, icpc and ifort)."
read A
if [ "$A" = "" ]; then
A="2"
fi
done
case "$A" in
1) compiler=sunF90;;
2) compiler=GNU;;
3) compiler=intel;;
esac
else
echo " "
echo "The $compiler compiler set will be used."
fi
# Prompt for inclusion of H3K reports (in xml output)
# on supported platforms (presently linux, cygwin and mingw).
if [ "$mode" = "interactive" ]; then
if [ "$platform" = "linux" ] ||
[ "$platform" = "cygwin" ] ||
[ "$platform" = "mingw" ] ||
[ "$platform" = "mac" ] ||
[ "$platform" = "sun" ] ; then
if [ "${xml_libs_found}" = "no" ]; then
echo " "
echo "Error: libxml2 library not found in /usr/include"
echo "or /usr/local/include. Support for xml output will be"
echo "disabled but the rest of the installation will"
echo "proceed normally."
else
case "${xml_support}" in
yes) echo "xml support included.";;
no) echo "xml support not included.";;
esac
fi
else
echo " "
echo "xml output support not available on ${platform}"
echo "and is therefore disabled."
xml_support="no"
SQLite_support="no"
fi
else
if [ "$xml_support" = "prompt" ]; then
xml_support="no"
SQLite_support="no"
fi
fi
# FMI support.
if [ "$mode" = "interactive" ]; then
if [ "${FMI_libs_found}" = "no" ]; then
echo " "
echo "FMI library resources could not be located. Please"
echo "follow instructions in manual/FMI/Users.txt. FMI"
echo "will be disabled but the rest of the installation"
echo "will proceed normally."
echo
FMI_support="no"
elif [ "${FMI_libs_found}" = "yes" ]; then
if ! [ "$platform" = "linux" ] &&
! [ "$machine" = "x86_64" ] &&
! [ "$machine" = "i386" ] &&
! [ "$machine" = "i686" ]; then
echo " "
echo "FMI not supported on $platform $machine."
echo "Only advanced users should proceed with"
echo "FMI enabled."
echo
fi
if [ "$FMI_support" = "prompt" ]; then
B="none"
while [ "$B" != "y" ] && [ "$B" != "n" ] && [ "$B" != "Y" ] && [ "$B" != "N" ]
do
if [ "$B" != "none" ]; then
echo " "
echo "Please answer 'y' or 'n'."
fi
echo " "
echo "Include FMI support (y/n)? [n]"
read B
if [ "$B" = "" ]; then
case "${FMI_support}" in
yes) B="y";;
*) B="n";;
esac
fi
done
if [ "$B" = "y" ]; then
FMI_support="yes"
echo " "
echo "FMI enabled."
else
FMI_support="no"
echo " "
echo "FMI disabled."
fi
fi
elif [ "${FMI_libs_found}" = "assume" ]; then
echo
echo "FMI headers and library are assumed to be"
echo "within the compiler/ linker paths. No checks"
echo "will be made for these resources before"
echo "compiling with FMI support enabled."
fi
else
if [ "$FMI_support" = "prompt" ]; then
FMI_support="no"
fi
fi
# Graphics libraries
if [ "$mode" = "interactive" ]; then
case "${xLibs}" in
X11) echo " "
echo "Building with X11 interface.";;
GTK) echo " "
echo "Building with GTK interface.";;
noX) echo " "
echo "Building with text only interface.";;
esac
else
# Assume X11 is available on all systems except mingw.
if [ "$platform" = "mingw" ]; then
xLibs=noX
echo " "
echo "Text only applications will be compiled."
else
echo " "
echo "The $xLibs libraries will be used."
fi
fi
# Prepend grapics library to target list.
case $xLibs in
X11) targets=" libX11 $targets";;
GTK) targets=" libGTK $targets";;
noX) targets=" libnoX $targets";;
esac
# Level of model complexity supported.
small_prompt="1"
medium_prompt="2"
large_prompt="3"
default="$medium_prompt"
case "$complexity" in
"$small_prompt")
cp ${SRCdir}/include/building_small.h ${SRCdir}/include/building.h
;;
"$medium_prompt")
cp ${SRCdir}/include/building_medium.h ${SRCdir}/include/building.h
;;
"$large_prompt")
cp ${SRCdir}/include/building_large.h ${SRCdir}/include/building.h
;;
esac
# Debugging symbols required?
if [ "$mode" = "interactive" ]; then
case "${debugging}" in
yes) echo " "
echo "Building with debug symbols.";;
no) echo " "
echo "Building without debug symbols.";;
esac
# Installation of databases required?
B="none"
while [ "$B" != "y" ] && [ "$B" != "n" ] && [ "$B" != "Y" ] && [ "$B" != "N" ]
do
if [ "$B" != "none" ]; then
echo " "
echo "Please answer 'y' or 'n'."
fi
case "${install_dbs}" in
yes) echo " "
echo "Install databases (y/n)? [y]";;
*) echo " "
echo "Install databases (y/n)? [n]";;
esac
read B
if [ "$B" = "" ]; then
case "${install_dbs}" in
yes) B="y";;
*) B="n";;
esac
fi
done
if [ "$B" = "y" ] || [ "$B" = "Y" ]; then
install_dbs="yes"
else
install_dbs="no"
fi
# Install training models?
B="none"
while [ "$B" != "y" ] && [ "$B" != "n" ] && [ "$B" != "Y" ] && [ "$B" != "N" ]
do
if [ "$B" != "none" ]; then
echo ""
echo "Please answer 'y' or 'n'."
fi
case "${install_training}" in
yes) echo "Install training models (y/n)? [y]";;
*) echo "Install training models (y/n)? [n]";;
esac
read B
if [ "$B" = "" ]; then
case "${install_training}" in
yes) B="y";;
*) B="n";;
esac
fi
done
if [ "$B" = "y" ] || [ "$B" = "Y" ]; then
install_training="yes"
else
install_training="no"
fi
fi
if [ "$debugging" = "yes" ]; then
debug_flag="-g"
else
debug_flag=" "
fi
# Header files.
LOCAL_INCLUDES="-I../include -I../shocc -I/usr/local/include -I../cetc/h3kreports"
# Architecture types.
case $platform in
sun) MCTYPE=sun ;;
linux) MCTYPE=lin ;;
cygwin) MCTYPE=cygw;;
mac) MCTYPE=osx ;;
mingw) MCTYPE=mingw ;;
# Custom hosts follow:
nrn7) MCTYPE=sun;;
esac
# Location of X libraries.
case $xLibs in
GTK) XINSTALLDIR="`pkg-config gtk+-2.0 --cflags --libs`";;
X11) X11_found="no"
case $platform in
sun)
XDEFDIR="/usr/openwin"
if [ -d /usr/openwin/lib/X11 ]; then
X11_found="yes"
XINSTALLDIR="/usr/openwin"
fi
;;
*)
# linux/mac/cygwin/arm: search for the X11 libraries.
XDEFDIR="/usr/X11R6 or /usr"
# Try /usr/X11R6
case $machine in
x86_64)
case $platform in
mac) if [ -d /usr/X11R6/lib/X11 ] ; then
X11_found="yes"
XINSTALLDIR="/usr/X11R6"
else
if [ -d /opt/X11/lib/X11 ] ; then
X11_found="yes"
XINSTALLDIR="/opt/X11"
fi
fi;;
*) if [ -d /usr/X11R6/lib64/X11 ] ; then
X11_found="yes"
XINSTALLDIR="/usr/X11R6"
else
if [ -d /usr/lib64/X11 ] ; then
X11_found="yes"
XINSTALLDIR="/usr/lib64"
fi
fi;;
esac;;
sun4u)
if [ -d /usr/X11R6/lib/64 ] ; then
X11_found="yes"
XINSTALLDIR="/usr/X11R6"
fi;;
armv6l)
if [ -d /usr/lib/arm-linux-gnueabihf ] ; then
X11_found="yes"
XINSTALLDIR="/usr/lib/arm-linux-gnueabihf"
fi;;
armv7l)
if [ -d /usr/lib/X11 ] ; then
X11_found="yes"
XINSTALLDIR="/usr/lib/X11"
fi;;
aarch64)
if [ -d /usr/lib/X11 ] ; then
X11_found="yes"
XINSTALLDIR="/usr/lib/X11"
fi;;
arm64)
case $platform in
mac) if [ -d /usr/X11R6/lib/X11 ] ; then
X11_found="yes"
XINSTALLDIR="/usr/X11R6"
else
if [ -d /opt/X11/lib/X11 ] ; then
X11_found="yes"
XINSTALLDIR="/opt/X11"
fi
fi;;
*) if [ -d /usr/X11R6/lib64/X11 ] ; then
X11_found="yes"
XINSTALLDIR="/usr/X11R6"
else
if [ -d /usr/lib64/X11 ] ; then
X11_found="yes"
XINSTALLDIR="/usr/lib64"
fi
fi;;
esac;;
*)
if [ -d /usr/X11R6/lib/X11 ] ; then
X11_found="yes"
XINSTALLDIR="/usr/X11R6"
fi;;
esac
# Try /usr
if [ -d /usr/lib/X11 ] && [ "$X11_found" = "no" ]; then
X11_found="yes"
XINSTALLDIR="/usr"
fi
if [ -d /usr/lib64/X11 ] && [ "$X11_found" = "no" ]; then
X11_found="yes"
XINSTALLDIR="/usr/lib64"
fi
;;
esac
# If X11 not found, ask user for location.
if [ "$X11_found" = "no" ] && [ "$mode" = "interactive" ]; then
echo " "
echo "X11 libraries not found in ($XDEFDIR)."
try_agian="y"
while [ "$try_agian" == "y" ] || [ "$try_agian" == "Y" ]
do
echo "Search for the X11 libraries at"
echo "an alternative location?"
read try_again
if [ "$try_agian" = "" ]; then
try_again="y"
fi
if [ "$try_again" = "y" ] || [ "$try_agian" = "Y" ]; then
echo " Location of X11 installation?"
read XINSTALLDIR
if [ -d $XINSTALLDIR/lib/X11 ]; then
echo " X11 was found at $XINSTALLDIR."
X11_found="yes"
try_agian="no"
else
echo "X11 libraries not found in $XINSTALLDIR!"
fi
fi
done
fi
# If X11 not found, issue an error and quit.
if [ "$X11_found" = "no" ]; then
echo " "
echo "Error: X11 libraries not found ... exiting."
echo " "
exit
fi
# Check if the required include files are installed.
if [ -r $XINSTALLDIR/include/X11/X.h ]; then
X11INCLUDEDIR=$XINSTALLDIR/include
else
if [ -r /usr/include/X11/X.h ]; then
X11INCLUDEDIR=/usr/include
else
echo " "
echo "Error: the X11 libraries were found at $XINSTALLDIR but"
echo "the corresponding header files (e.g. X.h) could not be"
echo "located at $XINSTALLDIR/include/X11. Please check if"
echo "the X11 development package is installed (usually called"
echo "xfree86-devel, xorg-X11-devel or libX11-devel.)"
exit
fi
fi
;;
noX) XINSTALLDIR="";;
esac
# Assign compilers.
case $compiler in
sunF90) CC=cc; CPL=CC; FC=f90 ;;
GNU) case $gnu_version in
gcc4) CC=gcc; CPL=g++; FC=gfortran ;;
esac;;
intel) CC=icc; CPL=icpc; FC=ifort ;;
esac
if [ "$compiler_version" != "none" ]; then
CC="$CC$compiler_version"
CPL="$CPL$compiler_version"
FC="$FC$compiler_version"
fi
# Extended debugging.
ExtendedDebugFlags=""
if [ "$extendedDebugging" == "yes" ]; then
case $compiler in
sunF90) ExtendedDebugFlags="$ExtendedDebugFlags";;
GNU) case $gnu_version in
gcc4) ExtendedDebugFlags="$ExtendedDebugFlags -fbounds-check -Wunderflow -Wconversion -frange-check -ffpe-trap=zero,invalid,overflow,underflow" ;;
esac;;
intel) ExtendedDebugFlags="$ExtendedDebugFlags -debug all -C -fp-stack-check -traceback -inline-debug-info -fpe0 " ;;
esac
fi
# Assign wwlink variable.
case $compiler in
sunF90) WWLINK="shared_solaris" ;;
GNU) WWLINK="unshared" ;;
esac
# FFLAGS: Establish platform specific ifdef variables for inserted into
# Fortran compiler flags (for OSX 10.6 and x86_64 force -m64 otherwise -m32).
case $platform in
sun) case $machine in