-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathinstall.py
executable file
·849 lines (752 loc) · 26.7 KB
/
install.py
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
# The directories to check are: /usr/lib64, /usr/lib or /usr/lib/x86_64-linux-gnu/
import sys
import os
from os import walk
import subprocess
############################
ostype = subprocess.Popen("uname", stdout=subprocess.PIPE).stdout.read()
ostype=ostype.strip()
############################ Linux case ###########################################################################
### In the case a library is only available with a mangled name such as libboost_regex.so.1.53,
### the installer will create a "systems" directory in which symbolic links to these libraries will be created...
###################################################################################################################
versiongcc = subprocess.Popen(["gcc","-dumpversion"], stdout=subprocess.PIPE).stdout.read()
nbversion=float(versiongcc[:3])
print("GCC Version=",nbversion)
#### We check some parameters ###
def displayhelp(s):
if s!="":
print('')
print("Unknown command:", s)
print('')
print("Options:")
print(" -anaconda: anaconda path (often /opt/anaconda3)")
print(" -withsound: Compile with sound support")
print(" -noregex: Do not compile with regular expression support")
print(" -pathregex path: Path to regex include files")
print(" -pythonpath path: Path to Python library")
print(" -pythoninclude path: Path to Python include files")
print(" -pythonversion name: Python version (example: 2.7 or 3.6)")
print(" -withgui: Compile with GUI support")
print(" -pathfltk path: path to GUI libraries (if you have a specific version of fltk1.3 in a different directory than /usr/lib)")
print(" -withfastint: Compile with fast int")
print(" -intel: Compile with Intel Intrinsics instruction to speed up string conversion and string search. It impacts 'conversion.cxx' compiling...")
print(" -avx: Compile with Intel Intrinsics instruction to speed up string conversion and string search (same as intel)")
print(" -avx2: Compile with more advanced Intel Intrinsics instruction to speed up string conversion and string search")
print(" -java: Prepare compiling to java")
print(" -garbagescan: Activate memory scan for memory leaks")
print(" -gccversion: Directory names for intermediate and final files depend on local gcc version")
print(" -version name: Directory names for intermediate and final files depend on name (do not use with gccversion)")
print(" -pathlib path: provides a system path to check for system libraries")
print(" -static: favor static libraries over dynamic libraries when ambiguity. The default behaviour is to select dynamic libraries.")
print(" -forcejpeg: force the compiling with jpeg")
print(" -help: display this help")
print('')
exit(-1)
selectstatic = False
withsound=False
gccversion=False
noregex=False
withgui=False
withfastint=False
regexpath=""
compilejava=False
guipath=None
pythoninclude=None
pythonpath=None
pythonversion="python2.7"
anaconda = None
versionname=None
libpath="/usr"
i=1
avx=False
avx2=False
forcejpeg = False
garbagescan = False;
compilelibs="""
amaps: install
$(MAKE) -C allmaps all
libs: install
$(MAKE) -C allmaps all
$(MAKE) -C pdf all
$(MAKE) -C liblinear linear
$(MAKE) -C lispe tamgulispe
$(MAKE) -C libword2vec word2vec
$(MAKE) -C libwapiti wapiti
$(MAKE) -C libpython pytamgu
"""
cleanlibs="""
cleanlibs:
$(MAKE) -C allmaps clean
$(MAKE) -C pdf clean
$(MAKE) -C libpython clean
$(MAKE) -C liblinear clean
$(MAKE) -C lispe clean
$(MAKE) -C libword2vec clean
$(MAKE) -C libwapiti clean
"""
while i < len(sys.argv):
if sys.argv[i]=="-forcejpeg":
forcejpeg = True
elif sys.argv[i]=="-java":
compilejava=True
elif sys.argv[i]=="-garbagescan":
garbagescan = True
elif sys.argv[i]=="-withsound":
withsound=True
elif sys.argv[i]=="-intel" or sys.argv[i] == "-avx":
avx=True
elif sys.argv[i]=="-static":
selectstatic=True
elif sys.argv[i]=="-avx2":
avx=True
avx2=True
elif sys.argv[i]=="-gccversion":
if versionname != None:
print("It is either gccversion or version, not both")
exit(-1)
gccversion=True
elif sys.argv[i]=="-noregex":
noregex=True
elif sys.argv[i]=="-withgui":
withgui=True
elif sys.argv[i]=="-withfastint":
withfastint=True
elif sys.argv[i]=="-help":
displayhelp("")
elif sys.argv[i]=="-version":
if gccversion == True:
print("It is either gccversion or version, not both")
exit(-1)
if i >= len(sys.argv):
print("Missing name")
exit(-1)
versionname=sys.argv[i+1]
versiongcc="."+versionname
gccversion = True
i+=1
elif sys.argv[i]=="-anaconda":
if i >= len(sys.argv):
print("Missing anaconda path on command line")
exit(-1)
anaconda = sys.argv[i+1]
i+=1
elif sys.argv[i]=="-pythoninclude":
if i >= len(sys.argv):
print("Missing python include path on command line")
exit(-1)
pythoninclude=sys.argv[i+1]
i+=1
elif sys.argv[i]=="-pythonpath":
if i >= len(sys.argv):
print("Missing python path on command line")
exit(-1)
pythonpath=sys.argv[i+1]
i+=1
elif sys.argv[i]=="-pythonversion":
if i >= len(sys.argv):
print("Missing python version on command line")
exit(-1)
pythonversion="python"+sys.argv[i+1]
i+=1
elif sys.argv[i]=="-pathfltk":
if i >= len(sys.argv):
print("Missing GUI path on command line")
exit(-1)
guipath=sys.argv[i+1]
i+=1
elif sys.argv[i]=="-pathregex":
if i >= len(sys.argv):
print("Missing regex path on command line")
exit(-1)
regexpath="-I"+sys.argv[i+1]
i+=1
elif sys.argv[i]=="-pathlib":
if i >= len(sys.argv):
print("Missing library path on command line")
exit(-1)
libpath=sys.argv[i+1]
i+=1
else:
displayhelp(sys.argv[i])
i+=1
versiongcc=versiongcc.strip()
############################ MAC OS case...
if ostype==b"Darwin":
compilelibs = """
libs: install
$(MAKE) -C allmaps all
$(MAKE) -C libpython pytamgu
$(MAKE) -C libsqlite sqlite
$(MAKE) -C libcurl curl
$(MAKE) -C libxml xml
$(MAKE) -C lispe tamgulispe
$(MAKE) -C liblinear linear
$(MAKE) -C libword2vec word2vec
$(MAKE) -C libwapiti wapiti
$(MAKE) -C pdf all
"""
cleanlibs = """
cleanlibs:
$(MAKE) -C allmaps clean
$(MAKE) -C libpython clean
$(MAKE) -C libsqlite clean
$(MAKE) -C libcurl clean
$(MAKE) -C libxml clean
$(MAKE) -C liblinear clean
$(MAKE) -C lispe clean
$(MAKE) -C libword2vec clean
$(MAKE) -C libwapiti clean
$(MAKE) -C pdf clean
"""
incpath = "INCLUDEPATH=-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2"
if withsound:
compilelibs += "\t$(MAKE) -C libsound sound\n"
cleanlibs += "\t$(MAKE) -C libsound clean\n"
incpath += " -Iinclude/macos/ao"
ostype = subprocess.Popen(["uname", "-a"], stdout=subprocess.PIPE).stdout.read()
if withgui:
compilelibs += "\t$(MAKE) -C libgui all\n"
cleanlibs += "\t$(MAKE) -C libgui clean\n"
if b"arm64" in ostype.lower():
incpath += " -Iinclude/macarm/fltk"
else:
incpath += " -Iinclude/macos/fltk"
incpath += "\n"
compilelibs += "\n\n"
cleanlibs += "\n\n"
if b"arm64" in ostype.lower():
mac_os = "arm"
obuild=open('java/build.base')
txt=obuild.read()
obuild.close()
txt = txt.replace("mac.java", "arm.java")
txt = txt.replace('value="mac"', 'value="arm"')
if garbagescan:
txt = txt.replace('<!--compilerarg value="-DGARBAGESCAN" location="start"/-->', '<compilerarg value="-DGARBAGESCAN" location="start"/>')
wbuild = open("java/build.xml","w")
wbuild.write(txt)
wbuild.close()
else:
mac_os = "mac"
obuild=open('java/build.base')
txt=obuild.read()
if garbagescan:
txt = txt.replace('<!--compilerarg value="-DGARBAGESCAN" location="start"/-->', '<compilerarg value="-DGARBAGESCAN" location="start"/>')
obuild.close()
wbuild = open("java/build.xml","w")
wbuild.write(txt)
wbuild.close()
vname = "mac"
if compilejava:
if mac_os == "arm":
vname = "arm.java"
else:
vname = "mac.java"
f=open("Makefile.in","w")
print("MAC OS", vname)
f.write("COMPPLUSPLUS = clang++\n")
f.write("Optim = -Ofast\n")
f.write("COMP = clang\n")
f.write("BINPATH = bin/"+vname+"\n")
f.write("OBJPATH = objs/"+vname+"\n")
f.write("LIBOBJPATH = libobjs/"+vname+"\n")
f.write(incpath)
MACLIBS= "MACLIBS= -framework Cocoa -framework AudioToolbox -framework AudioUnit -framework CoreAudio -framework ScreenCaptureKit\n"
if compilejava:
if garbagescan:
f.write("MULTIGA=-stdlib=libc++ -DMULTIGLOBALTAMGU -DGARBAGESCAN\n");
else:
f.write("MULTIGA=-stdlib=libc++ -DMULTIGLOBALTAMGU\n");
f.write("# MAC OS support\n")
f.write(compilelibs)
f.write(cleanlibs)
f.write(MACLIBS)
f.write("SYSTEMSPATH = -Llibs/macos -L../libs/macos\n")
f.write("TAMGUCONSOLENAME = tamgu\n")
if withgui:
if mac_os == "arm":
f.write("FLTKLIBS=-Llibs/macarm -lfltk -lfltk_images -lfltk_jpeg\n")
else:
f.write("FLTKLIBS=-Llibs/macos -lfltk -lfltk_images\n")
f.write("JPEGLIB = -lfltk_jpeg\n\n")
if withsound:
f.write("SOURCEMM = macsound.mm\n")
f.write("OBJECTLIBMM = $(SOURCEMM:%.mm=$(LOBJPATH)/sound/%.o)\n")
f.write("LIBSOUND=-lao -lsndfile\n")
f.write("SOUNDFILE=tamgusound.cxx tamgump3.cxx\n")
f.write("SOUNDFLAG= -DTamguSOUND -DMACSOUND -Iinclude/macos -Iinclude/macos/ao\n")
f.write("FLAGMPG123=-DUSEMPG123\n")
f.write("LIBMPG123=-lmpg123\n\n")
f.write("#Python\n")
if pythonversion=="python2.7":
f.write("INCLUDEPYTHON = -I/System/Library/Frameworks/Python.framework/Versions/Current/include/python2.7\n")
f.write("PYTHONLIB = /System/Library/Frameworks/Python.framework/Versions/Current/Python\n\n")
else:
pversion=pythonversion[6:]
if anaconda != None:
if anaconda[-1] != '/':
anaconda += '/'
f.write("INCLUDEPYTHON = -I"+anaconda+"include/python"+pversion+"\n")
f.write("FORLINK = -undefined dynamic_lookup\n")
f.write("PYTHONLIB = $(FORLINK) -L"+anaconda+"lib -lpython"+pversion+"\n")
f.write("# See: 'https://github.com/shogun-toolbox/shogun/issues/4068' for an explanation of the following line\n")
else:
if pythoninclude==None:
f.write("INCLUDEPYTHON = -I/Library/Frameworks/Python.framework/Headers\n")
else:
f.write("INCLUDEPYTHON = "+pythoninclude+"\n")
if pythonpath==None:
if anaconda == None:
f.write("PYTHONLIB = /Library/Frameworks/Python.framework/Python\n")
else:
f.write("PYTHONLIB = "+pythonpath+"\n")
# AVX instructions are not available on arm64 machines
if mac_os == "arm":
if compilejava:
f.write("C++11Flag = -std=c++14 -DTamgu_REGEX -DMAVERICK -DAPPLE\n")
else:
f.write("C++11Flag = -std=c++14 -DTamgu_REGEX -mavx2 -DMAVERICK -DAPPLE\n") # -DFLTK14 when ready
f.write("INTELINT =\n")
else:
if compilejava:
f.write("C++11Flag = -std=c++14 -DTamgu_REGEX -DMAVERICK -DAPPLE\n")
f.write("INTELINT =\n")
else:
f.write("C++11Flag = -std=c++14 -DTamgu_REGEX -DMAVERICK -DAPPLE\n")
f.write("INTELINT = -DINTELINTRINSICS -mavx2 -DAVXSUPPORT\n")
f.close()
print("You can launch 'make all libs' now")
sys.exit(0)
##############################################
sourcegui = ""
if guipath != None:
sourcegui = "GUIPATH=-L"+guipath+"\nFLTKX11LIBS = -lXext -lXft -lXinerama -lX11 -lfontconfig -lXfixes -lXcursor\n"
v=['libfltk', 'libfltk_images', 'libfltk_jpeg', 'libcurl', 'libboost_regex', 'libxml2', 'libssl',
'libsqlite3', 'libmpg123', 'libao', 'libsndfile', 'libldap','libcrypto','libldap', 'libgmp', "lib"+pythonversion,
"libXext", "libXrender", "libXft", "libXinerama", "libX11", "libfontconfig", "libXfixes", "libXcursor"]
def traverse(libpath):
for (dirpath, dirnames, filenames) in walk(libpath):
for s in filenames:
if "libgcc" in s:
return libpath
for d in dirnames:
s=traverse(libpath+d+"/")
if s!=None:
return s
return None
#### We look for the library path that contains all our libraries
##if libpath=="/usr":#we look for libgcc
## print("Looking into /usr/lib/x86_64-linux-gnu/")
## libpath=traverse("/usr/lib/x86_64-linux-gnu/")
## if libpath==None:
## print("Looking into /usr/lib64/")
## libpath=traverse("/usr/lib64/")
## if libpath==None:
## print("Looking into /usr/lib/")
## libpath=traverse("/usr/lib/")
## if libpath==None:
## sys.exit(0)
############################
### We check the system path lib directories for the requested libraries
if libpath[-1] != '/':
libpath+='/'
if libpath == "/usr/":
libpaths = ["/usr/lib/x86_64-linux-gnu/","/usr/lib64/","/usr/lib/", "/usr"]
else:
libpaths = [libpath, "/usr/lib/x86_64-linux-gnu/","/usr/lib64/","/usr/lib/"]
f = []
libpath = None
for lb in libpaths:
fd = []
for (dirpath, dirnames, filenames) in walk(lb):
fd.extend(filenames)
break
if guipath != None:
for (dirpath, dirnames, filenames) in walk(guipath):
fd.extend(filenames)
break
if fd != []:
if len(fd) > len(f):
f = fd
libpath = lb
if libpath == None:
exit(0)
print("Investigating:",libpath )
for s in f:
if s in v:
v.remove(s)
found={}
ret=[]
for s in v:
for libname in f:
if s in libname:
if s in found:
###we favor dynamic libraries over static ones...
checklib = ".a"
checkfound = ".so"
if selectstatic:
checklib = ".so"
checkfound = ".a"
if checklib in libname and checkfound in found[s]:
continue
if checkfound in libname and checklib in found[s]:
found[s] = libname
elif len(libname) < len(found[s]):
found[s]=libname
else:
found[s]=libname
ret.append(s)
for s in ret:
while s in v:
v.remove(s)
### If we have some mangled names, we need to create a "systems" directory
### to store symbolic links to them, which will be used to link our final application
os.system("mkdir -p systems")
if "libcurl" in found:
compilelibs += " $(MAKE) -C libcurl curl\n"
cleanlibs += " $(MAKE) -C libcurl clean\n"
if "libsqlite3" in found:
compilelibs += " $(MAKE) -C libsqlite sqlite\n"
cleanlibs += " $(MAKE) -C libsqlite clean\n"
if "libxml2" in found:
compilelibs += " $(MAKE) -C libxml xml\n"
cleanlibs += " $(MAKE) -C libxml clean\n"
objpath=None
javalibpath=None
if gccversion:
if compilejava:
objpath='objs/linux'+versiongcc
print(objpath)
javalibpath='<property name="platformArch" value="linux'+versiongcc+'" />'
print(javalibpath)
os.system("mkdir -p systems/linux"+versiongcc)
for u in found:
if ".a" not in found[u] and ".dylib" not in found[u]:
ky = u
if u == "libfltk":
sourcegui += "\nFLTKLIBS=-lfltk1.3 -lfltk_images\n"
ky += "1.3"
command="rm systems/linux"+versiongcc+"/"+ky+".so"
os.system(command)
command="ln -s "+libpath+found[u]+" systems/linux"+versiongcc+"/"+ky+".so"
os.system(command)
elif ".a" in found[u] and u == "libfltk":
sourcegui += "\nFLTKLIBS= -Wl,-Bstatic -lfltk -lfltk_images -Wl,-Bdynamic\n"
if "FLTKX11LIBS" not in sourcegui:
sourcegui += "\nFLTKX11LIBS = -lXext -lXft -lXinerama -lXrender -lX11 -lfontconfig -lXfixes -lXcursor\n"
else:
for u in found:
if ".a" not in found[u] and ".dylib" not in found[u]:
ky = u
if u == "libfltk":
sourcegui += "\nFLTKLIBS=-lfltk1.3 -lfltk_images\n"
ky += "1.3"
command="rm systems/"+ky+".so"
os.system(command)
command="ln -s "+libpath+found[u]+" systems/"+ky+".so"
os.system(command)
elif ".a" in found[u] and u == "libfltk":
sourcegui += "\nFLTKLIBS= -Wl,-Bstatic -lfltk -lfltk_images -Wl,-Bdynamic\n"
if "FLTKX11LIBS" not in sourcegui:
sourcegui += "\nFLTKX11LIBS = -lXext -lXft -lXinerama -lXrender -lX11 -lfontconfig -lXfixes -lXcursor\n"
############################
f=open("Makefile.in","w")
f.write("TAMGUCONSOLENAME = tamguconsole\n")
f.write("Optim = -O3\n")
f.write("# Uncomment the next line, if mouse does not work in the editor\n")
f.write("# MOUSESUPPORT = -DXTERM_MOUSE_VT100\n")
if avx2:
f.write("INTELINT = -DINTELINTRINSICS -msse4.2 -mavx2 -DAVXSUPPORT\n")
elif avx:
f.write("INTELINT = -DINTELINTRINSICS -msse4.1\n")
f.write("COMPPLUSPLUS = g++\n")
f.write("COMP = gcc\n")
if gccversion:
f.write("BINPATH = bin/linux"+versiongcc+"\n")
f.write("OBJPATH = objs/linux"+versiongcc+"\n")
f.write("LIBOBJPATH = libobjs/linux"+versiongcc+"\n")
f.write("SYSTEMSPATH = -L../systems/linux"+versiongcc+" -Lsystems/linux"+versiongcc+" -L"+libpath+"\n")
else:
f.write("BINPATH = bin/linux\n")
f.write("OBJPATH = objs/linux\n")
f.write("LIBOBJPATH = libobjs/linux\n")
f.write("SYSTEMSPATH = -L../systems -Lsystems -Llibs/linux -L"+libpath+"\n")
############################
if compilejava:
if garbagescan:
f.write("MULTIGA=-DMULTIGLOBALTAMGU -DGARBAGESCAN\n");
else:
f.write("MULTIGA=-DMULTIGLOBALTAMGU\n");
############################
specflags="SPECFLAGS =";
if not withfastint:
specflags+=" -DNOFASTTYPE"
#We cannot use the CODECVT include to read/write UTF16 files...
if nbversion<= 5.1:
specflags+=" -DNOCODECVT"
if specflags!="SPECFLAGS =":
specflags+="\n"
f.write(specflags)
############################
if len(v)!=0:
print("--------------------------------")
print('')
print("Missing libraries:", v)
if "libfltk" in v or withgui==False:
print('')
print("Sorry tamgu will have no GUI functionalities. Install FLTK package for GUI features...")
withgui=False
if withgui:
f.write(sourcegui)
compilelibs += " $(MAKE) -C libgui all\n"
cleanlibs += " $(MAKE) -C libgui clean\n"
############################
if anaconda != None:
if anaconda[-1] != '/':
anaconda += '/'
pversion=pythonversion[6:]
f.write("INCLUDEPYTHON = -I"+anaconda+"include/python"+pversion+"\n")
f.write("PYTHONLIB = -L"+anaconda+"lib -lpython"+pversion+"\n")
print('')
print("You can compile the pytamgu library, based on anaconda")
print('')
elif pythoninclude!=None:
f.write("\n\n#Python support to compile tamgu python library: 'pytamgu'\n")
f.write("INCLUDEPYTHON = -I"+pythoninclude+"\n")
f.write("PYTHONLIB = -l"+pythonversion+"\n")
print('')
print("You can compile the pytamgu library (tamgu python library)")
print('')
elif pythonversion not in v:
f.write("\n\n#Python support to compile tamgu python library: 'pytamgu'\n")
for (dirpath, dirnames, filenames) in walk("/usr/include"):
if pythonversion in dirnames:
f.write("INCLUDEPYTHON = -I/usr/include/"+pythonversion+"\n")
f.write("PYTHONLIB = -l"+pythonversion+"\n")
print('')
print("You can compile the pytamgu library (tamgu python library)")
print('')
else:
f.write("INCLUDEPYTHON = \n")
f.write("PYTHONLIB = -l"+pythonversion+"\n")
print('')
print("Could not find python 2.7 include and library paths. ")
print("Modify 'INCLUDEPYTHON' and 'PYTHONLIB' in Makefile.in if you want to compile pytamgu (the tamgu python library)")
print('')
break
if pythonpath != None:
f.write("PYTHONPATH = -L"+pythonpath+"\n")
############################
includepath="INCLUDEPATH = -Iinclude/linux"
############################
jpegflag="#JPEGFLAG = -DFLTKNOJPEG"
jpeglib="#JPEGLIB = -lfltk_jpeg"
if "libfltk_jpeg" not in v or forcejpeg:
jpeglib=jpeglib.replace("#","")
else:
jpegflag=jpegflag.replace("#","")
print("No fltk_jpeg library available")
f.write("\n\n# JPEG support\n")
f.write(jpegflag+"\n")
f.write(jpeglib+"\n")
f.write("\n")
############################
flagmpg123="""
#FLAGMPG123=-DUSEMPG123
#LIBMPG123=-lmpg123
"""
if withsound==True:
if "libmpg123" not in v:
flagmpg123=flagmpg123.replace("#","")
else:
print("MPG123 will not be available in tamgu")
f.write("# MPG3 support")
f.write(flagmpg123)
f.write("\n")
############################
soundao="""
#LIBAO=-lao
#LIBSOUNDFILE=-lsndfile
"""
soundflag="""
#LIBSOUND=$(LIBAO) $(LIBSOUNDFILE)
#SOUNDFILE=tamgusound.cxx
#SOUNDFLAG= -DTamguSOUND
"""
if withsound==True:
sndbool=False
compilelibs += " $(MAKE) -C libsound sound\n"
cleanlibs += " $(MAKE) -C libsound clean\n"
if "libao" not in v:
soundao=soundao.replace("#LIBAO","LIBAO")
soundflag=soundflag.replace("#","")
includepath+=" -Iinclude/linux/ao"
sndbool=True
if "libsndfile" not in v:
soundao=soundao.replace("#LIBSOUNDFILE","LIBSOUNDFILE")
soundflag=soundflag.replace("#","")
includepath+=" -Iinclude/linux/ao"
if not sndbool:
print("No sound available")
else:
f.write("# SOUND (ao and sndfile) support")
f.write(soundao)
f.write(soundflag)
f.write("\n")
############################
sslflag="""
#SSLLIB= -lssl
"""
if "libssl" not in v:
sslflag=sslflag.replace("#","")
f.write("# SSL support")
f.write(sslflag)
f.write("\n")
############################
cryptoflag="""
#CRYPTOLIB= -lcrypto
"""
if "libcrypto" not in v:
cryptoflag=cryptoflag.replace("#","")
f.write("# CRYPTO support")
f.write(cryptoflag)
f.write("\n")
############################
gmpflag="""
#GMPLIB= -lgmp
"""
if "libgmp" not in v:
gmpflag=gmpflag.replace("#","")
f.write("# GMP support")
f.write(gmpflag)
f.write("\n")
############################
f.write(includepath+"\n")
############################
# We test now if the compiler onboard is compatible with C++11 norm
#C++11Flag = -std=c++0x
#C++11Flag = -std=gnu++0x
#C++11Flag = -std=c++11
pathtest= os.getcwd()
if pathtest[-1]!='/':
pathtest+='/src/testcompile.cxx'
else:
pathtest+='src/testcompile.cxx'
command=["g++","-std=c++11",pathtest]
ostype = subprocess.call(command)
if ostype:
command[1]="-std=c++0x"
ostype = subprocess.call(command)
if ostype:
command[1]="-std=gnu++0x"
ostype = subprocess.call(command)
if ostype:
print('')
print('')
print("Error: You need a compiler compatible with C++11")
print('')
sys.exit(-1)
f.write("\n# Compiler C++11 option\n")
f.write("C++11Flag = "+command[1]+"\n")
############################
regexflag="""
#REGEXFLAG = %%%
#REGEX=-DTamgu_REGEX $(REGEXFLAG)
"""
regexflag+="#LIBREGEX= -lboost_regex\n"
#Properties...
p1='<!--property name="regexcpp" value="true" /-->'
p2='<!--property name="regexboost" value="true" /-->'
p3='<!--property name="nofastype" value="true" /-->'
p4='<!--property name="nocodecvt" value="true" /-->'
rep1='<property name="regexcpp" value="true" />'
rep2='<property name="regexboost" value="true" />'
rep3='<property name="nofastype" value="true" />'
rep4='<property name="nocodecvt" value="true" />'
brep1=False
brep2=False
if noregex==False:
#we check now how to include regex... either #include "boost/regex.hpp" or <regex>
pathtest= os.getcwd()
if pathtest[-1]!='/':
pathtest+='/src/testregex.cxx'
else:
pathtest+='src/testregex.cxx'
systempath="-Lsystems"
if gccversion:
systempath+="/linux"+versiongcc
cmd=["g++","-o","testregex",command[1],"-DREGEXCPP",pathtest,systempath,"-lboost_regex"]
print('')
print("------------------------------------------")
print("Warning, error messages might show as the system is checking, which version of regex is implemented on your machine.")
print("They are normal and will not prevent any actual compiling")
print('')
ostype = subprocess.call(cmd)
if ostype:
if regexpath!="":
cmd=["g++","-o","testregex",command[1],regexpath,pathtest,systempath,"-lboost_regex"]
else:
cmd=["g++","-o", "testregex",command[1],pathtest,systempath,"-lboost_regex"]
ostype = subprocess.call(cmd)
if ostype:
noregex=True
else:
print('')
print("Using boost::regex")
if compilejava:
brep2=True
if regexpath!="":
regexflag=regexflag.replace("%%%",regexpath)
else:
print('')
print("Using std::regex")
regexflag=regexflag.replace("%%%","-DREGEXCPP")
regexflag=regexflag.replace("-lboost_regex","")
if compilejava:
brep1=True
brep2=True
if compilejava:
fb=open('java/build.base')
txt=fb.read()
fb.close()
if brep1:
txt=txt.replace(p1,rep1)
if brep2:
txt=txt.replace(p2,rep2)
if brep2:
txt=txt.replace(p2,rep2)
if not withfastint:
txt=txt.replace(p3,rep3)
if nbversion<= 5.1:
txt=txt.replace(p4,rep4)
if garbagescan:
txt = txt.replace('<!--compilerarg value="-DGARBAGESCAN" location="start"/-->', '<compilerarg value="-DGARBAGESCAN" location="start"/>')
if objpath != None:
txt=txt.replace("objs/linux",objpath)
if javalibpath != None:
txt=txt.replace('<property name="platformArch" value="linux" />',javalibpath)
bsv=open('java/build.xml',"w")
bsv.write(txt)
bsv.close()
if noregex==False:
os.system("rm testregex")
regexflag=regexflag.replace("%%%","")
regexflag=regexflag.replace("#","")
else:
print("Regex will not be available in tamgu")
noregex=False
f.write("# boost regex support")
f.write(regexflag)
f.write("\n")
f.write(compilelibs)
f.write("\n")
f.write(cleanlibs)
f.write("\n")
f.close()
print('')
print('')
print("All is ok... You can compile now")
print(" 'make all' to compile main lib and executable")
print(" 'make libs' to compile the libs")
print('')