-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathinstaller
executable file
·1450 lines (1284 loc) · 43.7 KB
/
installer
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
#! /usr/bin/env bash
# __START_OF_LICENSE__
#
# Copyright (c) 2017, 2018 Michael D. Adams
# All rights reserved.
#
# This file is part of the SDE software.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3,
# or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; see the file LICENSE. If not,
# see <http://www.gnu.org/licenses/>.
#
# __END_OF_LICENSE__
debug_level="${SDE_INSTALLER_DEBUG_LEVEL:-0}"
if [ "$debug_level" -ge 1 ]; then
set -xv
fi
function join_by
{
local d=${1-} f=${2-}
if shift 2; then
printf %s "$f" "${@/#/$d}"
fi
}
################################################################################
# Specify the versions of various software packages to be installed.
################################################################################
# CMake: https://cmake.org/download
# CMake: https://gitlab.kitware.com/cmake/cmake
cmake_version=3.30.5
# Ninja: https://github.com/ninja-build/ninja
# Ninja Releases: https://github.com/ninja-build/ninja/releases
ninja_version=v1.12.1
# GCC: https://www.gnu.org/software/gcc
# GCC Releases: https://ftp.gnu.org/gnu/gcc
# https://gcc.gnu.org/git/?p=gcc.git;a=shortlog;h=refs/heads/master
# https://gcc.gnu.org/pub/gcc/snapshots
# web:$VERSION
# git:$COMMIT
gcc_qversion=web:14.2.0
alt_gcc_qversion=git:41179a3276807c6bb6d30f9bafb6b9da31320e48
# GCC Go
gccgo_qversion="$gcc_qversion"
#gccgo_qversion=web:11.2.0
# LLVM: http://releases.llvm.org/download.html
# LLVM Releases: https://github.com/llvm/llvm-project/releases
# web:$VERSION
# git:llvmorg-$VERSION
# git:$COMMIT
clang_qversion=web:19.1.4
alt_clang_qversion=git:2d90af59084d842a343f9acf6ae7c1e61991873c
# Musl: https://www.musl-libc.org/download.html
# Musl Releases: https://musl.libc.org/releases.html
musl_version=1.2.5
# JasPer: https://github.com/jasper-software/jasper
# JasPer Releases: https://github.com/jasper-software/jasper/releases
jasper_version=version-4.2.4
# GDB: https://www.gnu.org/software/gdb/download/
gdb_version=15.2
# SPL: http://www.ece.uvic.ca/~frodo/SPL/#download
# SPL: https://github.com/mdadams/SPL.git
#spl_version=version-2.0.8
spl_version=b222bdc856ac38d04ae8857218e5a0cbdaaf2121
# Ndiff: ???
ndiff_version=2.00
# TeX Live: https://www.tug.org/texlive/acquire.html
texlive_version=2024
# Boost: https://www.boost.org/users/download
# Note: Do not upgrade Boost until CMake catches up; otherwise build problems
# will likely result.
boost_version=1.86.0
# CGAL: https://github.com/CGAL/cgal
# CGAL Releases: https://github.com/CGAL/cgal/releases
cgal_version=6.0
# Aristotle: https://github.com/mdadams/aristotle
# Aristotle Releases: https://github.com/mdadams/aristotle/tags
aristotle_version=v3.0.43
# YCM: https://github.com/Valloric/YouCompleteMe
# YCM Commits: https://github.com/ycm-core/YouCompleteMe/commits/master
ycm_version=0b158e059e15fbe92b44222df2439144272a8782
# Vim: https://www.vim.org/download.php
# Vim Release Tags: https://github.com/vim/vim/tags
vim_qversion=git:v9.1.0771
# GSL: https://github.com/Microsoft/GSL/releases
gsl_version=v4.0.0
# Catch2: https://github.com/catchorg/Catch2
# Catch2 Releases: https://github.com/catchorg/Catch2/releases
catch_version=v2.13.10
alt_catch_version=v3.7.1
# Lcov: https://github.com/linux-test-project/lcov
# Lcov Releases: https://github.com/linux-test-project/lcov/releases
#lcov_version=v2.1 # Note: This has problems with missing dependencies.
lcov_version=v2.2
# Vim LSP: https://github.com/prabirshrestha/vim-lsp.git
# Vim LSP Commits: https://github.com/prabirshrestha/vim-lsp/commits/master
vimlsp_version=04428c920002ac7cfacbecacb070a8af57b455d0
# Vim Async: https://github.com/prabirshrestha/async.vim.git
# Vim Async Commits: https://github.com/prabirshrestha/async.vim/commits/master
vimlsp_async_version=2082d13bb195f3203d41a308b89417426a7deca1
# Vim Asyncomplete: https://github.com/prabirshrestha/asyncomplete.vim.git
# Vim Asyncomplete commits: https://github.com/prabirshrestha/asyncomplete.vim/commits/master
vimlsp_ac_version=016590d2ca73cefe45712430e319a0ef004e2215
# Vim Asyncomplete LSP: https://github.com/prabirshrestha/asyncomplete-lsp.vim.git
# Vim Asyncomplete LSP commits: https://github.com/prabirshrestha/asyncomplete-lsp.vim/commits/master
vimlsp_aclsp_version=cc5247bc268fb2c79d8b127bd772514554efb3ee
# Hub: https://github.com/github/hub
# Hub Releases: https://github.com/github/hub/releases
hub_version=2.14.2
# GitHub CLI: https://github.com/cli/cli
# GitHub CLI Releases: https://github.com/cli/cli/releases
# https://github.com/cli/cli/blob/trunk/docs/source.md
# 2.58.0 version requires go 1.22.5
gh_version=2.45.0 # 2.45.0+ (to at least 2.58.0) have build failures
#gh_version=2.14.3 # works with go 1.16.15
# GHI: https://github.com/stephencelis/ghi
# GHI Releases: https://github.com/stephencelis/ghi/releases
#ghi_version=1.2.0
ghi_version=
# Fmtlib: https://github.com/fmtlib/fmt.git
# Fmtlib Releases: https://github.com/fmtlib/fmt/releases
#fmtlib_version=9.1.0
fmtlib_version=
# range: https://github.com/ericniebler/range-v3.git
#range_version=0.10.0
range_version=
# cmcstl2: https://github.com/CaseyCarter/cmcstl2.git
#cmcstl2_version=684a96d527e4dc733897255c0177b784dc280980
cmcstl2_version=
################################################################################
#
################################################################################
apply_override()
{
declare -n value="$1"
#declare -n default="$2"
local default="$2"
if [ -n "${!default+x}" ]; then
echo "WARNING: OVERRIDING VALUE OF $1"
value="${!default}"
fi
}
apply_override cmake_version SDE_INSTALL_CMAKE_VERSION
apply_override ninja_version SDE_INSTALL_NINJA_VERSION
apply_override gcc_qversion SDE_INSTALL_GCC_QVERSION
apply_override alt_gcc_qversion SDE_INSTALL_ALT_GCC_QVERSION
apply_override gccgo_qversion SDE_INSTALL_GCCGO_QVERSION
apply_override clang_qversion SDE_INSTALL_CLANG_QVERSION
apply_override alt_clang_qversion SDE_INSTALL_ALT_CLANG_QVERSION
apply_override musl_version SDE_INSTALL_MUSL_VERSION
apply_override jasper_version SDE_INSTALL_JASPER_VERSION
apply_override gdb_version SDE_INSTALL_GDB_VERSION
apply_override spl_version SDE_INSTALL_SPL_VERSION
apply_override ndiff_version SDE_INSTALL_NDIFF_VERSION
apply_override texlive_version SDE_INSTALL_TEXLIVE_VERSION
apply_override boost_version SDE_INSTALL_BOOST_VERSION
apply_override cgal_version SDE_INSTALL_CGAL_VERSION
apply_override aristotle_version SDE_INSTALL_ARISTOTLE_VERSION
apply_override ycm_version SDE_INSTALL_YCM_VERSION
apply_override vim_qversion SDE_INSTALL_VIM_QVERSION
apply_override gsl_version SDE_INSTALL_GSL_VERSION
apply_override catch_version SDE_INSTALL_CATCH_VERSION
apply_override alt_catch_version SDE_INSTALL_ALT_CATCH_VERSION
apply_override lcov_version SDE_INSTALL_LCOV_VERSION
apply_override vimlsp_version SDE_INSTALL_VIMLSP_VERSION
apply_override vimlsp_async_version SDE_INSTALL_VIMLSP_ASYNC_VERSION
apply_override vimlsp_ac_version SDE_INSTALL_VIMLSP_AC_VERSION
apply_override vimlsp_aclsp_version SDE_INSTALL_VIMLSP_ACLSP_VERSION
apply_override hub_version SDE_INSTALL_HUB_VERSION
apply_override gh_version SDE_INSTALL_GH_VERSION
apply_override ghi_version SDE_INSTALL_GHI_VERSION
apply_override fmtlib_version SDE_INSTALL_FMTLIB_VERSION
apply_override range_version SDE_INSTALL_RANGE_VERSION
apply_override cmcstl2_version SDE_INSTALL_CMCSTL2_VERSION
################################################################################
# Utility functions.
################################################################################
panic()
{
echo "FATAL ERROR: $@" 1>&2
exit 1
}
eprint()
{
echo "$@" 1>&2
}
get_clang_version()
{
clang_program=$(type -P clang) || return 1
local buffer=$("$clang_program" --version) || return 1
awk '(NR==1) {print $3;}' <<< "$buffer" || return 1
}
get_version_info()
{
if [ $# -ne 2 ]; then
return 1
fi
local version="$1"
local key="$2"
case "$key" in
major)
field=1;;
minor)
field=2;;
micro)
field=3;;
*)
return 1;;
esac
awk -v i="$field" -v FS='.' '(NR==1) {print $i;}' <<< "$version" || \
return 1
}
qversion_get()
{
if [ "$#" -ne 2 ]; then
return 1
fi
local key="$1"
local qversion="$2"
local value=
case "$key" in
method)
if [[ "$qversion" =~ ^.*:.*$ ]]; then
value="${qversion%%:*}"
else
value=
fi
;;
version)
value="${qversion#*:}";;
*)
return 1;;
esac
echo "$value"
}
usage()
{
echo "BAD USAGE: $@" 1>&2
cat <<- EOF
usage: $0 [options]
options:
-d sde_top_dir
Set the top-level directory to top_dir.
-e default_environment
Set the default environment to default_environment.
-f
Allow the use of an existing directory.
examples:
./installer -d /usr/local/sde -e default
EOF
exit 2
}
################################################################################
#
################################################################################
cmd_dir=$(dirname $0) || panic "cannot get command directory"
bin_dir="$cmd_dir/bin"
sde_cmd="$bin_dir/sde"
sde_relpath="$bin_dir/sde_relpath"
sde_install_cmake="$bin_dir/sde_install_cmake"
sde_install_ninja="$bin_dir/sde_install_ninja"
sde_install_gcc="$bin_dir/sde_install_gcc"
sde_install_clang="$bin_dir/sde_install_clang"
sde_install_boost="$bin_dir/sde_install_boost"
sde_install_texlive="$bin_dir/sde_install_texlive"
sde_download_texlive_iso="$bin_dir/sde_download_texlive_iso"
sde_install_texlive_iso="$bin_dir/sde_install_texlive_iso"
sde_install_jasper="$bin_dir/sde_install_jasper"
sde_install_gdb="$bin_dir/sde_install_gdb"
sde_install_spl="$bin_dir/sde_install_spl"
sde_install_ndiff="$bin_dir/sde_install_ndiff"
sde_install_aristotle="$bin_dir/sde_install_aristotle"
sde_install_ycm="$bin_dir/sde_install_ycm"
sde_install_vim="$bin_dir/sde_install_vim"
sde_install_gsl="$bin_dir/sde_install_gsl"
sde_install_catch="$bin_dir/sde_install_catch"
sde_install_lcov="$bin_dir/sde_install_lcov"
sde_install_vimlsp="$bin_dir/sde_install_vimlsp"
sde_install_cgal="$bin_dir/sde_install_cgal"
sde_install_hub="$bin_dir/sde_install_hub"
sde_install_gh="$bin_dir/sde_install_gh"
sde_install_ghi="$bin_dir/sde_install_ghi"
sde_install_musl="$bin_dir/sde_install_musl"
sde_install_fmtlib="$bin_dir/sde_install_fmtlib"
sde_install_range="$bin_dir/sde_install_range"
sde_install_cmcstl2="$bin_dir/sde_install_cmcstl2"
sde_make_cmake_toolchain_file="$bin_dir/sde_make_cmake_toolchain_file"
sde_toolchain_template="$bin_dir/compiler_toolchain.cmake"
################################################################################
# Process command line
################################################################################
default_environment=
force=0
sde_top_dir=""
clean=0
while getopts d:fe:c opt; do
case "$opt" in
d)
sde_top_dir="$OPTARG";;
e)
default_environment="$OPTARG";;
c)
clean=1;;
f)
force=1;;
\?)
usage
break;;
esac
done
shift $((OPTIND - 1))
if [ -z "$sde_top_dir" ]; then
usage "no top directory specified"
fi
if [ "$force" -eq 0 -a -d "$sde_top_dir" ]; then
panic "top directory already exists $sde_top_dir"
fi
sde_shell="$sde_top_dir/bin/sde_shell"
################################################################################
# START OF INSTALLATION
################################################################################
date_stamp=$(date "+%Y%m%d") || panic "cannot get date"
cat <<- EOF
============================================================
Starting SDE Installation
Time: $(date +"%Y-%m-%d %H:%M:%S")
============================================================
EOF
sde_toolchain_dir="$sde_top_dir/toolchains"
#boot_dir="$sde_top_dir/bootstrap"
packages_dir="$sde_top_dir/packages"
ycm_extras_dir="$packages_dir/ycm_extras"
# Set the user file-creation mask to allow read and execute permissions
# for the group and others.
# This will help to increase the likelihood that the installed software
# will be accessible by all users.
umask 022
################################################################################
################################################################################
################################################################################
################################################################################
alt_gcc_install="${SDE_ALT_GCC_INSTALL:-0}"
alt_clang_install="${SDE_ALT_CLANG_INSTALL:-0}"
enable_texlive_install="${SDE_TEXLIVE_INSTALL:-1}"
generic_sdebase_dir="$packages_dir/sdebase"
sdebase_dir="$packages_dir/sdebase-default"
if [ -n "$cmake_version" ]; then
cmake_dir="$packages_dir/cmake-$cmake_version"
else
cmake_dir=
fi
if [ -n "$ninja_dir" ]; then
ninja_dir="$packages_dir/ninja-$ninja_version"
else
ninja_dir=
fi
if [ -n "$gcc_qversion" ]; then
gcc_method=$(qversion_get method "$gcc_qversion") || \
panic "cannot get method"
gcc_version=$(qversion_get version "$gcc_qversion") || \
panic "cannot get version"
gcc_dir="$packages_dir/gcc-$gcc_version"
else
gcc_dir=
fi
if [ -n "$clang_qversion" ]; then
clang_method=$(qversion_get method "$clang_qversion") || \
panic "cannot get method"
clang_version=$(qversion_get version "$clang_qversion") || \
panic "cannot get version"
clang_dir="$packages_dir/clang-$clang_version"
else
clang_dir=
fi
if [ -n "$boost_version" ]; then
boost_dir="$packages_dir/boost-$boost_version"
fi
if [ -n "$texlive_version" ]; then
texlive_dir="$packages_dir/texlive-$texlive_version"
texlive_iso_dir="$packages_dir/texlive_iso-$texlive_version"
else
texlive_dir=
texlive_iso_dir=
fi
if [ -n "$jasper_version" ]; then
jasper_dir="$packages_dir/jasper-$jasper_version"
else
jasper_dir=
fi
if [ -n "$gdb_version" ]; then
gdb_dir="$packages_dir/gdb-$gdb_version"
fi
if [ -n "$spl_version" ]; then
spl_dir="$packages_dir/SPL-$spl_version"
else
spl_dir=
fi
if [ -n "$ndiff_version" ]; then
ndiff_dir="$packages_dir/ndiff-$ndiff_version"
else
ndiff_dir=
fi
if [ -n "$aristotle_version" ]; then
aristotle_dir="$packages_dir/aristotle-$aristotle_version"
else
aristotle_dir=
fi
if [ -n "$ycm_version" ]; then
ycm_dir="$packages_dir/ycm-$ycm_version"
else
ycm_dir=
fi
if [ -n "$vim_qversion" ]; then
vim_method=$(qversion_get method "$vim_qversion") || \
panic "cannot get method"
vim_version=$(qversion_get version "$vim_qversion") || \
panic "cannot get version"
vim_dir="$packages_dir/vim-$vim_version"
else
vim_dir=
fi
if [ -n "$gsl_version" ]; then
gsl_dir="$packages_dir/gsl-$gsl_version"
else
gsl_dir=
fi
if [ -n "$catch_version" ]; then
catch_dir="$packages_dir/catch-$catch_version"
else
catch_dir=
fi
if [ -n "$alt_catch_version" ]; then
alt_catch_dir="$packages_dir/catch-$alt_catch_version"
else
alt_catch_dir=
fi
if [ -n "$lcov_version" ]; then
lcov_dir="$packages_dir/lcov-$lcov_version"
else
lcov_dir=
fi
if [ -n "$vimlsp_version" ]; then
vimlsp_dir="$packages_dir/vimlsp-$vimlsp_version"
else
vimlsp_dir=
fi
if [ -n "$cgal_version" ]; then
cgal_dir="$packages_dir/CGAL-$cgal_version"
else
cgal_dir=
fi
if [ -n "$hub_version" ]; then
hub_dir="$packages_dir/hub-$hub_version"
else
hub_dir=
fi
if [ -n "$gh_version" ]; then
gh_dir="$packages_dir/gh-$gh_version"
else
gh_dir=
fi
if [ -n "$ghi_version" ]; then
ghi_dir="$packages_dir/ghi-$ghi_version"
else
ghi_dir=
fi
if [ -n "$musl_version" ]; then
musl_dir="$packages_dir/musl-$musl_version"
else
musl_dir=
fi
if [ -n "$fmtlib_version" ]; then
fmtlib_dir="$packages_dir/fmtlib-$fmtlib_version"
else
fmtlib_dir=
fi
if [ -n "$range_version" ]; then
range_dir="$packages_dir/range-$range_version"
else
range_dir=
fi
if [ -n "$cmcstl2_version" ]; then
cmcstl2_dir="$packages_dir/cmcstl2-$cmcstl2_version"
else
cmcstl2_dir=
fi
if [ -n "$gccgo_qversion" ]; then
gccgo_method=$(qversion_get method "$gccgo_qversion") || \
panic "cannot get method"
gccgo_version=$(qversion_get version "$gccgo_qversion") || \
panic "cannot get version"
gccgo_dir="$packages_dir/gccgo-$gccgo_version"
else
gccgo_dir=
fi
gcc_install_options=()
# Note: The following install-gcc options should be the last ones added
# so that they can override others.
if [ -n "$SDE_GCC_INSTALL_OPTIONS" ]; then
gcc_install_options+=($SDE_GCC_INSTALL_OPTIONS)
fi
alt_gcc_install_options=("${gcc_install_options[@]}")
if [ -n "$SDE_ALT_GCC_INSTALL_OPTIONS" ]; then
alt_gcc_install_options+=($SDE_ALT_GCC_INSTALL_OPTIONS)
fi
clang_install_options=()
clang_install_options+=(--default-projects-runtimes)
clang_install_options+=(--default-targets)
clang_install_options+=(--enable-shared-libllvm)
clang_install_options+=(--no-enable-link-shared-libllvm)
clang_install_options+=(--no-enable-link-shared-clangcpp)
clang_install_options+=(--strip)
clang_install_options+=(--no-default-pie)
clang_install_options+=(--no-enable-test-suite)
#clang_install_options+=(--old-host-toolchain)
# Note: Due to libgcc_s shared library, there is no point to
# static linking of libstdc++.
#clang_install_options+=(--enable-static-libstdcxx)
# Note: The following install-clang options should be the last ones added
# so that they can override others.
if [ -n "$SDE_CLANG_INSTALL_OPTIONS" ]; then
clang_install_options+=($SDE_CLANG_INSTALL_OPTIONS)
fi
alt_clang_install_options=("${clang_install_options[@]}")
if [ -n "$SDE_ALT_CLANG_INSTALL_OPTIONS" ]; then
alt_clang_install_options+=($SDE_ALT_CLANG_INSTALL_OPTIONS)
fi
if [ "${SDE_VIM_INSTALL:-1}" -eq 0 ]; then
vim_dir=
fi
if [ "${SDE_CGAL_INSTALL:-0}" -eq 0 ]; then
cgal_dir=
fi
if [ "${SDE_HUB_INSTALL:-0}" -eq 0 ]; then
hub_dir=
fi
if [ "${SDE_MUSL_INSTALL:-1}" -eq 0 ]; then
musl_dir=
fi
if [ "${SDE_SPL_INSTALL:-1}" -eq 0 ]; then
spl_dir=
fi
if [ "${SDE_GHI_INSTALL:-0}" -eq 0 ]; then
ghi_dir=
fi
if [ "${SDE_GH_INSTALL:-1}" -eq 0 ]; then
gh_dir=
fi
if [ "${SDE_GCCGO_INSTALL:-1}" -eq 0 ]; then
gccgo_dir=
fi
if [ "${SDE_YCM_INSTALL:-1}" -eq 0 ]; then
ycm_dir=
fi
if [ "${SDE_NINJA_INSTALL:-1}" -eq 0 ]; then
ninja_dir=
fi
#if [ -z "$gccgo_dir" ]; then
# if [ -n "$gh_dir" ]; then
# panic "cannot install gh without gccgo"
# fi
# if [ -n "$hub_dir" ]; then
# panic "cannot install hub without gccgo"
# fi
#fi
if [ -n "$clang_qversion" ]; then
native_clang_version="$(get_clang_version)" || \
native_clang_version=
if [ -n "$native_clang_version" ]; then
native_clang_major_version=$(get_version_info \
"$native_clang_version" major) || \
panic "cannot get version information"
clang_major_version=$(get_version_info "$clang_version" major) || \
panic "cannot get version information"
if [ "$native_clang_major_version" = "$clang_major_version" ]; then
echo "clang $clang_major_version is already installed"
echo "skipping clang install to avoid possible shared library conflicts"
clang_version=
fi
fi
fi
if [ "$alt_gcc_install" -ne 0 ]; then
#commit="$("$sde_install_gcc" --print-commit --method git --version master)" || \
# panic "cannot get GCC commit"
#alt_gcc_version="git:$commit"
alt_gcc_method="$(qversion_get method "$alt_gcc_qversion")" || \
panic "cannot get method"
alt_gcc_version="$(qversion_get version "$alt_gcc_qversion")" || \
panic "cannot get version"
alt_gcc_dir="$packages_dir/gcc-$alt_gcc_version"
fi
if [ "$alt_clang_install" -ne 0 ]; then
#commit="$("$sde_install_clang" --print-commit --method git --version main)" || \
# panic "cannot get Clang commit"
#alt_clang_dir="$packages_dir/clang-git:$commit"
alt_clang_method="$(qversion_get method "$alt_clang_qversion")" || \
panic "cannot get method"
alt_clang_version="$(qversion_get version "$alt_clang_qversion")" || \
panic "cannot get version"
alt_clang_dir="$packages_dir/clang-$alt_clang_version"
fi
################################################################################
# Perform any cleaning.
################################################################################
if [ "$clean" -ne 0 ]; then
echo "Cleaning"
if [ -d "$sdebase_dir" ]; then
rm -rf "$sdebase_dir" || panic
fi
dirs=()
dirs+=(bin)
dirs+=(doc)
dirs+=(etc)
for dir in "${dirs[@]}"; do
target_dir="$sde_top_dir/$dir"
if [ -d "$target_dir" ]; then
rm -rf "$target_dir" || \
panic "cannot remove directory $target_dir"
fi
done
fi
################################################################################
# Install SDE Base
################################################################################
sdebase_installed=0
if [ ! -d "$sdebase_dir" ]; then
sdebase_installed=1
files=()
files+=($(cd "$cmd_dir" && find bin -type f))
files+=($(cd "$cmd_dir" && find doc -type f))
files+=($(cd "$cmd_dir" && find etc -type f))
for file in ${files[@]}; do
dir=$(dirname "$file") || panic "cannot get directory of $file"
#echo "processing $file $dir"
mode="r"
case "$file" in
bin/*)
case "$file" in
bin/sde_shell_bashrc)
;;
*)
mode="rx";;
esac
esac
target_dir="$sdebase_dir/$dir"
if [ ! -d "$target_dir" ]; then
mkdir -p "$target_dir" || panic "cannot make directory $target_dir"
fi
#echo "installing $cmd_dir/$file $sdebase_dir/$file"
install -m a+"$mode" "$cmd_dir/$file" "$sdebase_dir/$file" || \
panic "cannot install file $file"
done
fi
################################################################################
# Perform other SDE installation
################################################################################
for dir in bin doc etc etc/environments toolchains; do
if [ ! -d "$sde_top_dir/$dir" ]; then
mkdir -p "$sde_top_dir/$dir" || \
panic "cannot make directory $dir"
fi
done
if [ "$sdebase_installed" -ne 0 ]; then
# executables in $sde_top_dir/bin directory
files=()
files+=($(cd "$sdebase_dir" && find bin -type f))
files+=($(cd "$sdebase_dir" && find doc -type f))
files+=($(cd "$sdebase_dir" && find etc -type f))
for file in "${files[@]}"; do
source_file="$generic_sdebase_dir/$file"
destination_file="$sde_top_dir/$file"
destination_dir=$(dirname "$destination_file") || \
panic "cannot get directory of $destination_file"
if [ -L "$destination_file" -o -e "$destination_file" ]; then
rm -f "$destination_file" || \
panic "cannot remove file $destination_file"
fi
relpath=$("$sde_relpath" -r "$destination_dir" "$source_file") || \
panic "cannot get relative path"
ln -s "$relpath" "$destination_file" || \
panic "cannot link"
done
file_list=(cmake ctest cpack gdb)
if [ -n "$gcc_dir" -o -n "$alt_gcc_dir" ]; then
file_list+=(gcc g++)
fi
if [ -n "$clang_dir" -o -n "$alt_clang_dir" ]; then
file_list+=(clang clang++)
fi
if [ -n "$gcc_dir" -o -n "$alt_gcc_dir" -o -n "$clang_dir" -o \
-n "$alt_clang_dir" ]; then
file_list+=(cc c++)
fi
if [ -n "$gccgo_dir" ]; then
file_list+=(gccgo go)
fi
for file in "${file_list[@]}"; do
target_file="$sde_top_dir/bin/$file"
if [ -L "$target_file" -o -e "$target_file" ]; then
rm -f "$target_file" || panic "cannot remove file $target_file"
fi
ln -s sde_wrapper "$target_file" || \
panic "cannot link"
done
"$sde_cmd" pkg -d "$sde_top_dir" "sdebase" default || \
panic "cannot set package version"
fi
if [ -n "$default_environment" ]; then
"$sde_cmd" env -d "$sde_top_dir" "$default_environment" || \
panic "cannot set default environment"
fi
################################################################################
# Setup toolchain files for CMake.
################################################################################
cp -f "$sde_toolchain_template" "$sde_toolchain_dir" || \
panic "cannot copy file"
if [ -n "$gcc_version" ]; then
"$sde_make_cmake_toolchain_file" \
-f \
-i "$sde_toolchain_template" \
-o "$sde_toolchain_dir/gcc-default.cmake" \
-d "$sde_top_dir" \
-n gcc -v "$gcc_version" || \
panic "cannot make toolchain file"
fi
if [ "$alt_gcc_install" -ne 0 ]; then
"$sde_make_cmake_toolchain_file" \
-f \
-i "$sde_toolchain_template" \
-o "$sde_toolchain_dir/gcc-alt.cmake" \
-d "$sde_top_dir" \
-n gcc \
-v alt || \
panic "cannot make toolchain file"
fi
if [ -n "$clang_version" ]; then
"$sde_make_cmake_toolchain_file" \
-f \
-i "$sde_toolchain_template" \
-o "$sde_toolchain_dir/clang-default.cmake" \
-d "$sde_top_dir" \
-n clang \
-v "$clang_version" || \
panic "cannot make toolchain file"
fi
if [ "$alt_clang_install" -ne 0 ]; then
"$sde_make_cmake_toolchain_file" \
-f \
-i "$sde_toolchain_template" \
-o "$sde_toolchain_dir/clang-alt.cmake" \
-d "$sde_top_dir" \
-n clang \
-v alt || \
panic "cannot make toolchain file"
fi
################################################################################
# Install YCM Extras
################################################################################
if [ -n "$ycm_extras_dir" ]; then
if [ ! -d "$ycm_extras_dir" ]; then
for dir in "$ycm_extras_dir"; do
if [ ! -d "$dir" ]; then
mkdir -p "$dir" || \
panic "cannot make directory $dir"
fi
done
# YCM Extras
ycm_extra_conf_file="$ycm_extras_dir/.ycm_extra_conf.py"
if [ -f "$ycm_extra_conf_file" ]; then
rm -f "$ycm_extra_conf_file" || \
panic "cannot remove file $ycm_extra_conf_file"
fi
sed -e 's%@@SDE_TOP_DIR@@%'"$sde_top_dir"'%g' \
< "$cmd_dir/etc/ycm_extra_conf.py.template" \
> "$ycm_extra_conf_file" || panic "cannot create file"
fi
fi
################################################################################
# Install CMake
################################################################################
# Since some software requires CMake to build, install CMake before
# building other software.
if [ -n "$cmake_version" -a -n "$cmake_dir" ]; then
if [ ! -d "$cmake_dir" ]; then
"$sde_shell" -s -p null -x \
"$sde_install_cmake" -v "$cmake_version" -d "$cmake_dir" || \
panic "cannot install cmake"
fi
"$sde_cmd" pkg -d "$sde_top_dir" cmake "$cmake_version" || \
panic "cannot configure cmake"
fi
################################################################################
# Install Ninja
################################################################################
# TODO/NOTE: This should probably be moved until after GCC is installed.
if [ -n "$ninja_version" -a -n "$ninja_dir" ]; then
if [ ! -d "$ninja_dir" ]; then
"$sde_shell" -s -p cmake -x \
"$sde_install_ninja" -v "$ninja_version" -d "$ninja_dir" || \
panic "cannot install ninja"
fi
"$sde_cmd" pkg -d "$sde_top_dir" ninja "$ninja_version" || \
panic "cannot configure ninja"
fi
################################################################################
# Install GHI
################################################################################
if [ -n "$ghi_version" -a -n "$ghi_dir" ]; then
if [ ! -d "$ghi_dir" ]; then
"$sde_shell" -s -p null -x \
"$sde_install_ghi" -v "$ghi_version" -d "$ghi_dir" || \
panic "cannot install ghi"
fi
"$sde_cmd" pkg -d "$sde_top_dir" ghi "$ghi_version" || \
panic "cannot configure ghi"
fi
################################################################################
# Install GCC
################################################################################
if [ -n "$gcc_version" -a -n "$gcc_dir" ]; then
if [ ! -d "$gcc_dir" ]; then
"$sde_shell" -s -p null -x \
"$sde_install_gcc" \
--method "$gcc_method" \
--version "$gcc_version" \
--install-dir "$gcc_dir" \
"${gcc_install_options[@]}" || \
panic "cannot install gcc"
fi
"$sde_cmd" pkg -d "$sde_top_dir" gcc "$gcc_version" || \
panic "cannot configure gcc"
fi
################################################################################
# Install Alternative Version of GCC
################################################################################
if [ "$alt_gcc_install" -ne 0 -a -n "$alt_gcc_dir" ]; then
if [ ! -d "$alt_gcc_dir" ]; then
"$sde_shell" -s -p null -x \
"$sde_install_gcc" \
--method "$alt_gcc_method" \
--version "$alt_gcc_version" \
--install-dir "$alt_gcc_dir" \
"${alt_gcc_install_options[@]}" || \
panic "cannot install gcc"
fi
#"$sde_cmd" pkg -d "$sde_top_dir" gcc "$gcc_version" || \
# panic "cannot configure gcc"
base=$(basename "$alt_gcc_dir") || \
panic "cannot get basename"
target="$packages_dir/gcc-alt"
if [ ! -e "$target" ]; then
ln -s "$base" "$target" || \
panic "cannot create symlink"
fi
fi
################################################################################
# Install Clang
################################################################################
if [ -n "$clang_version" -a -n "$clang_dir" ]; then
if [ ! -d "$clang_dir" ]; then
# Note: The "gcc-*" in the -p option might not be necessary.
"$sde_shell" -s -p cmake:gcc-$gcc_version -x \
"$sde_install_clang" \
--method "$clang_method" \
--version "$clang_version" \
--install-dir "$clang_dir" \
--gcc-dir "$gcc_dir" \
"${clang_install_options[@]}" \
|| panic "cannot install clang"
fi
"$sde_cmd" pkg -d "$sde_top_dir" clang "$clang_version" || \
panic "cannot configure clang"
fi