From 90eaa87a4d801d6ae75095a55c6a8cecfc2812a1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 6 Mar 2023 13:14:24 +0100 Subject: [PATCH] python/build/zlib.py: use autotools to be more portable Right now, zlib is only built for Windows, but we may eventually changed that, so don't hard-code `win32/Makefile.gcc`. --- python/build/zlib.py | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/python/build/zlib.py b/python/build/zlib.py index 0747a6d0d..c5aeb8c30 100644 --- a/python/build/zlib.py +++ b/python/build/zlib.py @@ -1,22 +1,32 @@ -import os.path, subprocess +import subprocess -from build.project import Project +from build.makeproject import MakeProject -class ZlibProject(Project): +class ZlibProject(MakeProject): def __init__(self, url, md5, installed, **kwargs): - Project.__init__(self, url, md5, installed, **kwargs) + MakeProject.__init__(self, url, md5, installed, **kwargs) + + def get_make_args(self, toolchain): + return MakeProject.get_make_args(self, toolchain) + [ + 'CC=' + toolchain.cc + ' ' + toolchain.cppflags + ' ' + toolchain.cflags, + 'CPP=' + toolchain.cc + ' -E ' + toolchain.cppflags, + 'AR=' + toolchain.ar, + 'ARFLAGS=' + toolchain.arflags, + 'RANLIB=' + toolchain.ranlib, + 'LDSHARED=' + toolchain.cc + ' -shared', + 'libz.a' + ] + + def get_make_install_args(self, toolchain): + return [ + 'RANLIB=' + toolchain.ranlib, + self.install_target + ] def _build(self, toolchain): src = self.unpack(toolchain, out_of_tree=False) - subprocess.check_call(['/usr/bin/make', '--quiet', - '-f', 'win32/Makefile.gcc', - 'PREFIX=' + toolchain.arch + '-', - '-j12', - 'install', - 'INCLUDE_PATH='+ os.path.join(toolchain.install_prefix, 'include'), - 'LIBRARY_PATH=' + os.path.join(toolchain.install_prefix, 'lib'), - 'BINARY_PATH=' + os.path.join(toolchain.install_prefix, 'bin'), - ], - cwd=src, env=toolchain.env) + subprocess.check_call(['./configure', '--prefix=' + toolchain.install_prefix, '--static'], + cwd=src, env=toolchain.env) + self.build_make(toolchain, src)