Debian Codegraph @

cmake/tribits/devtools_install/install-autoconf.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 autoconfBaseName = "autoconf"
18 autoconfDefaultVersion = "2.69"
19 autoconfSupportedVersions = ["2.69"]
20 autoconfTarballVersions = {
21 "2.69" : "2.69"
22 }
23
24 #
25 # Script code
26 #
27
28
29 from InstallProgramDriver import *
30 from GeneralScriptSupport import *
31
32
33 class AutoconfInstall:
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-autoconf.py"
44
45 def getProductBaseName(self):
46 return autoconfBaseName
47
48 def getProductDefaultVersion(self):
49 return autoconfDefaultVersion
50
51 def getProductSupportedVersions(self):
52 return autoconfSupportedVersions
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 autoconfBaseName+"-"+version
61
62 def getBaseDirName(self, version):
63 return autoconfBaseName+"-"+version+"-base"
64
65 def getExtraHelpStr(self, version):
66 return """
67 This script builds Autoconf"""+self.getProductName(version)+""" from source compiled with the
68 configured C compilers in your path.
69
70 NOTE: The assumed directory structure of the download source provided by the
71 command --download-cmnd=<download-cmnd> is:
72
73 autoconf-<version>-base/
74 autoconf-<full-version>.tar.gz
75 """
76
77 def injectExtraCmndLineOptions(self, clp, version):
78 setStdDownloadCmndOption(self, clp, version)
79 clp.add_option(
80 "--extra-configure-options", dest="extraConfigureOptions", type="string", \
81 default="", \
82 help="Extra options to add to the 'configure' command for "+self.getProductName(version)+"." \
83 +" Note: This does not override the hard-coded configure options." )
84
85 def echoExtraCmndLineOptions(self, inOptions):
86 cmndLine = ""
87 cmndLine += " --download-cmnd='"+inOptions.downloadCmnd+"' \\\n"
88 cmndLine += " --extra-configure-options='"+inOptions.extraConfigureOptions+"' \\\n"
89 return cmndLine
90
91 #
92 # Called after parsing the command-line
93 #
94
95 def setup(self, inOptions):
96 self.inOptions = inOptions
97 self.baseDir = os.getcwd()
98 self.autoconfBaseDir = self.baseDir+"/"+self.getBaseDirName(self.inOptions.version)
99 autoconfVersionFull = autoconfTarballVersions[self.inOptions.version]
100 self.autoconfTarball = "autoconf-"+autoconfVersionFull+".tar.gz"
101 self.autoconfSrcDir = "autoconf-"+autoconfVersionFull
102 self.autoconfBuildBaseDir = self.autoconfBaseDir+"/autoconf-build"
103 self.scriptBaseDir = getScriptBaseDir()
104
105 #
106 # Called after setup()
107 #
108
109 def doDownload(self):
110 removeDirIfExists(self.autoconfBaseDir, True)
111 echoRunSysCmnd(self.inOptions.downloadCmnd)
112
113 def doUntar(self):
114 # Find the full name of the source tarball
115 echoChDir(self.autoconfBaseDir)
116 echoRunSysCmnd("tar -xzf "+self.autoconfTarball)
117
118 def doConfigure(self):
119 createDir(self.autoconfBuildBaseDir, True, True)
120 echoRunSysCmnd(
121 "../"+self.autoconfSrcDir+"/configure "+\
122 " "+self.inOptions.extraConfigureOptions+\
123 " --prefix="+self.inOptions.installDir,
124 extraEnv={"CFLAGS":"-O3"},
125 )
126
127 def doBuild(self):
128 echoChDir(self.autoconfBuildBaseDir)
129 echoRunSysCmnd("make " + getParallelOpt(self.inOptions, "-j") \
130 + self.inOptions.makeOptions)
131
132 def doInstall(self):
133 echoChDir(self.autoconfBuildBaseDir)
134 echoRunSysCmnd("make " + getParallelOpt(self.inOptions, "-j") \
135 + self.inOptions.makeOptions + " install")
136
137 def getFinalInstructions(self):
138 return """
139 To use the installed version of autoconf-"""+self.inOptions.version+""" add the path:
140
141 """+self.inOptions.installDir+"""/bin
142
143 to your path and that should be it!
144 """
145
146
147 #
148 # Executable statements
149 #
150
151 autoconfInstaller = InstallProgramDriver(AutoconfInstall())
152 autoconfInstaller.runDriver()