This repository has been archived by the owner on Jun 16, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gap.cc
1361 lines (1294 loc) · 46.3 KB
/
gap.cc
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
//
// gap.cc - part of the GAP installer BOB
//
// Copyright (C) by Max Neunhoeffer 2012
// This file is free software, see license information at the end.
//
#include <sys/stat.h>
#include <dirent.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/wait.h>
#include <fstream>
#include <iostream>
#include "bob.h"
using namespace std;
using namespace BOB;
static const char *GAP_dependencies[]
= { NULL };
static Status GAP_prerequisites(string, Status)
{
Status res = OK;
string path;
bool hint = false;
if (!which("/bin/sh",path)) {
out(ERROR,"Need a (bash-like) shell in /bin/sh, please install one.");
res = ERROR;
}
if (Which_C_Compiler.num != 0) {
out(ERROR,"Need a C-compiler, preferably gcc, please install one.");
res = ERROR;
}
if (Have_make.num != 0) {
out(ERROR,"Need the 'make' utility, please install it.");
res = ERROR;
}
if (!which("m4",path)) {
out(ERROR,"Need the 'm4' utility, please install it.");
res = ERROR;
}
if (Have_C_Library("-lreadline -lncurses") != OK) {
out(OK,"");
out(WARN,"You do not have the readline library installed.");
out(WARN,"GAP will be compiled without readline support.");
hint = true;
}
if (Have_C_Header("readline/readline.h") != OK) {
out(OK,"");
out(WARN,"You do not have the headers for the readline library "
"installed.");
out(WARN,"GAP will be compiled without readline support.");
hint = true;
}
if (Which_Architecture.str == "OSX" &&
(!which("/usr/bin/gcc",path) ||
!which("/usr/bin/xcodebuild",path))) {
out(WARN,"It seems that you do not have the XCode command line tools.");
hint = true;
}
if (Double_Compile.str == "DoubleCompile") {
if (Have_C_Library("-lreadline -lncurses",true) != OK) {
out(OK,"");
out(WARN,"You do not have the 32bit readline library installed.");
out(WARN,"32bit-GAP will be compiled without readline support.");
hint = true;
}
if (Have_C_Header("readline/readline.h",true) != OK) {
out(OK,"");
out(WARN,"You do not have the headers for the 32bit readline "
"library installed.");
out(WARN,"32bit-GAP will be compiled without readline support.");
hint = true;
}
}
if (res != OK || hint) {
if (Which_Architecture.str == "LINUX" &&
Which_OS_Variant.str == "apt-get") {
out(OK,"");
out(ADVICE,"You can install the necessary tools by doing:");
out(ADVICE," apt-get install gcc make m4 libc6-dev libreadline-dev");
out(ADVICE,"with root privileges (using su or sudo).");
if (Double_Compile.str == "DoubleCompile") {
out(ADVICE,"For the 32-bit libraries do:");
out(ADVICE," apt-get install lib32readline5-dev");
}
out(OK,"");
}
if (Which_Architecture.str == "LINUX" &&
Which_OS_Variant.str == "rpm") {
out(ADVICE,"You can install the necessary libraries from"
" the following rpm-packages:");
out(ADVICE," gcc make m4 glibc-devel readline-devel");
out(ADVICE,"Use");
out(ADVICE," yum install gcc make m4 glibc-devel readline-devel");
out(ADVICE,"with root privileges (using su or sudo).");
if (Double_Compile.str == "DoubleCompile") {
out(ADVICE,"For the 32-bit libraries do:");
out(ADVICE," yum install glibc-devel.i686 readline-devel.i686");
}
out(OK,"");
}
if (Which_Architecture.str == "OSX") {
out(OK,"");
out(ADVICE,"First you need to install the Apple Developer Tools "
"(aka XCode)");
out(ADVICE,"with \"gcc\" \"make\" and \"m4\".");
out(ADVICE,"See https://developer.apple.com/technologies/tools/");
out(ADVICE,"and http://www.gap-system.org/Download/tools.html");
out(ADVICE,"Launch Xcode, then open its Preferences dialog, and go");
out(ADVICE,"to the \"Downloads\" pane. You will be presented with");
out(ADVICE,"an optional list of extra components. From there,");
out(ADVICE,"install the \"Command Line tools\" component.");
out(OK,"");
if (which("port",path)) {
out(ADVICE,"You can install the necessary additional libraries "
"by doing:");
out(ADVICE," sudo port install readline +universal");
out(OK,"");
}
if (which("brew",path)) {
out(ADVICE,"You can install the necessary additional libraries "
"by doing:");
out(ADVICE," brew install readline");
out(OK,"");
}
if (which("fink",path)) {
out(ADVICE,"You can install the necessary additional libraries "
"by doing:");
out(ADVICE," fink install readline5");
out(OK,"");
}
}
}
return res;
}
static string GAP_archivename;
static Status GAP_getfunc(string targetdir)
{
try {
getind(targetdir, "http://gap-system.github.io/bob/GAP.link",
GAP_archivename);
}
catch (Status e) {
out(ERROR,"Could not download GAP archive.");
return ERROR;
}
return OK;
}
vector<string> confignames;
vector<string> GAParchs;
static void DetermineGAParchs(void)
// Must be in targetdir.
{
fstream f;
int i;
string line;
if (GAParchs.size() > 0) return;
for (i = 0;i <= Double_Compile.num;i++) {
if (Double_Compile.num == 1 && i == 0)
f.open("gap4r7/sysinfo.gap-default32",fstream::in);
else if (Double_Compile.num == 1 && i == 1)
f.open("gap4r7/sysinfo.gap-default64",fstream::in);
else
f.open("gap4r7/sysinfo.gap",fstream::in);
if (f.fail()) {
out(ERROR,"Cannot determine GAParchs.");
return;
}
getline(f,line);
f.close();
GAParchs.push_back(line.substr(8));
}
}
static string merkCFLAGS;
static string merkCPPFLAGS;
static string merkLDFLAGS;
static void GAP_sortoutenvironment(void)
{
merkCFLAGS = getenvironment("CFLAGS");
merkCPPFLAGS = getenvironment("CPPFLAGS");
merkLDFLAGS = getenvironment("LDFLAGS");
delenvironment("CFLAGS");
delenvironment("CPPFLAGS");
delenvironment("LDFLAGS");
setenvironment("COPTS",merkCPPFLAGS + " " + merkCFLAGS);
setenvironment("LOPTS",merkLDFLAGS);
out(OK,"Using COPTS=\""+getenvironment("COPTS")+"\"");
out(OK,"Using LOPTS=\""+getenvironment("LOPTS")+"\"");
}
static void GAP_restoreenvironment(void)
{
if (merkCFLAGS != "") setenvironment("CFLAGS",merkCFLAGS);
if (merkCPPFLAGS != "") setenvironment("CPPFLAGS",merkCPPFLAGS);
if (merkLDFLAGS != "") setenvironment("LDFLAGS",merkLDFLAGS);
delenvironment("COPTS");
delenvironment("LOPTS");
}
static Status GAP_buildfunc(string)
{
// By convention, we are in the target directory.
if (access("gap4r7",F_OK) == 0) {
if (interactive) {
string answer;
cout << "\nATTENTION!\n\n"
<< "There seems to be a previous installation of GAP 4.7 in "
<< "the gap4r7 directory.\n\n";
fstream stamp("gap4r7/BOBusedArchive",fstream::in);
if (!stamp.fail()) {
string stamparchive;
getline(stamp,stamparchive);
stamp.close();
if (stamparchive == GAP_archivename) {
cout << "Note that the previous installation was done "
"from the same archive as this one!\n\n";
}
}
cout << "Remove old installation?\n\n"
<< "Answer \"yes\" to proceed or anything else to abort --> ";
cin >> answer;
if (answer != "yes") {
out(ERROR,"Not removing old installation. Aborting.");
exit(2);
}
}
out(OK,"Removing old installation...");
if (rmrf("gap4r7") == ERROR)
out(WARN,"Could not remove directory \"gap4r7\" recursively!");
}
out(OK,"Unpacking GAP archive...");
try { unpack(GAP_archivename); }
catch (Status e) {
out(ERROR,"A problem occurred when extracting the archive.");
return ERROR;
}
try { cd("gap4r7"); } catch (Status e) { return ERROR; }
fstream stamp("BOBusedArchive",fstream::out | fstream::trunc);
if (stamp.fail()) {
out(WARN,"Could not create file BOBusedArchive.");
} else {
stamp << GAP_archivename << endl;
stamp.close();
}
// Clean up environment due to GAP's funny behaviour:
GAP_sortoutenvironment();
string readlineopt = "";
if (Which_Architecture.str == "OSX") {
if (exists("/opt/local/lib/libreadline.dylib") &&
exists("/opt/local/include/readline/readline.h")) {
// MacPorts put the readline library there
readlineopt = " --with-readline=/opt/local";
} else if (exists("/opt/lib/libreadline.dylib") &&
exists("/opt/include/readline/readline.h")) {
readlineopt = " --with-readline=/opt";
} else if (isdir("/usr/local/Cellar/readline")) {
// homebrew currently has it here.
readlineopt = " --with-readline=/usr/local/Cellar/readline/6.2.2";
// FIXME: Read off version number here
} else if (finkpath != "" &&
exists(finkpath+"include/readline/readline.h") &&
exists(finkpath+"lib/libreadline.dylib")) {
readlineopt = " --with-readline="+finkpath;
}
}
if (Double_Compile.str == "DoubleCompile") {
out(OK,"Compiling for both 32-bit and 64-bit...");
out(OK,"Running ./configure ABI=32"+readlineopt+" for GAP...");
try { sh("./configure ABI=32"+readlineopt); }
catch (Status e) {
out(ERROR,"Error in configure stage.");
GAP_restoreenvironment();
return ERROR;
}
out(OK,"Running make for GAP...");
try { sh("make"); }
catch (Status e) {
out(ERROR,"Error in compilation stage.");
GAP_restoreenvironment();
return ERROR;
}
confignames.push_back("default32");
}
out(OK,"Running ./configure"+readlineopt+" for GAP...");
try { sh("./configure"+readlineopt); }
catch (Status e) {
out(ERROR,"Error in configure stage.");
GAP_restoreenvironment();
return ERROR;
}
out(OK,"Running make for GAP...");
try { sh("make"); }
catch (Status e) {
out(ERROR,"Error in compilation stage.");
GAP_restoreenvironment();
return ERROR;
}
GAP_restoreenvironment();
if (Which_Wordsize.num == 32)
confignames.push_back("default32");
else
confignames.push_back("default64");
return OK;
}
Component GAP("GAP",GAP_dependencies,GAP_prerequisites,
GAP_getfunc,GAP_buildfunc);
static Status BuildGAPPackage(string, string pkgname, bool withm32,
Status err, bool withmakeclean = false,
bool withabi32 = false, bool only64 = false)
{
string msg;
string pkgdir;
string cmd;
Status res = OK;
try { cd("gap4r7/pkg"); } catch (Status e) { return err; }
try { cdprefix(pkgname,pkgdir); } catch (Status e) { return err; }
if (Double_Compile.str == "DoubleCompile") {
if (!only64) {
cmd = string("./configure CONFIGNAME=default32");
if (withm32) cmd += " CFLAGS=-m32";
if (withabi32) cmd += " ABI=32";
msg = string("Running "+cmd+" for ")+pkgname+" package...";
out(OK,msg);
try { sh(cmd); }
catch (Status e) {
out(err,"Error in configure stage.");
res = err;
goto dosixtyfour;
}
msg = string("Running make for ")+pkgname+" package...";
out(OK,msg);
try { sh("make"); }
catch (Status e) {
out(err,"Error in compilation stage.");
res = err;
goto dosixtyfour;
}
if (withmakeclean) {
msg = string("Running make clean for ")+pkgname+" package...";
out(OK,msg);
try { sh("make clean"); }
catch (Status e) {
out(err,"Error in make clean stage.");
res = err;
}
}
}
dosixtyfour:
msg = string("Running ./configure CONFIGNAME=default64 for ")+pkgname+
" package...";
out(OK,msg);
try { sh("./configure CONFIGNAME=default64"); }
catch (Status e) {
out(err,"Error in configure stage.");
return err;
}
msg = string("Running make for ")+pkgname+" package...";
out(OK,msg);
try { sh("make"); }
catch (Status e) {
out(err,"Error in compilation stage.");
return err;
}
return res;
} else {
msg = string("Running ./configure for ")+pkgname+ " package...";
out(OK,msg);
try { sh("./configure"); }
catch (Status e) {
out(err,"Error in configure stage.");
return err;
}
msg = string("Running make for ")+pkgname+" package...";
out(OK,msg);
try { sh("make"); }
catch (Status e) {
out(err,"Error in compilation stage.");
return err;
}
}
return OK;
}
static const char *deps_onlyGAP[]
= { "!GAP", NULL };
static Status io_buildfunc(string targetdir)
{ return BuildGAPPackage(targetdir, "io", true, ERROR); }
Component io("io",deps_onlyGAP,NULL,NULL,io_buildfunc);
static Status orb_buildfunc(string targetdir)
{ return BuildGAPPackage(targetdir, "orb", true, WARN); }
Component orb("orb",deps_onlyGAP,NULL,NULL,orb_buildfunc);
static Status cvec_buildfunc(string targetdir)
{ return BuildGAPPackage(targetdir, "cvec", true, WARN); }
Component cvec("cvec",deps_onlyGAP,NULL,NULL,cvec_buildfunc);
static Status edim_buildfunc(string targetdir)
{ return BuildGAPPackage(targetdir, "edim", false, WARN); }
Component edim("edim",deps_onlyGAP,NULL,NULL,edim_buildfunc);
static Status Browse_prerequisites(string, Status depsresult)
{
string path;
Status ret;
bool hint = false;
ret = OK;
if (depsresult != OK) return depsresult;
if (Have_C_Library("-lncurses") != OK ||
Have_C_Header("ncurses.h") != OK) {
out(OK,"");
out(WARN,"Need ncurses library for component Browse.");
ret = WARN;
}
if (Have_C_Library("-lpanel") != OK ||
Have_C_Header("panel.h") != OK) {
out(OK,"");
out(WARN,"Need panel library for component Browse.");
ret = WARN;
}
if (Double_Compile.str == "DoubleCompile") {
if (Have_C_Library("-lncurses",true) != OK ||
Have_C_Header("ncurses.h",true) != OK) {
out(OK,"");
out(WARN,"Need 32bit ncurses library for component "
"Browse to work in 32bit GAP.");
hint = true;
}
if (Have_C_Library("-lpanel",true) != OK ||
Have_C_Header("panel.h",true) != OK) {
out(OK,"");
out(WARN,"Need 32bit panel library for component "
"Browse to work in 32bit GAP.");
hint = true;
}
}
if (ret != OK || hint) {
if (Which_Architecture.str == "LINUX" &&
Which_OS_Variant.str == "apt-get") {
out(OK,"");
out(ADVICE,"You can install the necessary libraries by doing:");
out(ADVICE," apt-get install libncurses-dev");
out(ADVICE,"with root privileges (using su or sudo).");
if (Double_Compile.str == "DoubleCompile") {
out(ADVICE,"For the 32-bit libraries do:");
out(ADVICE," apt-get install lib32ncurses5-dev");
}
out(OK,"");
}
if (Which_Architecture.str == "LINUX" &&
Which_OS_Variant.str == "rpm") {
out(ADVICE,"You can install the necessary libraries from"
" the following rpm-packages:");
out(ADVICE," ncurses-devel");
out(ADVICE,"Use");
out(ADVICE," yum install ncurses-devel");
out(ADVICE,"with root privileges (using su or sudo).");
if (Double_Compile.str == "DoubleCompile") {
out(ADVICE,"For the 32-bit libraries do:");
out(ADVICE," yum install ncurses-devel.i686");
}
out(OK,"");
}
if (Which_Architecture.str == "OSX") {
if (which("port",path)) {
out(ADVICE,"You can install the necessary additional libraries "
"by doing:");
out(ADVICE," sudo port install ncurses +universal");
out(OK,"");
}
if (which("brew",path)) {
out(ADVICE,"Currently you cannot install ncurses via homebrew.");
out(OK,"");
}
if (which("fink",path)) {
out(ADVICE,"You can install the necessary additional libraries "
"by doing:");
out(ADVICE," fink install libncurses5");
out(OK,"");
}
}
}
return ret;
}
static Status Browse_buildfunc(string targetdir)
{ return BuildGAPPackage(targetdir, "Browse", false, WARN); }
Component Browse("Browse",deps_onlyGAP,Browse_prerequisites,NULL,
Browse_buildfunc);
static Status nq_prerequisites(string, Status depsresult)
{
string path;
Status ret;
if (depsresult != OK) return depsresult;
ret = OK;
if (!(which("gawk",path) || which("mawk",path) || which("nawk",path) ||
which("awk",path))) {
out(OK,"");
out(WARN,"Need awk for component nq-Pkg.");
ret = WARN;
}
if (ret != OK) {
if (Which_Architecture.str == "LINUX" &&
Which_OS_Variant.str == "apt-get") {
out(OK,"");
out(ADVICE,"You can install the necessary tools by doing:");
out(ADVICE," apt-get install mawk");
out(ADVICE,"with root privileges (using su or sudo).");
out(OK,"");
}
if (Which_Architecture.str == "LINUX" &&
Which_OS_Variant.str == "rpm") {
out(ADVICE,"You can install the necessary libraries from"
" the following rpm-packages:");
out(ADVICE," mawk");
out(ADVICE,"Use");
out(ADVICE," yum install mawk");
out(ADVICE,"with root privileges (using su or sudo).");
out(OK,"");
}
if (Which_Architecture.str == "OSX") {
out(OK,"");
if (which("port",path)) {
out(ADVICE,"You can install the necessary additional libraries "
"by doing:");
out(ADVICE," sudo port install gawk");
out(OK,"");
}
if (which("brew",path)) {
out(ADVICE,"You can install the necessary additional libraries "
"by doing:");
out(ADVICE," brew install gawk");
out(OK,"");
}
if (which("fink",path)) {
out(ADVICE,"You can install the necessary additional libraries "
"by doing:");
out(ADVICE," fink install gawk");
out(OK,"");
}
}
}
return ret;
}
static Status nq_buildfunc(string targetdir)
{ return BuildGAPPackage(targetdir, "nq", true, WARN, true, true); }
Component nq("nq",deps_onlyGAP,nq_prerequisites,NULL,nq_buildfunc);
static Status switch_sysinfo_link(string targetdir, int towhat)
{
if (Double_Compile.str == "SingleCompile") return OK;
if (chdir(targetdir.c_str()) != 0 ||
chdir("gap4r7") != 0 ||
unlink("sysinfo.gap") != 0 ||
unlink("Makefile") != 0) {
out(ERROR,"Could not switch sysinfo.gap symbolic link.");
return ERROR;
}
if (towhat == 0) {
out(OK,"Switching to default32 configuration.");
if (symlink("sysinfo.gap-default32","sysinfo.gap") != 0 ||
symlink("Makefile-default32","Makefile") != 0) {
out(ERROR,"Could not switch sysinfo.gap symbolic link.");
return ERROR;
}
} else {
out(OK,"Switching to default64 configuration.");
if (symlink("sysinfo.gap-default64","sysinfo.gap") != 0 ||
symlink("Makefile-default64","Makefile") != 0) {
out(ERROR,"Could not switch sysinfo.gap symbolic link.");
return ERROR;
}
}
try { cd(targetdir); } catch (Status e) {
out(ERROR,"Could not switch sysinfo.gap symbolic link.");
return ERROR;
}
return OK;
}
static Status BuildOldGAPPackage(string targetdir, string pkgname, Status err,
bool only64=false)
{
string dirfound;
string msg;
int i;
Status ret = OK;
for (i = 0;i <= Double_Compile.num;i++) {
if (i < Double_Compile.num && only64) continue;
if (switch_sysinfo_link(targetdir,i) == ERROR) return ERROR;
string pkgdir = string("gap4r7/pkg");
string cmd;
try { cd("gap4r7/pkg"); } catch (Status e) { ret = err; continue; }
try { cdprefix(pkgname,dirfound); }
catch (Status e) { ret = err; continue; }
msg = string("Running ./configure ../.. for ")+pkgname+" package...";
out(OK,msg);
try { sh("./configure ../.."); }
catch (Status e) {
out(err,"Error in configure stage.");
ret = err;
continue;
}
msg = string("Running make for ")+pkgname+" package...";
out(OK,msg);
try { sh("make"); }
catch (Status e) {
out(err,"Error in compilation stage.");
ret = err;
continue;
}
}
if (switch_sysinfo_link(targetdir,i) == ERROR) return ERROR;
return ret;
}
static Status example_buildfunc(string targetdir)
{ return BuildOldGAPPackage(targetdir,"example", WARN); }
Component example("example",deps_onlyGAP,NULL,NULL,example_buildfunc);
static Status ace_buildfunc(string targetdir)
{ return BuildOldGAPPackage(targetdir,"ace", WARN); }
Component ace("ace",deps_onlyGAP,NULL,NULL,ace_buildfunc);
static Status atlasrep_buildfunc(string)
{
try { cd("gap4r7/pkg/atlasrep"); } catch (Status e) { return WARN; }
if (chmod("datagens",01777) < 0 ||
chmod("dataword",01777) < 0) {
out(WARN,"Cannot set permissions for \"datagens\" and \"dataword\".");
return WARN;
}
return OK;
}
Component atlasrep("atlasrep",deps_onlyGAP,NULL,NULL,atlasrep_buildfunc);
static Status cohomolo_buildfunc(string targetdir)
{ return BuildOldGAPPackage(targetdir,"cohomolo", WARN); }
Component cohomolo("cohomolo",deps_onlyGAP,NULL,NULL,cohomolo_buildfunc);
static Status fplsa_patchfunc(string targetdir)
{
string edscriptname;
if (Which_Architecture.str != "OSX") return OK;
out(OK,"Patching fplsa for Mac OSX...");
try {
getind(targetdir, "http://gap-system.github.io/bob/fplsa.edit.link",
edscriptname);
}
catch (Status e) {
out(ERROR,"Could not download patch for fplsa.");
return WARN;
}
try { edit(edscriptname); } catch (Status e) { return WARN; }
return OK;
}
static Status fplsa_buildfunc(string targetdir)
{ return BuildOldGAPPackage(targetdir,"fplsa", WARN); }
Component fplsa("fplsa",deps_onlyGAP,NULL,fplsa_patchfunc,fplsa_buildfunc);
#if 0
static Status fr_prerequisites(string, Status depsresult)
{
string path;
if (depsresult != OK) return depsresult;
if (!which("wget",path)) {
out(OK,"");
out(WARN,"Need wget utility installed for component fr.");
out(OK,"");
if (Which_Architecture.str == "LINUX" &&
Which_OS_Variant.str == "apt-get") {
out(ADVICE,"You can install the necessary tool by doing:");
out(ADVICE," apt-get install wget");
out(ADVICE,"with root privileges (using su or sudo).");
out(OK,"");
}
if (Which_Architecture.str == "LINUX" &&
Which_OS_Variant.str == "rpm") {
out(ADVICE,"You can install the necessary tools from"
" the following rpm-packages:");
out(ADVICE," wget");
out(ADVICE,"Use");
out(ADVICE," yum install wget");
out(ADVICE,"with root privileges (using su or sudo).");
out(OK,"");
}
if (Which_Architecture.str == "OSX") {
out(OK,"");
if (which("port",path)) {
out(ADVICE,"You can install the necessary additional tools "
"by doing:");
out(ADVICE," sudo port install wget");
out(OK,"");
}
if (which("brew",path)) {
out(ADVICE,"You can install the necessary additional tools "
"by doing:");
out(ADVICE," brew install wget");
out(OK,"");
}
if (which("fink",path)) {
out(ADVICE,"You can install the necessary additional tools "
"by doing:");
out(ADVICE," fink install wget");
out(OK,"");
}
}
}
if (!which("appletviewer",path) ||
!which("javac",path)) {
out(WARN,"Need appletviewer and java compiler for component fr.");
}
return OK;
}
static Status fr_buildfunc(string targetdir)
{
vector<string> PackageInfo;
try {
readlines(targetdir+"gap4r7/pkg/fr/PackageInfo.g",PackageInfo);
if (PackageInfo.size() >= 10 &&
PackageInfo[9] == "Version := \"1.2.6.4\",") {
out(WARN,"This version 1.2.6.4 of fr has known compilation "
"problems.");
}
}
catch (Status e) {
out(WARN,"Could not read gap4r7/pkg/fr/PackageInfo.g");
}
return BuildGAPPackage(targetdir,"fr",true,WARN);
}
Component fr("fr",deps_onlyGAP,fr_prerequisites,NULL,fr_buildfunc);
#endif
static Status grape_buildfunc(string targetdir)
{ return BuildOldGAPPackage(targetdir,"grape", WARN); }
Component grape("grape",deps_onlyGAP,NULL,NULL,grape_buildfunc);
static Status Gauss_buildfunc(string targetdir)
{ return BuildOldGAPPackage(targetdir,"Gauss", WARN); }
Component Gauss("Gauss",deps_onlyGAP,NULL,NULL,Gauss_buildfunc);
static Status guava_buildfunc(string targetdir)
{
string msg;
string pkgname = "guava";
string dirfound;
int i;
Status ret = OK;
for (i = 0;i <= Double_Compile.num;i++) {
if (switch_sysinfo_link(targetdir,i) == ERROR) return ERROR;
string pkgdir = string("gap4r7/pkg/");
string cmd;
try { cd("gap4r7/pkg"); } catch (Status e) { ret = WARN; continue; }
try { cdprefix(pkgname,dirfound); }
catch (Status e) { ret = WARN; continue; }
mkdir("bin",0755); // intentionally ignore errors here
msg = string("Running ./configure ../.. for ")+pkgname+" package...";
out(OK,msg);
try { sh("./configure ../.."); }
catch (Status e) {
out(WARN,"Error in configure stage.");
ret = WARN;
break;
}
msg = string("Running make for ")+pkgname+" package...";
out(OK,msg);
try { sh("make"); }
catch (Status e) {
out(WARN,"Error in compilation stage.");
ret = WARN;
break;
}
msg = string("Running make install for ")+pkgname+" package...";
out(OK,msg);
try { sh("make install"); }
catch (Status e) {
out(WARN,"Error in installation stage.");
ret = WARN;
break;
}
}
if (switch_sysinfo_link(targetdir,i) == ERROR) return ERROR;
return ret;
}
Component guava("guava",deps_onlyGAP,NULL,NULL,guava_buildfunc);
static Status kbmag_prerequisites(string, Status depsresult)
{
if (depsresult != OK) return depsresult;
if (Which_Wordsize.num == 64 &&
Can_Compile_32bit.num != 0) {
out(WARN,"Need to compile in 32-bit mode using -m32 for component "
"kbmag.");
out(WARN,"Please use gcc or clang and install the necessary 32-bit "
"libraries.");
return WARN;
}
return OK;
}
static Status kbmag_buildfunc(string targetdir)
{
string msg;
int i;
Status ret = OK;
for (i = 0;i <= Double_Compile.num;i++) {
if (switch_sysinfo_link(targetdir,i) == ERROR) return ERROR;
string pkgdir = "gap4r7/pkg/kbmag";
string cmd;
if (chdir(pkgdir.c_str())) {
msg = "Cannot change to the kbmag package's directory.";
out(WARN,msg);
ret = WARN;
break;
}
msg = "Running ./configure ../.. for kbmag package...";
out(OK,msg);
try { sh("./configure ../.."); }
catch (Status e) {
out(WARN,"Error in configure stage.");
ret = WARN;
break;
}
out(OK,"Running make for kbmag package...");
if (Which_Wordsize.num == 64)
msg = "make COPTS=-O2~-m32";
else
msg = "make COPTS=-O2";
try { sh(msg); }
catch (Status e) {
out(WARN,"Error in compilation stage.");
ret = WARN;
break;
}
}
if (switch_sysinfo_link(targetdir,i) == ERROR) return ERROR;
return ret;
}
Component kbmag("kbmag",deps_onlyGAP,kbmag_prerequisites,NULL,kbmag_buildfunc);
static Status carat_buildfunc(string targetdir)
{
string topdir;
DetermineGAParchs();
try { cd("gap4r7/pkg/carat"); } catch (Status e) { return WARN; }
try {unpack("carat-2.1b1.tgz"); }
catch (Status e) {
out(ERROR,"Cannot unpack carat archive.");
return WARN;
}
try { sh("ln -sfn carat-2.1b1/bin bin"); }
catch (Status e) {
out(ERROR,"Cannot create bin link for carat package.");
return WARN;
}
try { cd("carat-2.1b1"); } catch (Status e) { return WARN; }
// Now patch the Makefile for Mac OSX:
string edscriptname;
if (Which_Architecture.str == "OSX") {
out(OK,"Patching carat for Mac OSX...");
try {
getind(targetdir, "http://gap-system.github.io/bob/carat.edit.link",
edscriptname);
}
catch (Status e) {
out(ERROR,"Could not download patch for carat.");
return WARN;
}
vector<string> edscript;
try {
readlines(edscriptname,edscript);
edscript[edscript.size()-1]
+= " -I"+targetdir+"gap4r7/bin/"+GAParchs[Double_Compile.num]+
"/extern/gmp/include"+
" -L"+targetdir+"gap4r7/bin/"+GAParchs[Double_Compile.num]+
"/extern/gmp/lib";
edit(edscript);
}
catch (Status e) {
out(ERROR,"Failed to patch carat.");
return WARN;
}
}
topdir = targetdir + "gap4r7/pkg/carat/carat-2.1b1";
try { sh("make TOPDIR="+topdir); }
catch (Status e) {
out(ERROR,"Failed to build standalone carat program.");
return WARN;
}
try { cd("bin"); } catch (Status e) { return WARN; }
vector<string> filenames;
try { listdir(".",filenames); }
catch (Status e) {
out(ERROR,"Could not read off architecture string for carat.");
return WARN;
}
size_t i;
for (i = 0;i < filenames.size();i++) {
if (filenames[i] != "Makefile" && filenames[i] != "config.guess") break;
}
if (i >= filenames.size()) {
out(ERROR,"Could not find architecture string for carat.");
return WARN;
}
string targetbin = filenames[i];
for (i = 0;i < GAParchs.size();i++)
try { sh(string("ln -sfn ")+targetbin+" "+GAParchs[i]); }
catch (Status e) {
out(ERROR,"Cannot create symbolic link to carat.");
return WARN;
}
return OK;
}
Component carat("carat",deps_onlyGAP,NULL,NULL,carat_buildfunc);
static Status xgap_prerequisites(string, Status)
{
Status res = OK;
string path;
if (Have_C_Library("-lXaw -lXmu -lXt -lXext -lX11 -lSM -lICE") != OK) {
out(WARN,"You have not enough X11 libraries installed, thus "
"XGAP cannot run.");
res = WARN;
}
if (Have_C_Header("X11/X.h") != OK ||
Have_C_Header("X11/Xlib.h") != OK ||
Have_C_Header("X11/Intrinsic.h") != OK ||
Have_C_Header("X11/Xaw/XawInit.h") != OK ||
Have_C_Header("X11/keysym.h") != OK) {
out(WARN,"You have not enough X11 headers installed, thus "
"XGAP cannot be compiled.");
res = WARN;
}
if (res != OK) {
out(WARN,"The following libraries with headers are required "
"for XGAP:");
out(WARN," libXaw libXmu libXt libXext libX11 libSM libICE");
if (Which_Architecture.str == "LINUX" &&
Which_OS_Variant.str == "apt-get") {
out(OK,"");
out(ADVICE,"You can install the necessary libraries by doing:");
out(ADVICE," apt-get install libx11-dev libxt-dev libxaw7-dev");
out(ADVICE,"with root privileges (using su or sudo).");
out(OK,"");
}
if (Which_Architecture.str == "LINUX" &&
Which_OS_Variant.str == "rpm") {
out(ADVICE,"You can install the necessary libraries from"
" the following rpm-packages:");
out(ADVICE," libX11-devel libXaw-devel libXmu-devel libXt-devel"
" libXext-devel libSM-devel libICE-devel");
out(ADVICE,"Use");
out(ADVICE," yum install libX11-devel libXaw-devel libXmu-devel "
"libXt-devel libXext-devel \\ ");
out(ADVICE," libSM-devel libICE-devel");
out(ADVICE,"with root privileges (using su or sudo).");
out(OK,"");
}
if (Which_Architecture.str == "OSX") {
out(OK,"");
if (which("port",path)) {
out(ADVICE,"You can install the necessary additional libraries "
"by doing:");
out(ADVICE," port install xorg-libX11 xorg-libXaw");
out(ADVICE,"with root privileges (using su or sudo).");
out(OK,"");
}
if (which("brew",path)) {
out(ADVICE,"You can currently not install X11 using homebrew.");
out(OK,"");
}
if (which("fink",path)) {
out(ADVICE,"You can install the necessary additional libraries "