Debian Codegraph @

cmake/tribits/devtools_install/install-mpich.py

raw
1 #!/usr/bin/env python3
2
3 # @HEADER
4 # *****************************************************************************
5 # TriBITS: Tribal Build, Integrate, and Test System
6 #
7 # Copyright 2013-2016 NTESS and the TriBITS contributors.
8 # SPDX-License-Identifier: BSD-3-Clause
9 # *****************************************************************************
10 # @HEADER
11
12
13 #
14 # Defaults
15 #
16
17 mpichBaseName = "mpich"
18 mpichDefaultVersion = "3.1.3"
19 mpichSupportedVersions = ["3.1.3"]
20 mpichTarballVersions = {
21 "3.1.3" : "3.1.3"
22 }
23
24 #
25 # Script code
26 #
27
28
29 from InstallProgramDriver import *
30 from GeneralScriptSupport import *
31
32
33 class MpichInstall:
34
35 def __init__(self):
36 self.dummy = None
37
38 #
39 # Called before even knowing the product version
40 #
41
42 def getScriptName(self):
43 return "install-mpich.py"
44
45 def getProductBaseName(self):
46 return mpichBaseName
47
48 def getProductDefaultVersion(self):
49 return mpichDefaultVersion
50
51 def getProductSupportedVersions(self):
52 return mpichSupportedVersions
53
54 #
55 # Called after knowing the product version but before parsing the
56 # command-line.
57 #
58
59 def getProductName(self, version):
60 return mpichBaseName+"-"+version
61
62 def getBaseDirName(self, version):
63 return mpichBaseName+"-"+version+"-base"
64
65 def getExtraHelpStr(self, version):
66 return """
67 This script builds """+self.getProductName(version)+""" from source compiled
68 with the configured C/C++/Fortran compilers in your path or set by the env
69 vars CC, CXX, and FC.
70
71 NOTE: The assumed directory structure of the download source provided by the
72 command --download-cmnd=<download-cmnd> is:
73
74 mpich-<version>-base/
75 mpich-<version>.tar.gz
76 """
77
78 def injectExtraCmndLineOptions(self, clp, version):
79 setStdDownloadCmndOption(self, clp, version)
80 clp.add_option(
81 "--extra-configure-options", dest="extraConfigureOptions", type="string", \
82 default="", \
83 help="Extra options to add to the 'configure' command for "+self.getProductName(version)+"." \
84 +" Note: This does not override the hard-coded configure options." )
85
86 def echoExtraCmndLineOptions(self, inOptions):
87 cmndLine = ""
88 cmndLine += " --download-cmnd='"+inOptions.downloadCmnd+"' \\\n"
89 cmndLine += " --extra-configure-options='"+inOptions.extraConfigureOptions+"' \\\n"
90 return cmndLine
91
92 #
93 # Called after parsing the command-line
94 #
95
96 def setup(self, inOptions):
97 self.inOptions = inOptions
98 self.baseDir = os.getcwd()
99 self.mpichBaseDir = self.baseDir+"/"+self.getBaseDirName(self.inOptions.version)
100 mpichVersionFull = mpichTarballVersions[self.inOptions.version]
101 self.mpichTarball = "mpich-"+mpichVersionFull+".tar.gz"
102 self.mpichSrcDir = "mpich-"+mpichVersionFull
103 self.mpichBuildBaseDir = self.mpichBaseDir+"/mpich-build"
104 self.scriptBaseDir = getScriptBaseDir()
105
106 #
107 # Called after setup()
108 #
109
110 def doDownload(self):
111 removeDirIfExists(self.mpichBaseDir, True)
112 echoRunSysCmnd(self.inOptions.downloadCmnd)
113
114 def doUntar(self):
115 # Find the full name of the source tarball
116 echoChDir(self.mpichBaseDir)
117 echoRunSysCmnd("tar -xzf "+self.mpichTarball)
118 # NOTE: I found that you have to untar the tarball and can't store the
119 # open source in the git repo. Otherwise the timestamps are messed up and
120 # it 'make' tries to recreate some generated files.
121
122 def doConfigure(self):
123 createDir(self.mpichBuildBaseDir, True, True)
124 echoRunSysCmnd(
125 "../"+self.mpichSrcDir+"/configure "+\
126 " "+self.inOptions.extraConfigureOptions+\
127 " --prefix="+self.inOptions.installDir,
128 extraEnv={"CFLAGS":"-O3", "CXXFLAGS":"-O3", "FFLAGS":"-O3"},
129 )
130
131 def doBuild(self):
132 echoChDir(self.mpichBuildBaseDir)
133 echoRunSysCmnd("make " + getParallelOpt(self.inOptions, "-j") \
134 + self.inOptions.makeOptions)
135
136 def doInstall(self):
137 echoChDir(self.mpichBuildBaseDir)
138 echoRunSysCmnd("make " + getParallelOpt(self.inOptions, "-j") \
139 + self.inOptions.makeOptions + " install")
140
141 def getFinalInstructions(self):
142 return """
143 To use the installed version of mpich-"""+self.inOptions.version+""" add the path:
144
145 """+self.inOptions.installDir+"""/bin
146
147 to your path and that should be it!
148
149 Also, when you link shared libs or executables, pass in:
150
151 -Wl,-rpath,"""+self.inOptions.installDir+"""/lib[64]
152
153 That will make it so that you don't need to add this MPICH libs to your
154 LD_LIBRARY_PATH.
155 """
156
157
158 #
159 # Executable statements
160 #
161
162 mpichInstaller = InstallProgramDriver(MpichInstall())
163 mpichInstaller.runDriver()