2017-08-13 03:24:00 +02:00
|
|
|
from pythonforandroid.toolchain import Recipe, shprint, current_directory, ArchARM
|
|
|
|
from os.path import exists, join, realpath
|
|
|
|
from os import uname
|
|
|
|
import glob
|
|
|
|
import sh
|
2018-10-07 16:59:03 +02:00
|
|
|
import os
|
2017-08-13 03:24:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
class LibGMPRecipe(Recipe):
|
|
|
|
version = '6.1.2'
|
2019-03-25 07:45:19 +01:00
|
|
|
#url = 'http://www.mirrorservice.org/pub/gnu/gmp/gmp-{version}.tar.bz2'
|
|
|
|
url = 'https://gmplib.org/download/gmp/gmp-{version}.tar.bz2'
|
2017-08-13 03:24:00 +02:00
|
|
|
|
|
|
|
def should_build(self, arch):
|
|
|
|
build_dir = self.get_build_dir(arch.arch)
|
|
|
|
return not exists(join(build_dir, '.libs', 'libgmp.so'))
|
|
|
|
|
|
|
|
def get_recipe_env(self, arch=None):
|
|
|
|
env = super(LibGMPRecipe, self).get_recipe_env(arch)
|
|
|
|
env['LIBGMP_LDFLAGS'] = '-avoid-version'
|
|
|
|
|
2018-10-07 16:59:03 +02:00
|
|
|
ndk_dir = self.ctx.ndk_platform
|
|
|
|
ndk_lib_dir = os.path.join(ndk_dir, 'usr', 'lib')
|
|
|
|
if self.ctx.ndk == 'crystax':
|
|
|
|
crystax_lib_dir = os.path.join(self.ctx.ndk_dir, 'sources/crystax/libs', arch.arch)
|
|
|
|
env['CFLAGS'] = '{} -L{} -L{}'.format(env.get('CFLAGS'), crystax_lib_dir, ndk_lib_dir);
|
|
|
|
|
|
|
|
env['LDFLAGS'] += ' -L{}'.format(ndk_lib_dir)
|
|
|
|
env['LDFLAGS'] += " --sysroot={}".format(self.ctx.ndk_platform)
|
|
|
|
env['PYTHONPATH'] = ':'.join([
|
|
|
|
self.ctx.get_site_packages_dir(),
|
|
|
|
env['BUILDLIB_PATH'],
|
|
|
|
])
|
2017-08-13 03:24:00 +02:00
|
|
|
|
2018-10-07 16:59:03 +02:00
|
|
|
return env
|
2017-08-13 03:24:00 +02:00
|
|
|
|
|
|
|
def build_arch(self, arch):
|
|
|
|
with current_directory(self.get_build_dir(arch.arch)):
|
|
|
|
env = self.get_recipe_env(arch)
|
|
|
|
configure = sh.Command('./configure')
|
|
|
|
shprint(configure,
|
|
|
|
'--host=arm-linux',
|
|
|
|
_env=env)
|
|
|
|
shprint(sh.make, '-j4', _env=env)
|
|
|
|
shprint(sh.mkdir, 'include')
|
|
|
|
shprint(sh.cp, '-a', 'gmp.h', 'include/gmp.h')
|
|
|
|
shprint(sh.cp, '-a', '.libs/libgmp.so', join(self.ctx.get_libs_dir(arch.arch), 'libgmp.so'))
|
|
|
|
shprint(sh.cp, '-a', '.libs/libgmp.so', join(self.ctx.get_libs_dir(''), 'libgmp.so')) # also copy to libs_collections/<package_name>
|
|
|
|
|
|
|
|
recipe = LibGMPRecipe()
|