-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·3863 lines (3429 loc) · 129 KB
/
configure
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/sh
# configure script for FlexibleSUSY
# Author: Alexander Voigt
PROGRAM_NAME=FlexibleSUSY
FLEXIBLESUSY_MAJOR=2
FLEXIBLESUSY_MINOR=6
FLEXIBLESUSY_PATCH=0
FLEXIBLESUSY_EXTRA=""
FLEXIBLESUSY_VERSION="${FLEXIBLESUSY_MAJOR}.${FLEXIBLESUSY_MINOR}.${FLEXIBLESUSY_PATCH}${FLEXIBLESUSY_EXTRA}"
GIT_COMMIT=$(git rev-parse HEAD 2> /dev/null || echo unknown)
GM2CALC_VERSION="unknown"
HIMALAYA_VERSION="unknown"
# directory of this script
BASEDIR=$(dirname $0)
# absolute path to this script
ABSBASEDIR=$(cd "$BASEDIR"; pwd | sed 's/ /\\\\ /g')
# config directory
CONFIGDIR="${BASEDIR}/config"
# current date
DATE=$(date 2>/dev/null || echo unknown)
# platform information
debmultiarch=""
# default library and include directories
default_lib_paths="$LD_LIBRARY_PATH:/usr/lib:/usr/local/lib"
default_inc_paths="$CPATH:$CPLUS_INCLUDE_PATH:/usr/include:/usr/local/include"
# configure log file
logfile="$BASEDIR/config.log"
statusfile="$BASEDIR/config.status"
sarahconfig="$BASEDIR/config.sarah"
feynartsconfig="$BASEDIR/config.feynarts"
formcalcconfig="$BASEDIR/config.formcalc"
mathconfig="$BASEDIR/config.math"
# whether we are in 32-bit or 64-bit environment
machine_word_size="unknown"
# operating system
operating_system="unknown"
# kernel version (uname -r)
kernel_version="unknown"
# target makefile
MAKEFILE=$BASEDIR/Makefile
MAKEFILE_TMPL=${CONFIGDIR}/Makefile.in
# target config script
FSCONFIG=$BASEDIR/flexiblesusy-config
FSCONFIG_TMPL=${CONFIGDIR}/flexiblesusy-config.in
# target sarah dependency generation script
SARAH_DEP_GEN=${CONFIGDIR}/list_sarah_model_files.sh
SARAH_DEP_GEN_TMPL=${CONFIGDIR}/list_sarah_model_files.sh.in
SARAH_MODEL_DIR=""
# target config header
CONFIGHDR=${CONFIGDIR}/config.h
CONFIGHDR_TMPL=${CONFIGDIR}/config.h.in
# target dox file with Doxygen \mainpage
DOC_MAINPAGE=$BASEDIR/doc/mainpage.dox
DOC_MAINPAGE_TMPL=$BASEDIR/doc/mainpage.dox.in
# target makefile file for the standalone example
STANDALONE_MAKEFILES="\
${BASEDIR}/examples/standalone-model/Makefile \
${BASEDIR}/examples/standalone-rge/Makefile"
STANDALONE_MAKEFILE_TMPL="${BASEDIR}/config/Makefile.standalone.in"
# target makefile file for the tower example
TOWER_MAKEFILES="
${BASEDIR}/examples/tower/Makefile"
TOWER_MAKEFILE_TMPL="${BASEDIR}/config/Makefile.tower.in"
# target makefile file for the customized betas example
CUSTOMBETAS_MAKEFILES="
${BASEDIR}/examples/customized-betas/Makefile"
CUSTOMBETAS_MAKEFILE_TMPL="${BASEDIR}/config/Makefile.customized-betas.in"
# options
deprecated_options=""
options=" \
enable_colors \
enable_compile \
enable_compiler_warnings \
enable_debug \
enable_fflite \
enable_gm2calc \
enable_himalaya \
enable_librarylink \
enable_looptools \
enable_mass_error_check \
enable_shared_libs \
enable_silent \
enable_sqlite \
enable_static \
enable_threads \
enable_tsil \
enable_verbose \
enable_feynarts \
enable_formcalc \
"
# BEGIN: NOT EXPORTED ##########################################
options="${options} \
enable_meta \
"
# END: NOT EXPORTED ##########################################
enable_compile="yes"
enable_compiler_warnings="no"
enable_colors="no"
enable_debug=""
enable_mass_error_check="no"
enable_fflite="no"
enable_gm2calc="automatic"
enable_himalaya="automatic"
enable_librarylink="automatic"
enable_looptools="no"
enable_collier="no"
enable_meta="no"
# BEGIN: NOT EXPORTED ##########################################
enable_meta="yes"
# END: NOT EXPORTED ##########################################
enable_silent="no"
enable_sqlite="automatic"
enable_shared_libs="no"
enable_static="no"
enable_threads="automatic"
enable_tsil="automatic"
enable_verbose="no"
enable_feynarts="automatic"
enable_formcalc="automatic"
# corresponding preprocessor define statements
DEFINE_ENABLE_COLORS="#undef ENABLE_COLORS"
DEFINE_ENABLE_DEBUG="#undef ENABLE_DEBUG"
DEFINE_ENABLE_CHECK_EIGENVALUE_ERROR="#undef CHECK_EIGENVALUE_ERROR"
DEFINE_ENABLE_FFLITE="#undef ENABLE_FFLITE"
DEFINE_ENABLE_GM2CALC="#undef ENABLE_GM2CALC"
DEFINE_ENABLE_HIMALAYA="#undef ENABLE_HIMALAYA"
DEFINE_ENABLE_LIBRARYLINK="#undef ENABLE_LIBRARYLINK"
DEFINE_ENABLE_LOOPTOOLS="#undef ENABLE_LOOPTOOLS"
DEFINE_ENABLE_COLLIER="#undef ENABLE_COLLIER"
DEFINE_ENABLE_ODEINT="#undef ENABLE_ODEINT"
DEFINE_ENABLE_RANDOM="#undef ENABLE_RANDOM"
DEFINE_ENABLE_SILENT="#undef ENABLE_SILENT"
DEFINE_ENABLE_SQLITE="#undef ENABLE_SQLITE"
DEFINE_ENABLE_THREADS="#define ENABLE_THREADS 1"
DEFINE_ENABLE_TSIL="#undef ENABLE_TSIL"
DEFINE_ENABLE_VERBOSE="#undef ENABLE_VERBOSE"
DEFINE_ENABLE_TWO_SCALE_SOLVER="#undef ENABLE_TWO_SCALE_SOLVER"
DEFINE_ENABLE_LATTICE_SOLVER="#undef ENABLE_LATTICE_SOLVER"
DEFINE_ENABLE_SEMI_ANALYTIC_SOLVER="#undef ENABLE_SEMI_ANALYTIC_SOLVER"
DEFINE_ENABLE_ADDONS=""
boost_lib_dir=""
boost_inc_dir=""
eigen_inc_dir=""
BOOSTFLAGS=""
gsl_config="gsl-config"
looptools_lib_dir=""
looptools_inc_dir=""
collier_lib_dir=""
collier_inc_dir=""
GSLFLAGS=""
CPPFLAGS=""
CXXFLAGS="-std=c++14 -O2 -fPIC"
FFLAGS="-O2 -fPIC"
FLIBS=""
FMOD=""
FSTD=''
FUTILIBS=''
BOOSTTESTLIBS=""
BOOSTTHREADLIBS=""
THREADLIBS=""
CXX="g++"
EIGENFLAGS=""
FC="gfortran"
GSLLIBS=""
INSTALL_DIR=""
MATH="math"
OPTIONAL_MODULES=""
pthread_lib_dir=""
STATIC_LIB_EXT=".a"
STATIC_LIB_CMD="ar cru"
STATIC_LDFLAGS="-static"
STATIC_LDLIBS="-lquadmath -ldl"
SHARED_LIB_EXT=".so"
SHARED_LIB_CMD="$CXX -shared -o"
SHARED_LDFLAGS=""
SHARED_LDLIBS=""
MODULE_LIBEXT="$STATIC_LIB_EXT"
MODULE_MAKE_LIB_CMD="$STATIC_LIB_CMD"
LIBLNK_LIBEXT="$SHARED_LIB_EXT"
LIBLNK_MAKE_LIB_CMD="$SHARED_LIB_CMD"
LOOPFUNCFLAGS=""
LOOPFUNCLIBS=""
COLLIERFLAGS=""
COLLIERLIBS=""
LDFLAGS="$SHARED_LDFLAGS"
LDLIBS="$SHARED_LDLIBS"
LLFLAGS=""
LLLIBS=""
himalaya_lib_dir=""
himalaya_inc_dir=""
sqlite_lib_dir=""
sqlite_inc_dir=""
tsil_lib_dir=""
tsil_inc_dir=""
# available RG solvers
SOLVERS="two_scale semi_analytic"
available_solvers="two_scale lattice semi_analytic"
# models that will be compiled
MODELS="all"
# BEGIN: NOT EXPORTED ##########################################
MODELS=""
# END: NOT EXPORTED ##########################################
# addons that will be compiled
ADDONS=""
#loop libraries that will be enabled additionally
LOOP_LIBRARIES=""
# C++ compiler type and version
cxx_compiler_type="unknown"
cxx_compiler_version="unknown"
# required C++ compiler versions
required_cxx_compiler_version="unknown"
required_gpp_compiler_version="5.0.0"
required_clang_compiler_version="3.8.1"
required_icpc_compiler_version="17.0.0"
# required boost version
required_boost_version="1.37.0"
# required Mathematica version
required_mathematica_version="7"
# required SARAH version
required_sarah_major="4"
required_sarah_minor="11"
required_sarah_patch="0"
required_sarah_version="${required_sarah_major}.${required_sarah_minor}.${required_sarah_patch}"
SARAH_VERSION="unknown"
SARAH_MAJOR="0"
SARAH_MINOR="0"
SARAH_PATCH="0"
# required FeynArts version
required_feynarts_version="3.9.0"
FEYNARTS_VERSION="unknown"
# required FormCalc version
required_formcalc_version="9.5.0"
FORMCALC_VERSION="unknown"
# Mathematica version (0 = unknown)
MATH_VERSION="0"
# Mathematica system ID
MATH_SYSTEMID=""
# Mathematica installation directory
MATH_INSTDIR=""
# string to eval when script terminates, normally or not
actions_at_exit=""
#_____________________________________________________________________
at_exit() {
local action
for action in "$@"; do
printf "%s\n" "$actions_at_exit" | grep -F -e "$action" > /dev/null ||
actions_at_exit="$actions_at_exit
$action"
done
}
#_____________________________________________________________________
do_actions_at_exit() {
logmsg "Executing clean-up actions:$actions_at_exit"
eval "$actions_at_exit"
}
#_____________________________________________________________________
write_configure_parameters() {
# This function writes all parameters [$*] to config.status
echo "$*" > "$statusfile"
}
#_____________________________________________________________________
message() {
# Write a simple message to std out (and to the log file). Use -n
# as first parameter to prevent a newline at the end of the
# message.
if test $# -lt 1 ; then
echo "message: Too few arguments"
return 1
fi
if test "x$1" = "x-n"; then
shift
printf "%s" "$*"
logmsg "-n" "$*"
else
echo "$*"
logmsg "$*"
fi
}
#_____________________________________________________________________
logmsg() {
# Write message to the log file. Use -n as first parameter to
# prevent a newline at the end of the message.
if test $# -lt 1 ; then
echo "logmsg: Too few arguments"
return 1
fi
if test "x$1" = "x-n"; then
shift
printf "%s" "$*" >> $logfile
else
echo "$*" >> $logfile
fi
}
#_____________________________________________________________________
log_package_information() {
logmsg "Package: ${PROGRAM_NAME}"
logmsg "Version: ${FLEXIBLESUSY_VERSION}"
logmsg "Date: ${DATE}"
logmsg "Git commit: ${GIT_COMMIT}"
}
#_____________________________________________________________________
guess_machine_word_size() {
local chip="$(uname -m | tr '[A-Z]' '[a-z]')"
exists_in_path getconf && chip="${chip}$(getconf LONG_BIT)"
case "$chip" in
*32|i[36]86)
machine_word_size="32"; return 0 ;;
*64) machine_word_size="64"; return 0 ;;
*) machine_word_size="unknown"
message "Warning: could not guess machine word size"
return 1 ;;
esac
}
#_____________________________________________________________________
contains() {
# Check if string $1 contains $2
if test $# -lt 2 ; then
echo "contains: Too few arguments"
return 1
fi
local string="$1"
local substring="$2"
for f in ${string}; do
test "x$f" = "x$substring" && return 0
done
return 1 # not found
}
#_____________________________________________________________________
contains_not() {
# Check if string $1 does not contain $2
if test $# -lt 2 ; then
echo "contains: Too few arguments"
return 1
fi
! contains "$1" "$2"
}
#_____________________________________________________________________
make_unique() {
# removes duplicate words from the string $1 (preserves order)
local str="$1"
local res=""
for s in ${str}; do
contains "${res}" "${s}" && continue
res="${res} ${s}"
done
echo "${res}" | sed -e 's/^ *//' -e 's/ *$//'
}
#_____________________________________________________________________
string_trim() {
echo "$1" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
}
#_____________________________________________________________________
check_library() {
# This function will try to locate a library [$1] in the directory
# given in $2 or in a default path [$3].
#
# The result of the search is stored in found_lib and found_dir,
# which should be immediately copied, since the variables value will
# be overwritten at next invocation of this function.
# Assert that we got enough arguments
if test $# -lt 3 ; then
echo "check_library: Too few arguments"
return 1
elif test $# -gt 3 ; then
echo "check_library: Too many arguments. Default path should be colon-separated."
return 1
fi
# Save arguments in local names
lib="$1"
libdirl="$2"
libdirs="$3"
# check if we got a specific argument as to where the library
# is to be found
if test ! "x$libdirl" = "x" ; then
libdirs=$libdirl
fi
# Write a message
checking_msg "$lib"
libs=""
for i in $lib ; do
for ext in .a .lib "" .so .sl .dylib .dll.a .tbd ; do
libs="$libs $i$ext"
done
done
found_dir=""
found_lib=""
if test "x$machine_word_size" = "x64"; then
IFS=":"
for p in $libdirs; do
unset IFS
libdir64=$(echo "$p" | grep lib | sed -e 's|lib$|lib64|g' -e 's|lib/|lib64/|g')
libdirs="$libdirs:$libdir64"
done
unset IFS
fi
if test "x$machine_word_size" = "x32"; then
IFS=":"
for p in $libdirs; do
unset IFS
libdir32=$(echo "$p" | grep lib | sed -e 's|lib$|lib32|g' -e 's|lib/|lib32/|g')
libdirs="$libdirs:$libdir32"
done
unset IFS
fi
# look first in the DEB_HOST_MULTIARCH directories
if test "x$debmultiarch" != "x" ; then
IFS=":"
for p in $libdirs; do
unset IFS
multiarch_libdir=$(echo "$p" | sed "s|lib$|lib/$debmultiarch|")
libdirs="$multiarch_libdir:$libdirs"
done
unset IFS
fi
IFS=":"
for p in $libdirs; do
unset IFS
for l in ${libs}; do
liblist=$(echo $p/$l) # expands wildcard
for n in ${liblist} ; do
if test -f $n ; then
found_dir=$(echo $p) # strip whitespace
found_lib=$(echo $l) # strip whitespace
break 3
fi
done
done
done
unset IFS
if test "x$found_dir" = "x" || test "x$found_lib" = "x" ; then
result "not found in $libdirs"
return 1
else
result "found in $found_dir"
fi
return 0
}
#_____________________________________________________________________
check_header() {
# This function will try to locate a header file [$1] in the
# directory given in $2 or in a default path [$3].
#
# The result of the search is stored in found_hdr and found_dir,
# which should be immediately copied, since the variables value
# will be overwritten at next invocation of this function.
# Assert that we got enough arguments
if test $# -lt 2 ; then
echo "check_header: Too few arguments"
return 1
elif test $# -gt 3 ; then
echo "check_header: Too many arguments. The default paths should be colon-separated."
return 1
fi
# Save arguments in local names
hdr="$1" ; shift
hdrdirl="$1"
hdrdirs="$*"
# check if we got a specific argument as to where the library
# is to be found
if test ! "x$hdrdirl" = "x" ; then
hdrdirs=$hdrdirl
fi
# Write a message
checking_msg "$hdr"
hdrs=""
for i in $hdr ; do
for ext in "" .h .hpp ; do
hdrs="$hdrs $i$ext"
done
done
found_dir=""
found_hdr=""
IFS=":"
for p in $hdrdirs; do
unset IFS
for h in ${hdrs}; do
hdrlist=$(echo $p/$h) # expands wildcard
for n in ${hdrlist} ; do
if test -f $n ; then
found_dir=$(echo $p) # strip whitespace
found_hdr=$(echo $hdr) # strip whitespace
break 3
fi
done
done
done
unset IFS
if test "x$found_dir" = "x" || test "x$found_hdr" = "x" ; then
result "not found in $hdrdirs"
return 1
else
result "found in $found_dir"
fi
return 0
}
#_____________________________________________________________________
checking_msg() {
# Write a simple "checking" message to std out.
if test $# -lt 1 ; then
echo "checking_msg: Too few arguments"
return 1
fi
printf "Checking for"
logmsg -n "Checking for"
while test $# -gt 1 ; do
printf " %s," "$1"
logmsg -n " $1,"
shift
if test $# -eq 1 ; then
printf " or"
logmsg -n " or"
fi
done
printf " %s ... " "$1"
logmsg -n " $1 ... "
}
#_____________________________________________________________________
result() {
echo "$*"
logmsg ""
logmsg " Result: $*"
}
#_____________________________________________________________________
check_symbol() {
# This function will try to locate a symbol [$1] in a specific
# library [$2] and in a given directory [$3].
# The result of the check is stored in found_symbol, 1 if true,
# 0 otherwise, which should be immediately copied, since the variable
# will be overwritten at next invocation of this function.
local symbol
local symbollib
local symboldir
# Assert that we got enough arguments
if test $# -ne 3 ; then
echo "check_symbol: not 3 arguments"
found_symbol=0
return 1
fi
# Save arguments in logical names
symbol=$1 ; shift
symbollib=$1 ; shift
symboldir=$1
if test "x$symbollib" = "x" ; then
found_symbol=0
return 1
fi
symbollib=$(echo $symbollib | sed -e 's/^-l/lib/')
if test ! "x$symboldir" = "x" ; then
symboldir=$(echo $symboldir | sed -e 's/^-L//')
fi
# Check if we got a specific argument as to where the library
# is to be found
symbolfile=$symbollib
exts=".so .lib .dylib"
if test ! "x$shared" = "xno" ; then
exts="$exts .a"
else
exts=".a $exts"
fi
usrlib="/usr/lib"
if test "x$machine_word_size" = "x32" ; then
usrlib="/usr/lib32 $usrlib"
fi
if test "x$machine_word_size" = "x64" ; then
usrlib="/usr/lib64 $usrlib"
fi
for d in "$symboldir" $usrlib ; do
logmsg " Checking in $d"
if test ! -r $d/$symbollib ; then
logmsg " $d/$symbollib not readable"
for i in $exts ; do
logmsg " Checking extension $i with $d/$symbollib"
if test -r $d/$symbollib$i ; then
logmsg " $d/$symbollib$i readable"
symbolfile=$d/$symbollib$i
break 2
fi
done
else
logmsg " $d/$symbollib readable"
symbolfile=$d/$symbollib
break
fi
done
if test "x$symbolfile" = "x" || test ! -r $symbolfile ; then
found_symbol=0
logmsg " Symbol not found"
return 1
fi
checking_msg "$symbol in $symbolfile"
nm $symbolfile 2>&1 | grep $symbol > /dev/null 2>&1 ||
nm -D $symbolfile 2>&1 | grep $symbol > /dev/null 2>&1
if test $? -eq 0 ; then
found_symbol=1
logmsg -n "symbol found"
else
nm $symbolfile 2>&1 | grep "no symbols" > /dev/null 2>&1
# if test $? -eq 0 ; then
# logmsg " $symbolfile is stripped, trying to link"
# # stripped library - only safe test is to link against the library
# check_link $symbolfile "" $symbol
# found_symbol=$link_result
# else
found_symbol=0
# fi
fi
if test $found_symbol -eq 1 ; then
result "ok"
return 0
else
result "no"
return 1
fi
}
#_____________________________________________________________________
split_version() {
local version="$1"
local major_var="$2"
local minor_var="$3"
local patch_var="$4"
set -- $(printf "%s" "$version" |
sed 's/^\([[:digit:].]*\).*$/\1/' | tr . ' ')
eval "$major_var=\"${1:-0}\""
eval "$minor_var=\"${2:-0}\""
eval "$patch_var=\"${3:-0}\""
}
#_____________________________________________________________________
major_minor_patch_at_least() {
local major=$1
local minor=$2
local patch=$3
local min_major=$4
local min_minor=$5
local min_patch=$6
if [ $major -gt $min_major ]; then return 0
elif [ $major -lt $min_major ]; then return 1
elif [ $minor -gt $min_minor ]; then return 0
elif [ $minor -lt $min_minor ]; then return 1
elif [ $patch -ge $min_patch ]; then return 0
else return 1
fi
}
#_____________________________________________________________________
version_at_least() {
local version="$1"
local min_version="$2"
local major minor patch
split_version "$version" major minor patch
local m_major m_minor m_patch
split_version "$min_version" m_major m_minor m_patch
major_minor_patch_at_least $major $minor $patch $m_major $m_minor $m_patch
}
#_____________________________________________________________________
try_compile_cpp_program() {
# This function compiles a C++ testprogram with the header
# inclusion given in [$1] and a statement given in [$2].
if test $# -ne 2 ; then
echo "try_compile_cpp_program: Two arguments required!"
exit 1
fi
local _header="$1"
local _statement="$2"
logmsg ""
logmsg "==================================="
logmsg "Trying to compile test program with"
logmsg " Header: ${_header}"
logmsg " Statement: ${_statement}"
local _suppress_separator=true
try_compile_run_cpp_program "${_header}
int main() {
${_statement};
return 0;
}"
}
#_____________________________________________________________________
try_compile_run_cpp_program() {
# This function compiles a C++ source code given in [$1]
# using the compiler given in [$2] or $CXX if $2 is unset
# with compiler flags given in [$3] or $CXXFLAGS if $3 is unset.
# It subsequently executes the resulting executable whose
# output through stdout and stderr is stored in cpp_output
# and whose exit code is stored in cpp_exit.
if [ $# -lt 1 -o $# -gt 3 ]; then
echo "try_compile_run_cpp_program: 1, 2, or 3 arguments required!"
exit 1
fi
local cxx="$2"
if [ -z "$cxx" ]; then
if test "x${CXX}" = "x"; then
echo "try_compile_run_cpp_program: CXX is not set!"
exit 1
fi
cxx="$CXX"
fi
local cxxflags="$3"
[ -z "$cxxflags" ] && cxxflags="$CXXFLAGS"
local source_code="$1"
local _src="${BASEDIR}/conftest.cpp"
local _exe="${BASEDIR}/conftest.x"
local _log="${BASEDIR}/conftest.log"
at_exit "rm -f \"${_exe}\" \"${_src}\" \"${_log}\""
logmsg ""
[ "$_suppress_separator" = true ] ||
logmsg "==================================="
logmsg "Trying to compile test program"
printf "%s\n" "$source_code" > ${_src}
# compile the source
${cxx} -o ${_exe} ${cxxflags} ${_src} > ${_log} 2>&1 || {
logmsg " Status: compilation failed!"
logmsg ""
logmsg "The test program was:"
logmsg "---------------------"
printf "%s\n" "$source_code" >> $logfile
logmsg "---------------------"
logmsg "Compiler: ${cxx}"
logmsg "Compiler flags: ${cxxflags}"
logmsg "Compilation command:"
echo " ${cxx} -o ${_exe} ${cxxflags} ${_src} > ${_log} 2>&1" >> $logfile
logmsg "Compiler error message:"
cat ${_log} >> $logfile
logmsg "==================================="
return 1
}
logmsg " Status: compilation successful."
# run the executable
logmsg "Running executable: $_exe"
cpp_output=$(${_exe} 2>&1)
cpp_exit="$?"
logmsg "The executable returned exit code: $cpp_exit"
if [ -z "$cpp_output" ]; then
logmsg "The executable produced no output."
else
logmsg "The executable produced output:"
printf "%s\n" "${cpp_output}" >> $logfile
fi
logmsg "==================================="
return 0
}
#_____________________________________________________________________
use_solver() {
# This function tests if a certain solver [$1] is used.
# Assert that we got enough arguments
if test $# -ne 1 ; then
echo "use_solver: Exactly one argument required"
return 1
fi
# check if the argument is in the list of used solvers
contains "$SOLVERS" "$1"
}
#_____________________________________________________________________
exists_in_path () {
# This function will try to locate an executable [$1] in $PATH.
#
# The result of the search is stored in cmd, which should be
# immediately copied, since the variables value will be
# overwritten at next invocation of this function.
# Assert that we got enough arguments
if test $# -ne 1 ; then
echo "exists_in_path: Exactly one argument required"
return 1
fi
cmd=$(command -v -- "$1")
case "$cmd" in
/*) return 0 ;;
alias\ *) return 1 ;; # alias
*) return 1 ;; # built-in or function
esac
}
#_____________________________________________________________________
is_empty_dir() {
if test $# -ne 1 ; then
echo "is_empty_dir: Exactly one argument required"
return 1
fi
find "$1" -maxdepth 0 -empty | read v
}
#_____________________________________________________________________
is_posix_platform() {
case "$operating_system" in
*BSD*) return 0 ;;
Darwin) return 0 ;;
DragonFly) return 0 ;;
GNU*) return 0 ;;
Linux) return 0 ;;
esac
return 1
}
#_____________________________________________________________________
check_install() {
if test -z "${INSTALL_DIR}"; then
return 0
fi
checking_msg "availability of install"
if exists_in_path "install"; then
result "ok"
else
result "no ok"
message "Error: The installation program \`install' needs to be installed."
message " \`install' is part of the GNU coreutils and can be downloaded from"
message " https://www.gnu.org/software/coreutils/"
exit 1
fi
}
#_____________________________________________________________________
check_install_dir() {
if test -z "${INSTALL_DIR}"; then
return 0
fi
checking_msg "source code installation directory"
# check if $INSTALL_DIR exists
if test -d "${INSTALL_DIR}"; then
# check if $INSTALL_DIR is empty
if is_empty_dir "${INSTALL_DIR}"; then
result "ok"
else
result "ok"
message "Warning: Source code installation directory is non-empty."
message " Existing files might be overwritten!"
fi
else
result "ok"
logmsg "Source code installation directory does not exist."
fi
# escape spaces
INSTALL_DIR=$(echo "${INSTALL_DIR}" | sed 's/ /\\\\ /g')
logmsg "Source code installation directory: ${INSTALL_DIR}"
}
#_____________________________________________________________________
check_solvers() {
if test -z "${SOLVERS}"; then
logmsg "No RGE solvers specified"
return 0
fi
checking_msg "RGE solvers"
local algs="$(echo $SOLVERS | tr ',' ' ')"
SOLVERS=""
for a in ${algs}; do
case "$a" in
all)
SOLVERS="$available_solvers"; break ;;
two_scale|lattice|semi_analytic)
SOLVERS="$SOLVERS $a"
continue ;;
*)
message "Error: unknown solver: $a";
message "Available solvers: $available_solvers";
exit 1 ;;
esac
done
# strip whitespace
SOLVERS="$(echo ${SOLVERS} | sed -e 's/^ *//' -e 's/ *$//')"
result "ok (${SOLVERS})"
logmsg " Solvers: ${SOLVERS}"
}
#_____________________________________________________________________
check_models() {
if test -z "${MODELS}" -o ! -d "$BASEDIR"/models ; then
logmsg "No models specified"
MODELS=""
return 0
fi
checking_msg "models"
local models="$(echo $MODELS | tr ',' ' ')"
MODELS=""
for a in ${models}; do
case "$a" in
all)
MODELS="${MODELS} $(find "$BASEDIR"/models/* -maxdepth 0 -type d -print0 | tr '\0' ' ' | sed -e 's|^\./||' -e 's| \./| |g' -e 's| *$||g')"