forked from difx/difx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-difx
executable file
·1071 lines (959 loc) · 35.6 KB
/
install-difx
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 python
from __future__ import print_function
import os,sys
import getopt
import re
# Set this to true if compiling within a master_tags checkout
# make trunk go away...
master_tag = True
#master_tag = False
###############################################################################
# this function was once called main() but really it was only for help.
def help(options=False, envivars=False, examples=False):
"""
Build and Install DiFX
Usage:
install-difx [options]
Builds and installs mpifxcorr and associated tools. If invoked from the
setup directory, the build will be within the source directory heirarchy,
otherwise the build will be made within the current directory.
By default install-difx will build and install the essential DiFX tools,
but stop if any errors are encountered (e.g. if something fails to build).
For the standard libraries and applications, build-difx will try to run
autoreconf first. If this fails, step by step configuration will be tried.
Remember, if you haven't signed up to the difx-users mailing list,
please do so at https://listmgr.nrao.edu/mailman/listinfo/difx-users.
For help with the (large number of options):
install-difx --help-options
"""
if options:
print("""
The install-difx options are:
-f --force Carry on regardless of any errors (all failed commands
will be listed at the end.)
-h --help Display this help message and quit.
-v --verb Provide more chatter about progress.
--mk5daemon Install mk5daemon (not installed by default)
--perl Install some non-standard perl utilities (deprecated)
--withmonitor Try to build the difx_monitor application (requires pgplot)
--withfb Build filterbank (which requires pgplot)
--withguiserver Build guiServer
--withhops Build HOPS (which requires pgplot)
--withm6support Build Mark6 support (which requires FUSE)
--withmark6meta Build Mark6 metadata support
--withpolconvert Build PolConvert (which requires CASA)
--withpython Build Python bindings for certain libraries (requires ctypes)
--withdatasim Build the datasim application (requires gsl)
--noinstall Don't install, only build.
--reconf Reconfigure step by step rather than with autoreconf
--noconf Assume existing configuration is correct
--clean Run make clean for all components
--g77 Use g77, rather than gfortran
--extraflags='flags' Add 'flags' to each of the CFLAGS, CXXFLAGS, and
FFLAGS environment variables
--makeflags='flags' Add 'flags' to each direct call of the make program,
(so you can do make -j 4 to speed up compilation)
--noipp Don't try and install ipp package config file, and
also disable IPP acceleration of mpifxcorr
--ipp Force installation of ipp package config file
(default doesn't overwrite existing)
--nodoc Don't build the documentation
--cache='name' Speeds up the configuration using cache files
'name' and 'name-CXX' in the build directory
--targ='...' Runs make ... on each of the components.
The default is 'all'.
--pristine Removes auto-built sources from source directories
(and implies --clean)
--doonly='...' Will only build the components specified in the list ...,
where ... is a comma-separated list of sub-packages in
["perl", "difxio", "difxmessage", "mark5access", "vdifio",
"calcif2", "difx2profile", "misc","vis2screen",
"calcserver", "difx2fits", "vex2difx", "difx2mark4",
"mpifxcorr", "difxfilterbank", "hops", "m6support",
"polconvert", "guiServer", "mk5daemon", "difx_monitor",
"datasim", "difxcalc11", "mark6sg", "mark6meta"]
--skip='...' Does a normal build, but skips components in a comma
separated list (drawn from the --doonly list).
--also='...' Does a normal build, but adds components in a comma
separated list (drawn from the --doonly list).
--newver='...' changes the source directory used on a per component
basis (from what would otherwise be used). This comma
separated list (of changes) should contain ':' paired
component name and new version. Usually the new version
code lies on a branch somewhere, rather than 'trunk'
""")
if envivars:
print("""
The following environment variables are essential to the build process.
They are usually set up if you source the "setup-difx.bash" script (which
must perhaps be adapted to your local circumstances):
DIFX_VERSION master tag "DiFX-2.6.2", &c., or "trunk" for developers
DIFXROOT absolute path to specify where the build products
are to be installed. If you build outside of the
source tree, you may then remove the build directory
MPICXX used to specify the C++ MPI-enabled compiler
IPPROOT path to the IPP tools, used to create the ipp.pc
pkgconfig file.
PKG_CONFIG_PATH where pkg-config should find .pc files. This script
sets it to a directory within the build area which is
prepended to what is supplied by the environment.
Optional variables:
PGPLOTDIR for the tools that require it, the location of the
PGPLOT installed tools.
DIFX_REPLDIR_PATH allows a replacement to the normal choice for the
directory in which to build, perhaps with different
compilation options set. See the script for details.
The following environment variables are no longer used by this script,
but exceptions will be raised if they are missing. (The configure process
that this script invokes may make use of these.)
DIFXBITS required by genipp
IPPLIB32 required by (deprecated) pulseprofile
IPPLIB64 required by (deprecated) pulseprofile
""")
if examples:
print("""
For example Haystack usually builds with:
path-to-setup/install-difx -v --ipp --cache=difx-config-cache \
--reconf --force --withhops --withm6support --withpolconvert
""")
###############################################################################
# Parse command line options and arguments
# When adding an option or argument
# * Make sure a default is set
# * Make sure it is documented in help.__doc__
###############################################################################
try:
opts, args = getopt.gnu_getopt(sys.argv[1:], "fhv",
["force", "help", "verb",
"help-options", "help-environment", "help-examples",
"mk5daemon", "withmonitor", "withdatasim", "perl", "withfb",
"withhops", "withm6support", "withguiserver", "withpython",
"withpolconvert", "noinstall", "reconf", "noconf", "clean",
"g77", "extraflags=", "makeflags=", "withmark6meta",
"noipp", "ipp", "nodoc", "cache=", "targ=", "pristine",
"doonly=", "skip=", "also=", "newver=", ])
except getopt.GetoptError as err:
print(err)
print(help.__doc__)
sys.exit(2)
if not 0 <= len(args) <= 0:
print("Error: Wrong number of Arguments")
print(help.__doc__)
sys.exit(2)
# set defaults
force = False
reconf = False
noinstall = False
gfortran = True
extraflags = None
MAKEcommand = "make "
doclean = False
target = 'all'
verb = False
cache = 'none'
errors = []
noconf = False
pristine = False
dodoc = True
dopybindings = False
doipp = 0
orgcwd = os.getcwd()
components = {"perl" :False,
"difxio" :True,
"codifio" :True,
"difxmessage" :True,
"dirlist" :True,
"mark5access" :True,
"mark6meta" :False,
"vdifio" :True,
"calcif2" :False,
"difxcalc11" :True,
"difx2profile" :True,
"misc" :True,
"vis2screen" :True,
"calcserver" :False,
"difx2fits" :True,
"vex2difx" :True,
"difx2mark4" :False,
"mpifxcorr" :True,
"mark6sg" :False,
"difxfilterbank":False,
"hops" :False,
"m6support" :False,
"polconvert" :False,
"guiServer" :False,
"mk5daemon" :False,
"difx_monitor" :False,
"datasim" :False,
"python" :True,
}
def setNormalComponentsFalse():
global components
components["difxio"] = False
components["difxmessage"] = False
components["dirlist"] = False
components["mark5access"] = False
components["mark6meta"] = False
components["codifio"] = False
components["vdifio"] = False
components["calcif2"] = False
components["difx2profile"] = False
components["misc"] = False
components["vis2screen"] = False
components["calcserver"] = False
components["difxcalc11"] = False
components["difx2fits"] = False
components["vex2difx"] = False
components["difx2mark4"] = False
components["hops"] = False
components["polconvert"] = False
components["mpifxcorr"]= False
components["mark6sg"]= False
components["python"]= False
def setOnlyComponents(only):
global components
setNormalComponentsFalse()
array = only.strip().split(',')
if(len(array)==0):
raise RuntimeError( "Could not find components to build " +
"in only argument '%s'"%only)
for a in array:
c = a.strip()
if(c in components):
components[c] = True
if(c == "python"):
dopybindings = True
else:
if (c != ''): raise RuntimeError(
"Unrecognized only component '%s'" % (a))
def setSkipComponents(skip):
global components
array = skip.strip().split(',')
if(len(array)==0):
raise RuntimeError("--skip invoked without a list")
for a in array:
c = a.strip()
if(c in components):
components[c] = False
if(c == "python"):
dopybindings = False
else:
raise RuntimeError("Unknown skip component '%s'"%(a))
def setAlsoComponents(also):
global components
array = also.strip().split(',')
if(len(array)==0):
raise RuntimeError("--also invoked without a list")
for a in array:
c = a.strip()
if(c in components):
components[c] = True
if(c == "python"):
dopybindings = True
else:
raise RuntimeError("Unknown also component '%s'"%(a))
adjustments=dict()
def newVersionComponents(changes):
global components
adjusts = changes.strip().split(',')
if(len(adjusts)==0):
raise RuntimeError("--newver invoked without a list")
for a in adjusts:
try:
com,ver = a.split(':')
except:
raise RuntimeError("elements must be pairs of component:path")
if(com in components):
adjustments[com] = ver
else:
raise RuntimeError("%s is not a component"%com)
# read options
if len(opts) > 0:
for o, a in opts:
if o in ("-f", "--force"):
force = True
if o in ("-h", "--help"):
print(help.__doc__)
sys.exit(0)
if o == "--help-options":
help(options=True)
sys.exit(0)
if o == "--help-environment":
help(envivars=True)
sys.exit(0)
if o == "--help-examples":
help(examples=True)
sys.exit(0)
if o in ("-v", "--verb"):
verb = True
if o == "--mk5daemon":
components["mk5daemon"] = True
if o == "--withmonitor":
components["difx_monitor"] = True
if o == "--withdatasim":
components["datasim"] = True
if o == "--perl":
components["perl"] = True
if o == "--withfb":
components["difxfilterbank"] = True
if o == "--withhops":
components["hops"] = True
if o == "--withm6support":
components["m6support"] = True
if o == "--withmark6meta":
components["mark6meta"] = True
if o == "--withpolconvert":
components["polconvert"] = True
if o == "--withguiserver":
components["guiServer"] = True
if o == "--withpython":
dopybindings = True
if o == "--noinstall":
noinstall = True
if o == "--reconf":
reconf = True
if o == "--noconf":
noconf = True
reconf = True
if o == "--clean":
doclean = True
if o == "--nodoc":
dodoc = False
if o == "--g77":
gfortran = False
if o == "--extraflags":
extraflags = a
if o == "--makeflags":
MAKEcommand += a + ' '
if o == "--ipp":
doipp = 1
if o == "--noipp":
doipp = -1
if o == "--cache":
cache = a
if o == "--targ":
target = a
noinstall = True
if o == "--pristine":
pristine = True
doclean = True
force = True
if o == "--doonly":
setOnlyComponents(a)
if o == "--skip":
setSkipComponents(a)
if o == "--also":
setAlsoComponents(a)
if o == "--newver":
newVersionComponents(a)
###### Get all relevant environment variables ###########
print("************************************")
print("Getting environmental variables")
print()
difxroot = os.environ.get('DIFXROOT')
if not difxroot:
raise RuntimeError("DIFXROOT must be defined")
if not re.match("/",difxroot):
raise RuntimeError("DIFXROOT must be an absolute path")
bindir = difxroot + '/bin/'
libdir = difxroot + '/lib/'
pkgdir = difxroot + '/lib/pkgconfig/'
incdir = difxroot + '/include/'
ipproot = os.environ.get('IPPROOT')
mpicxx = os.environ.get('MPICXX')
pgplotdir = os.environ.get('PGPLOTDIR')
platform = sys.platform
### these do not seem to be used by the script directly
difxbits = os.environ.get('DIFXBITS')
ipplib32 = os.environ.get('IPPLIB32')
ipplib64 = os.environ.get('IPPLIB64')
if(extraflags is not None):
###### Get all relevant environment variables ###########
print("************************************")
print("Setting environmental variables")
print()
for ftype in ["CFLAGS", "CXXFLAGS", "FFLAGS"]:
thisflags = extraflags
if(ftype in os.environ):
thisflags = os.environ[ftype] + ' ' + extraflags
os.environ[ftype] = thisflags
##### Check that appropriate setup has been done ########
if not master_tag:
if os.environ.get('DIFX_VERSION') == None:
print("You must have already source'd setup.bash/setup.csh!")
print("DIFX_VERSION was undefined - aborting compilation")
raise RuntimeError("DIFX_VERSION undefined")
difx_version = os.environ.get('DIFX_VERSION')
if difx_version != "trunk":
difx_version = "branches/" + difx_version
else:
difx_version = ''
##### OSX Specific changes
if platform == "darwin":
print("Using Darwin tools")
LIBTOOLIZE = "glibtoolize"
SHAREDPOSTFIX = "dylib"
else:
LIBTOOLIZE = "libtoolize"
SHAREDPOSTFIX = "so"
if gfortran:
os.environ['USEGFORTRAN'] = 'yes'
###### Targets ####################################################
# auto_compile(doreconf, dolibtoolize, doautoheader, ..., dompicxx)
# calcif2 is a utility on trunk but an application on master tags
libtargets = []
if components["difxio"]:
libtargets.append(["difxio", difx_version, True,True,True,False])
if components["codifio"]:
libtargets.append(["codifio", difx_version, True,True,True,False])
if components["difxmessage"]:
libtargets.append(["difxmessage",difx_version, True,True,True,False])
if components["dirlist"]:
libtargets.append(["dirlist", difx_version, True,True,True,False])
if components["mark6sg"]:
libtargets.append(["mark6sg", difx_version, True,True,True,False])
if components["mark5access"]:
libtargets.append(["mark5access",difx_version, True,True,True,False])
if components["mark6meta"]:
libtargets.append(["mark6meta", difx_version, True,True,True,False])
if components["python"]:
libtargets.append(["python", difx_version, True,True,False,False])
if components["vdifio"]:
libtargets.append(["vdifio", difx_version, True,True,True,False])
utiltargets = []
if components["calcif2"] and not master_tag:
utiltargets.append(["calcif2", difx_version, True,False,True,False])
if components["difx2profile"]:
utiltargets.append([
"pulsar/difx2profile", difx_version, True,False,True,True])
if components["misc"]:
utiltargets.append(["misc", difx_version, True,False,False,False])
if components["vis2screen"]:
utiltargets.append(["vis2screen",difx_version, True,False,False,True])
apptargets = []
if components["calcif2"] and master_tag:
apptargets.append(["calcif2", difx_version, True,False,True,False])
if components["calcserver"]:
apptargets.append(["calcserver", difx_version, True,True,False,False])
if components["difxcalc11"]:
apptargets.append(["difxcalc11", difx_version, True,False,False,False])
if components["difx2fits"]:
apptargets.append(["difx2fits", difx_version, True,False,True,False])
if components["vex2difx"]:
apptargets.append(["vex2difx", difx_version, True,True,True,False])
if components["difx2mark4"]:
apptargets.append(["difx2mark4", difx_version, True,True,True,False])
if components["difxfilterbank"]:
apptargets.append(["difxfilterbank", difx_version, True,False,False,True])
if components["hops"]:
apptargets.append(["hops", difx_version, True,True,True,False])
if components["m6support"]:
apptargets.append(["m6support", difx_version, True,False,True,False])
if components["polconvert"]:
apptargets.append(["polconvert", difx_version, True,False,True,False])
if components["guiServer"]:
apptargets.append(["guiServer", difx_version, True,False,False,True])
if components["mk5daemon"]:
apptargets.append(["mk5daemon", difx_version, True,False,True,False])
if components["difx_monitor"]:
apptargets.append(["difx_monitor", difx_version, True,False,False,True])
if components["datasim"]:
apptargets.append(["datasim", difx_version, True,True,True,False])
for key in adjustments:
todo = True
if todo:
for lib in libtargets:
if lib[0] == key:
lib[1] = adjustments[key]
print("Using version %s of component %s" % (lib[1],lib[0]))
todo = False
if todo:
for util in utiltargets:
if util[0] == key:
util[1] = adjustments[key]
print("Using version %s of component %s" % (util[1],util[0]))
todo = False
if todo:
for app in apptargets:
if app[0] == key:
app[1] = adjustments[key]
print("Using version %s of component %s" % (app[1],app[0]))
todo = False
if todo:
raise RuntimeError(
"Adjustment of %s to %s was not made" % (key,adjustments[key]))
# a navigation aid
def os_chdir(dir):
os.chdir(dir)
if verb:
print("--> " + dir)
print("==> " + os.getcwd())
print()
sys.stdout.flush()
# work out build and source directories
blddir = os.getcwd()
setupdir = os.path.dirname(sys.argv[0])
if not setupdir:
setupdir = "."
os_chdir(setupdir)
# master_tags/ has no setup directory
if not master_tag:
os_chdir("..")
topdir = os.getcwd()
# think a bit about pkgconfig path
pkg_config_path = blddir + "/pkgconfig"
pkg_config_path += ":" + os.environ.get('PKG_CONFIG_PATH')
os.environ['PKG_CONFIG_PATH'] = pkg_config_path
# source dir build starts in 'setup' of the svn tree and topdir of master_tag
# inbdir is set True when the build directory differs from the source dir
if blddir == topdir + '/setup':
if verb:
print()
print("Building/Installing from the source directory")
inbdir = False
startdir = topdir + '/setup'
elif master_tag and blddir == topdir:
if verb:
print()
print("Building/Installing from the master tag source directory")
inbdir = False
startdir = topdir
else:
if verb:
print()
print("Building/Installing from the build directory:")
inbdir = True
if master_tag:
startdir = topdir
else:
startdir = topdir + '/setup'
# allow use of symbolic links in partial checkouts
repldir = os.environ.get('DIFX_REPLDIR_PATH')
if not repldir:
repldir = 'no-repldir-to-replace-with-blddir'
if verb:
print(" Replace dir: " + repldir)
if cache != 'none':
cache = ' --cache-file=' + blddir + '/' + cache
if verb:
print(" Setup dir: " + setupdir)
print(" Source dir: " + topdir)
print(" Start dir: " + startdir)
print(" Build dir: " + blddir)
print(" PkgCfg path: " + os.environ.get('PKG_CONFIG_PATH'))
print("")
###### Subroutine to run a command and raise error on non-zero return
def run(cmd):
if verb:
print("Run(" + cmd + ") in " + os.getcwd())
sys.stdout.flush()
if os.system(cmd):
if force:
errors.append(os.getcwd() + ' ' + cmd + " failed.")
else:
raise RuntimeError("Error running " + cmd + " in " + os.getcwd())
###### Subroutine to do the compiling of an auto-tool ###
def auto_compile(doreconf, dolibtoolize, doautoheader, prefix, dompicxx):
thisdir = os.getcwd() # somewhere below topdir
if (doreconf and (reconf or os.system("autoreconf -if"))):
if noconf and os.path.exists('configure'):
print("Re-using existing configuration")
else:
print("Reconfiguring step by step")
if os.path.exists('m4'):
run("aclocal -I m4")
else:
run("aclocal")
if dolibtoolize:
run(LIBTOOLIZE+" --copy --force")
run("autoconf")
if doautoheader:
run("autoheader")
run("automake -acf")
if inbdir:
cfp = thisdir
blp = cfp.replace(topdir, blddir)
blp = blp.replace(repldir, blddir)
if not os.path.exists(blp):
os.makedirs(blp)
if verb:
print("++> " + blp + " was created")
os_chdir(blp)
else:
cfp = '.'
if noconf and os.path.exists('config.status'):
print("Re-using existing configuration")
else:
configstring = cfp + "/configure --prefix=" + prefix
if cache != 'none':
configstring += cache
# configstring = cfp + "/configure --prefix=" + prefix + cache
if dompicxx:
if cache != 'none':
configstring += "-CXX"
configstring += " CXX=" + mpicxx
if dopybindings and check_configureAC_has(
cfp+"/configure.ac", "enable-python"):
configstring += " --enable-python "
if dopybindings and check_configureAC_has(
cfp+"/configure.ac", "with-python"):
configstring += " --with-python "
run(configstring)
run(MAKEcommand + target)
if not noinstall:
run(MAKEcommand + "install")
os_chdir(thisdir)
def check_configureAC_has(cfpath, key):
try:
for line in open(cfpath,'r'):
if key in line:
return True
except:
print("Warning: could not check %s for %s\n.")
return False
###### Subroutine to set up documentation area ##########
def make_doc_area(basedocdir):
print("\n**** publishing doco-index ****\n")
if not os.path.exists(basedocdir):
os.mkdir(basedocdir)
print("cp -f %s/doco-index.html %s/index.html" % (startdir, basedocdir))
os.system(
"cp -f %s/doco-index.html %s/index.html" % (startdir, basedocdir))
###### Work ##########################################
# a few of these are (randomly) svn'd...
autojunk = 'aclocal.m4 autom4te.cache compile config.guess'
autojunk += ' config.h.in config.sub configure depcomp config.status'
autojunk += ' install-sh ltmain.sh Makefile.in missing'
# autojunk += ' COPYING INSTALL'
if doclean:
if components["perl"]:
print("**** Cleaning vexlib")
os_chdir("libraries/vex/"+difx_version+"/vexlib")
run(MAKEcommand + "clean")
os_chdir(topdir)
os_chdir("libraries")
thisdir = os.getcwd()
for libtarget in libtargets:
targetdir = libtarget[0] + '/' + libtarget[1]
if not os.path.exists(targetdir):
print("**** Could not find "+targetdir+", trying Trunk")
targetdir = libtarget[0] + '/trunk/'
if os.path.exists(targetdir):
print()
print("**** Cleaning "+targetdir)
os_chdir(targetdir)
run(MAKEcommand + "-k clean distclean")
if pristine:
run("rm -rf " + autojunk)
else:
print()
print("**** Skipping "+targetdir)
print()
os_chdir(thisdir)
os_chdir(topdir)
os_chdir("applications")
thisdir = os.getcwd()
for apptarget in apptargets:
targetdir = apptarget[0] + '/' + apptarget[1]
if not os.path.exists(targetdir):
print("**** Could not find "+targetdir+", trying Trunk")
targetdir = apptarget[0] + '/trunk/'
if os.path.exists(targetdir):
print()
print("**** Cleaning "+targetdir)
os_chdir(targetdir)
run(MAKEcommand + "-k clean distclean")
if pristine:
run("rm -rf " + autojunk)
else:
print()
print("**** Skipping "+targetdir)
print()
os_chdir(thisdir)
os_chdir(topdir)
os_chdir("utilities")
thisdir = os.getcwd()
for utiltarget in utiltargets:
if utiltarget[1] == '':
targetdir = utiltarget[0]
else:
targetdir= utiltarget[1] + '/' + utiltarget[0]
if not os.path.exists(targetdir):
print("**** Could not find "+targetdir+", trying Trunk")
targetdir = utiltarget[0] + '/trunk/'
if os.path.exists(targetdir):
print()
print("**** Cleaning "+targetdir)
os_chdir(targetdir)
run(MAKEcommand + "-k clean distclean")
if pristine:
run("rm -rf " + autojunk)
else:
print()
print("**** Skipping "+targetdir)
print()
os_chdir(thisdir)
targetdir = topdir + "/mpifxcorr/" + difx_version
if not os.path.exists(targetdir):
print("**** Could not find "+targetdir+", trying Trunk")
targetdir = topdir + "/mpifxcorr/trunk/"
if os.path.exists(targetdir):
print()
print("**** Cleaning "+targetdir)
os_chdir(targetdir)
run(MAKEcommand + "-k clean distclean")
if pristine:
run("rm -rf " + autojunk)
else:
print()
print("**** Skipping "+targetdir)
print()
os_chdir(topdir)
if pristine:
run('find . -name Makefile.in -exec rm {} \;')
sys.exit(0) # Clean exit
##### Make directories if required ######################
if not noinstall:
print("************************************")
print("Setting up directories")
print()
if not os.path.exists(difxroot):
os.mkdir(difxroot)
if not os.path.exists(bindir):
os.mkdir(bindir)
if not os.path.exists(libdir):
os.mkdir(libdir)
if not os.path.exists(pkgdir):
os.mkdir(pkgdir)
if not os.path.exists(incdir):
os.mkdir(incdir)
##### Install IPP package config file if appropriate ###
if doipp<0:
print("Not installing IPP .pc file")
print()
else:
if os.path.exists(pkgdir+"/ipp.pc") and doipp==0:
print(pkgdir+"ipp.pc already exists")
print()
else:
print("Creating "+pkgdir+"ipp.pc")
os_chdir(pkgdir)
run(startdir+"/genipppc "+ipproot)
os_chdir(topdir)
print()
##### Compile non-standard libraries ####################
if components["perl"]:
print()
print("************************************")
print("Building vex")
print()
os_chdir("libraries/vex/"+difx_version+"/vexlib")
if platform == "darwin":
run(MAKEcommand + "-f Makefile.osx")
else:
run(MAKEcommand)
if not noinstall:
run("mv -f libvex." + SHAREDPOSTFIX + " " + libdir)
run("mv -f libvex.a " + libdir)
os_chdir("../vexperl")
run("perl Makefile.PL PREFIX=" + difxroot)
run(MAKEcommand)
if not noinstall:
run(MAKEcommand + "install")
os_chdir(topdir)
print()
print("************************************")
print("Building Astro Perl")
print()
os_chdir("libraries/perl/"+difx_version+"/Astro")
run("perl Makefile.PL PREFIX="+difxroot)
run(MAKEcommand)
if not noinstall:
run(MAKEcommand + "install")
os_chdir(topdir)
print()
print("************************************")
print("Building DIFX-Input Perl")
print()
os.chdir("libraries/perl/"+difx_version+"/DIFX-Input")
run("perl Makefile.PL PREFIX="+difxroot)
run(MAKEcommand)
if not noinstall:
run(MAKEcommand + "install")
os.chdir(topdir)
##### Make standard (autotool'd) libraries ###############
os_chdir("libraries")
thisdir = os.getcwd()
for libtarget in libtargets:
targetdir = libtarget[0] + '/' + libtarget[1]
if not os.path.exists(targetdir):
print("**** Could not find "+targetdir+", trying Trunk")
targetdir = libtarget[0] + '/trunk/'
if os.path.exists(targetdir):
print()
print()
print("************************************")
print("Building ", targetdir)
print()
os_chdir(targetdir)
auto_compile(libtarget[2], libtarget[3], libtarget[4],
difxroot, libtarget[5])
else:
print()
print("******* Skipping "+targetdir)
print()
os_chdir(thisdir)
os_chdir(topdir)
if components["mpifxcorr"]:
##### Make mpifxcorr #####################################
print()
print("************************************")
print("Making mpifxcorr")
print()
targetdir = "mpifxcorr/" + difx_version
if not os.path.exists(targetdir):
print("**** Could not find "+targetdir+", trying Trunk")
targetdir = 'mpifxcorr/trunk/'
os_chdir(targetdir);
thisdir = os.getcwd()
if noconf and os.path.exists('configure'):
print("Reusing mpifxcorr configuration")
else:
print("Reconfiguring mpifxcorr")
run("aclocal")
run("autoconf")
run("autoheader")
run("automake -acf")
# the files added are all present, but that need not always be true....
if inbdir:
cfp = thisdir
blp = cfp.replace(topdir, blddir)
blp = blp.replace(repldir, blddir)
if not os.path.exists(blp):
os.makedirs(blp)
if verb:
print("++> " + blp + " was created")
os_chdir(blp)
else:
cfp = '.'
if noconf and os.path.exists('config.status'):
print("Re-using existing mpifxcorr configuration")
else:
configstring = cfp + "/configure CXX=" + mpicxx
configstring += " --prefix=" + difxroot
if doipp<0:
configstring += ' --disable-ipp '
if cache != 'none':
configstring += cache + "-CXX"
run(configstring)
run(MAKEcommand + target)
if not noinstall:
run(MAKEcommand + "install")
os_chdir(topdir)
##### Make standard (autotool'd) applications ############
os_chdir("applications")
thisdir = os.getcwd()
for apptarget in apptargets:
targetdir = apptarget[0] + '/' + apptarget[1]
if not os.path.exists(targetdir):
print("**** Could not find "+targetdir+", trying Trunk")
targetdir = apptarget[0] + '/trunk/'
if os.path.exists(targetdir):
print()
print()
print("************************************")
print("Building ", apptarget[0])
print()
os_chdir(targetdir)
auto_compile(apptarget[2], apptarget[3], apptarget[4],
difxroot, apptarget[5])
else:
print()
print("******* Skipping "+targetdir)
print()
os_chdir(thisdir)
os_chdir(topdir)
##### Make standard (autotool'd) utilities ###############
os_chdir("utilities")
thisdir = os.getcwd()
for utiltarget in utiltargets:
if (utiltarget[1] == ''):
targetdir = utiltarget[0]
else:
targetdir= utiltarget[1] + '/' + utiltarget[0]
if not os.path.exists(targetdir):
print("**** Could not find "+targetdir+", trying Trunk")
targetdir = utiltarget[0] + '/trunk/'
if os.path.exists(targetdir):
print()
print()
print("************************************")
print("Building ", utiltarget[0])
os_chdir(targetdir)
auto_compile(utiltarget[2], utiltarget[3], utiltarget[4],