2014-12-09 12:59:03 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import os, os.path
|
2015-11-21 00:17:00 +01:00
|
|
|
import sys, subprocess
|
2014-12-09 12:59:03 +01:00
|
|
|
|
|
|
|
configure_args = sys.argv[1:]
|
|
|
|
|
2014-12-17 16:47:25 +01:00
|
|
|
host_arch = 'i686-w64-mingw32'
|
|
|
|
|
2015-01-27 09:07:41 +01:00
|
|
|
if len(configure_args) > 0 and configure_args[0] == '--64':
|
2014-12-17 16:35:27 +01:00
|
|
|
configure_args = configure_args[1:]
|
|
|
|
host_arch = 'x86_64-w64-mingw32'
|
|
|
|
|
2014-12-09 12:59:03 +01:00
|
|
|
# the path to the MPD sources
|
2015-01-26 20:59:57 +01:00
|
|
|
mpd_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]) or '.', '..'))
|
2015-11-20 22:10:22 +01:00
|
|
|
sys.path[0] = os.path.join(mpd_path, 'python')
|
2014-12-09 12:59:03 +01:00
|
|
|
|
|
|
|
# output directories
|
2015-11-23 10:38:48 +01:00
|
|
|
from build.dirs import lib_path, tarball_path, src_path
|
2015-06-03 07:48:38 +02:00
|
|
|
|
2014-12-17 16:47:25 +01:00
|
|
|
arch_path = os.path.join(lib_path, host_arch)
|
|
|
|
build_path = os.path.join(arch_path, 'build')
|
|
|
|
root_path = os.path.join(arch_path, 'root')
|
2014-12-09 12:59:03 +01:00
|
|
|
|
2015-11-20 20:30:42 +01:00
|
|
|
class CrossGccToolchain:
|
2015-11-20 23:47:52 +01:00
|
|
|
def __init__(self, toolchain_path, arch,
|
|
|
|
tarball_path, src_path, build_path, install_prefix):
|
2015-11-20 20:30:42 +01:00
|
|
|
self.arch = arch
|
2015-11-20 23:47:52 +01:00
|
|
|
self.tarball_path = tarball_path
|
|
|
|
self.src_path = src_path
|
|
|
|
self.build_path = build_path
|
2015-11-20 20:30:42 +01:00
|
|
|
self.install_prefix = install_prefix
|
|
|
|
|
|
|
|
toolchain_bin = os.path.join(toolchain_path, 'bin')
|
|
|
|
self.cc = os.path.join(toolchain_bin, arch + '-gcc')
|
|
|
|
self.cxx = os.path.join(toolchain_bin, arch + '-g++')
|
|
|
|
self.ar = os.path.join(toolchain_bin, arch + '-ar')
|
|
|
|
self.nm = os.path.join(toolchain_bin, arch + '-nm')
|
|
|
|
self.strip = os.path.join(toolchain_bin, arch + '-strip')
|
|
|
|
|
|
|
|
common_flags = ''
|
|
|
|
self.cflags = '-O2 -g ' + common_flags
|
|
|
|
self.cxxflags = '-O2 -g ' + common_flags
|
|
|
|
self.cppflags = '-isystem ' + os.path.join(install_prefix, 'include')
|
2015-11-20 22:14:10 +01:00
|
|
|
self.ldflags = '-L' + os.path.join(install_prefix, 'lib')
|
2015-11-20 20:30:42 +01:00
|
|
|
self.libs = ''
|
|
|
|
|
2015-11-21 00:35:52 +01:00
|
|
|
self.is_arm = arch.startswith('arm')
|
|
|
|
self.is_armv7 = self.is_arm and 'armv7' in self.cflags
|
|
|
|
self.is_windows = 'mingw32' in arch
|
|
|
|
|
2015-11-20 20:30:42 +01:00
|
|
|
self.env = dict(os.environ)
|
|
|
|
|
|
|
|
# redirect pkg-config to use our root directory instead of the
|
|
|
|
# default one on the build host
|
|
|
|
self.env['PKG_CONFIG_LIBDIR'] = os.path.join(install_prefix, 'lib/pkgconfig')
|
2014-12-09 12:59:03 +01:00
|
|
|
|
|
|
|
# a list of third-party libraries to be used by MPD on Android
|
2015-11-23 10:43:06 +01:00
|
|
|
from build.libs import *
|
2014-12-09 12:59:03 +01:00
|
|
|
thirdparty_libs = [
|
2015-11-23 10:43:06 +01:00
|
|
|
libogg,
|
|
|
|
libvorbis,
|
|
|
|
opus,
|
|
|
|
flac,
|
|
|
|
zlib,
|
|
|
|
libid3tag,
|
|
|
|
ffmpeg,
|
|
|
|
curl,
|
|
|
|
boost,
|
2014-12-09 12:59:03 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
# build the third-party libraries
|
2015-11-20 23:47:52 +01:00
|
|
|
toolchain = CrossGccToolchain('/usr', host_arch,
|
|
|
|
tarball_path, src_path, build_path, root_path)
|
2015-11-20 20:30:42 +01:00
|
|
|
|
2014-12-09 12:59:03 +01:00
|
|
|
for x in thirdparty_libs:
|
2015-11-20 20:30:42 +01:00
|
|
|
if not x.is_installed(toolchain):
|
|
|
|
x.build(toolchain)
|
2014-12-09 12:59:03 +01:00
|
|
|
|
|
|
|
# configure and build MPD
|
|
|
|
|
|
|
|
configure = [
|
|
|
|
os.path.join(mpd_path, 'configure'),
|
2015-11-20 20:30:42 +01:00
|
|
|
'CC=' + toolchain.cc,
|
|
|
|
'CXX=' + toolchain.cxx,
|
|
|
|
'CFLAGS=' + toolchain.cflags,
|
|
|
|
'CXXFLAGS=' + toolchain.cxxflags,
|
|
|
|
'CPPFLAGS=' + toolchain.cppflags,
|
|
|
|
'LDFLAGS=' + toolchain.ldflags + ' -static',
|
|
|
|
'LIBS=' + toolchain.libs,
|
|
|
|
'AR=' + toolchain.ar,
|
|
|
|
'STRIP=' + toolchain.strip,
|
|
|
|
'--host=' + toolchain.arch,
|
|
|
|
'--prefix=' + toolchain.install_prefix,
|
2014-12-09 12:59:03 +01:00
|
|
|
|
|
|
|
'--enable-silent-rules',
|
|
|
|
|
|
|
|
'--disable-icu',
|
|
|
|
|
|
|
|
] + configure_args
|
|
|
|
|
2015-11-20 20:30:42 +01:00
|
|
|
subprocess.check_call(configure, env=toolchain.env)
|
|
|
|
subprocess.check_call(['/usr/bin/make', '--quiet', '-j12'], env=toolchain.env)
|