rewrite zlib (#261)

pull/262/head
ruki 4 years ago committed by GitHub
parent 2595beac10
commit fefc80f2fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 86
      packages/z/zlib/xmake.lua

@ -8,48 +8,50 @@ package("zlib")
add_versions("1.2.10", "42cd7b2bdaf1c4570e0877e61f2fdc0bce8019492431d054d3d86925e5058dc5")
add_versions("1.2.11", "629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff")
on_install("windows", function (package)
io.gsub("win32/Makefile.msc", "%-MD", "-" .. package:config("vs_runtime"))
import("package.tools.nmake").build(package, {"-f", "win32\\Makefile.msc", "zlib.lib"})
os.cp("zlib.lib", package:installdir("lib"))
os.cp("*.h", package:installdir("include"))
end)
on_install("mingw@windows", function (package)
import("core.tool.toolchain")
io.gsub("win32/Makefile.gcc", "\nCC =.-\n", "\nCC=" .. (package:build_getenv("cc") or "") .. "\n")
io.gsub("win32/Makefile.gcc", "\nAR =.-\n", "\nAR=" .. (package:build_getenv("ar") or "") .. "\n")
local bindir = toolchain.load("mingw"):bindir()
local make = path.join(bindir, "mingw32-make.exe")
os.vrun(make.." -f win32/Makefile.gcc libz.a")
os.cp("libz.a", package:installdir("lib"))
os.cp("*.h", package:installdir("include"))
end)
on_install("mingw@msys", function (package)
io.gsub("win32/Makefile.gcc", "\nCC =.-\n", "\nCC=" .. (package:build_getenv("cc") or "") .. "\n")
io.gsub("win32/Makefile.gcc", "\nAR =.-\n", "\nAR=" .. (package:build_getenv("ar") or "") .. "\n")
import("package.tools.make").build(package, {"-f", "win32/Makefile.gcc", "libz.a"})
os.cp("libz.a", package:installdir("lib"))
os.cp("*.h", package:installdir("include"))
end)
on_install("macosx", "bsd", function (package)
import("package.tools.autoconf").install(package, {"--static"})
end)
on_install("linux", function (package)
import("package.tools.autoconf").configure(package, {"--static"})
io.gsub("Makefile", "\nCFLAGS=(.-)\n", "\nCFLAGS=%1 -fPIC\n")
os.vrun("make install -j4")
end)
on_install("iphoneos", "android@linux,macosx", "mingw@linux,macosx", "cross", function (package)
import("package.tools.autoconf").configure(package, {host = "", "--static"})
io.gsub("Makefile", "\nAR=.-\n", "\nAR=" .. (package:build_getenv("ar") or "") .. "\n")
io.gsub("Makefile", "\nARFLAGS=.-\n", "\nARFLAGS=cr\n")
io.gsub("Makefile", "\nRANLIB=.-\n", "\nRANLIB=\n")
os.vrun("make install -j4")
on_install(function (package)
io.writefile("xmake.lua", [[
includes("check_cincludes.lua")
add_rules("mode.debug", "mode.release")
target("zlib")
set_kind("$(kind)")
if not is_plat("windows", "mingw") then
set_basename("z")
end
add_files("adler32.c")
add_files("compress.c")
add_files("crc32.c")
add_files("deflate.c")
add_files("gzclose.c")
add_files("gzlib.c")
add_files("gzread.c")
add_files("gzwrite.c")
add_files("inflate.c")
add_files("infback.c")
add_files("inftrees.c")
add_files("inffast.c")
add_files("trees.c")
add_files("uncompr.c")
add_files("zutil.c")
add_headerfiles("zlib.h", "zconf.h")
check_cincludes("Z_HAVE_UNISTD_H", "unistd.h")
check_cincludes("HAVE_SYS_TYPES_H", "sys/types.h")
check_cincludes("HAVE_STDINT_H", "stdint.h")
check_cincludes("HAVE_STDDEF_H", "stddef.h")
if is_plat("windows") then
add_defines("_CRT_SECURE_NO_DEPRECATE")
add_defines("_CRT_NONSTDC_NO_DEPRECATE")
if is_kind("shared") then
add_defines("ZLIB_DLL")
end
else
add_defines("_LARGEFILE64_SOURCE=1")
end
]])
local configs = {}
if package:config("shared") then
configs.kind = "shared"
end
import("package.tools.xmake").install(package, configs)
end)
on_test(function (package)

Loading…
Cancel
Save