Otok public index

apotocki/zlib

apotocki/zlib 1.3.2 (r1, windows)

Library
zlib
Variant
windows, target windows
Channel
stable
Published
2026-11-07
Recipe source
https://github.com/otok-dev/recipes.git
32756a87cf5bd189ca4c9825159bf0713ea8cf5e in recipes/zlib/1.3/windows/
Recipe SHA-256
16fda365c06823752384e726e5da6eb396d234ba3e4184e7df4d52c6d70efb23

Recipe files changed

Inputs

source.sha256bb329a0a2cd0274d05519d61c667c062e06990d72e125ee2dfa8de64f0119d16
source.urlhttps://github.com/madler/zlib/releases/download/v1.3.2/zlib-1.3.2.tar.gz

Platforms

windows

Toolchains

Recipe files

build.lua 1230 bytes · raw
-- zlib's CMake project, the library only. What it installs: zs.lib (static), or z.lib with z.dll (dynamic), with the
-- suffix d in debug.

-- zlib.pc names the library -lz whatever MSVC's file is (zs, zd, zsd): the file's name, so that pkg-config's
-- consumers (meson) link it
local function fix_pkg_config(p, lib)
    local pc = p .. "/lib/pkgconfig/zlib.pc"
    local name = lib:match("([^/]+)%.lib$")
    if not name or not otok.exists(pc) then return end
    local text, n = otok.read(pc):gsub("%-lz%f[%s]", "-l" .. name)
    assert(n > 0, "zlib.pc no longer links -lz")
    otok.write(pc, text)
end

function build(slice, options, deps)
    local static = slice.linkage == "static"
    otok.cmake{ defines = { ZLIB_BUILD_SHARED = not static, ZLIB_BUILD_STATIC = static, ZLIB_BUILD_TESTING = false } }
    local p = slice.prefix
    local dll = otok.glob("bin/z*.dll", p)[1]
    if dll then
        local link = otok.glob("lib/z*.lib", p)[1]
        fix_pkg_config(p, link)
        return { libraries = { z = { link = link, runtime = dll } }, headers = p .. "/include" }
    end
    local lib = otok.glob("lib/zs*.lib", p)[1]
    fix_pkg_config(p, lib)
    return { libraries = { z = lib }, headers = p .. "/include" }
end
recipe.toml 912 bytes · raw
# The otok recipe of zlib (https://github.com/apotocki/otok): zlib for Windows, from the release archive, with MSVC
# or with clang-cl across from Linux; static or dynamic.
[recipe]
api = 1
library = "zlib"
name = "zlib"
version = "1.3.2"
revision = 1
license = "Zlib"
license-files = ["LICENSE"]
homepage = "https://zlib.net"
description = "zlib, the general-purpose compression library."
keywords = ["compression", "deflate", "zlib"]
linkage = ["static", "dynamic"]

[source]
url = "https://github.com/madler/zlib/releases/download/v1.3.2/zlib-1.3.2.tar.gz"
sha256 = "bb329a0a2cd0274d05519d61c667c062e06990d72e125ee2dfa8de64f0119d16"

[platforms]
supported = ["windows"]
build-on = ["windows/msvc", "linux/clang-cl"]

[toolchains]
cmake = { version = ">= 3.20", default-recipe = "apotocki/cmake" }
ninja = { version = ">= 1.10", default-recipe = "apotocki/ninja" }

[[product]]
name = "ZLIB"
libraries = ["z"]