2015-11-30 23:47:28 +01:00
|
|
|
import os.path, subprocess, sys
|
2015-11-21 00:05:48 +01:00
|
|
|
|
2017-10-06 23:06:28 +02:00
|
|
|
from build.makeproject import MakeProject
|
2015-11-21 00:05:48 +01:00
|
|
|
|
2017-10-06 23:06:28 +02:00
|
|
|
class AutotoolsProject(MakeProject):
|
2015-11-21 00:05:48 +01:00
|
|
|
def __init__(self, url, md5, installed, configure_args=[],
|
|
|
|
autogen=False,
|
|
|
|
cppflags='',
|
2018-01-05 07:56:49 +01:00
|
|
|
ldflags='',
|
|
|
|
libs='',
|
2015-11-21 00:05:48 +01:00
|
|
|
**kwargs):
|
2017-10-06 23:06:28 +02:00
|
|
|
MakeProject.__init__(self, url, md5, installed, **kwargs)
|
2015-11-21 00:05:48 +01:00
|
|
|
self.configure_args = configure_args
|
|
|
|
self.autogen = autogen
|
|
|
|
self.cppflags = cppflags
|
2018-01-05 07:56:49 +01:00
|
|
|
self.ldflags = ldflags
|
|
|
|
self.libs = libs
|
2015-11-21 00:05:48 +01:00
|
|
|
|
2017-10-06 23:06:28 +02:00
|
|
|
def configure(self, toolchain):
|
2015-11-21 00:05:48 +01:00
|
|
|
src = self.unpack(toolchain)
|
|
|
|
if self.autogen:
|
2015-11-30 23:47:28 +01:00
|
|
|
if sys.platform == 'darwin':
|
|
|
|
subprocess.check_call(['glibtoolize', '--force'], cwd=src)
|
|
|
|
else:
|
|
|
|
subprocess.check_call(['libtoolize', '--force'], cwd=src)
|
2015-11-30 23:44:57 +01:00
|
|
|
subprocess.check_call(['aclocal'], cwd=src)
|
|
|
|
subprocess.check_call(['automake', '--add-missing', '--force-missing', '--foreign'], cwd=src)
|
|
|
|
subprocess.check_call(['autoconf'], cwd=src)
|
2015-11-21 00:05:48 +01:00
|
|
|
|
|
|
|
build = self.make_build_path(toolchain)
|
|
|
|
|
|
|
|
configure = [
|
|
|
|
os.path.join(src, 'configure'),
|
|
|
|
'CC=' + toolchain.cc,
|
|
|
|
'CXX=' + toolchain.cxx,
|
|
|
|
'CFLAGS=' + toolchain.cflags,
|
|
|
|
'CXXFLAGS=' + toolchain.cxxflags,
|
|
|
|
'CPPFLAGS=' + toolchain.cppflags + ' ' + self.cppflags,
|
2018-01-05 07:56:49 +01:00
|
|
|
'LDFLAGS=' + toolchain.ldflags + ' ' + self.ldflags,
|
|
|
|
'LIBS=' + toolchain.libs + ' ' + self.libs,
|
2015-11-21 00:05:48 +01:00
|
|
|
'AR=' + toolchain.ar,
|
2016-10-26 10:40:19 +02:00
|
|
|
'RANLIB=' + toolchain.ranlib,
|
2015-11-21 00:05:48 +01:00
|
|
|
'STRIP=' + toolchain.strip,
|
|
|
|
'--host=' + toolchain.arch,
|
|
|
|
'--prefix=' + toolchain.install_prefix,
|
|
|
|
'--enable-silent-rules',
|
|
|
|
] + self.configure_args
|
|
|
|
|
|
|
|
subprocess.check_call(configure, cwd=build, env=toolchain.env)
|
2017-10-06 23:06:28 +02:00
|
|
|
return build
|
|
|
|
|
|
|
|
def build(self, toolchain):
|
|
|
|
build = self.configure(toolchain)
|
|
|
|
MakeProject.build(self, toolchain, build)
|