Otok public index

apotocki/libpng

apotocki/libpng 1.6.47 (r1, windows)

Library
libpng
Variant
windows, target windows
Channel
stable
Published
2026-11-07
Recipe source
https://github.com/otok-dev/recipes.git
32756a87cf5bd189ca4c9825159bf0713ea8cf5e in recipes/libpng/1.6/windows/
Recipe SHA-256
94a08bb609e13a8745175bbed2aee9a75edaa612297e14287878a95bb07d80d2

Recipe files changed

Inputs

source.commit872555f4ba910252783af1507f9e7fe1653be252
source.githttps://github.com/pnggroup/libpng
source.tagv1.6.47

Platforms

windows

Dependencies

LibraryVersionRecipeDetails
zlib >= 1.2 apotocki/zlib

Toolchains

Recipe files

build.lua 2190 bytes · raw
-- libpng's CMake project, the library only. What it installs: libpng16_static.lib (static), or libpng16.lib with
-- libpng16.dll, with the suffix d in debug; the headers in include/ and include/libpng16/.

-- libpng installs no libpng.pc for Windows: one of the same contents, with the library's file name, so
-- that pkg-config's consumers (meson) find it; the prefix is the file's (pkgconf's ${pcfiledir})
local function write_pkg_config(p, lib)
    local name = lib:match("([^/]+)%.lib$")
    if otok.exists(p .. "/lib/pkgconfig/libpng.pc") then return end
    local text = table.concat({
        "prefix=${pcfiledir}/../..",
        "exec_prefix=${prefix}",
        "libdir=${prefix}/lib",
        "includedir=${prefix}/include/libpng16",
        "",
        "Name: libpng",
        "Description: Loads and saves PNG files",
        "Version: 1.6.47",
        "Requires.private: zlib",
        "Libs: -L${libdir} -l" .. name,
        "Cflags: -I${includedir}",
        "",
    }, "\n")
    for _, file in ipairs{ "libpng.pc", "libpng16.pc" } do otok.write(p .. "/lib/pkgconfig/" .. file, text) end
end

function build(slice, options, deps)
    local static = slice.linkage == "static"
    -- FindZLIB knows the static library of MSVC's zlib (zs.lib) only when told to look for one. For Windows libpng
    -- generates no libpng.pc and libpng-config, but installs them unless the build machine is Windows (CMAKE_HOST_WIN32):
    -- not those files, nor the manual pages (this recipe writes the .pc)
    otok.cmake{ defines = { PNG_SHARED = not static, PNG_STATIC = static, PNG_TESTS = false, PNG_TOOLS = false, PNG_FRAMEWORK = false,
        ZLIB_USE_STATIC_LIBS = deps.zlib.linkage == "static", SKIP_INSTALL_FILES = true } }
    local p = slice.prefix
    local dll = otok.glob("bin/libpng16*.dll", p)[1]
    if dll then
        local link = otok.glob("lib/libpng16*.lib", p)[1]
        write_pkg_config(p, link)
        return { libraries = { png16 = { link = link, runtime = dll } }, headers = p .. "/include" }
    end
    local lib = otok.glob("lib/libpng16_static*.lib", p)[1]
    write_pkg_config(p, lib)
    return { libraries = { png16 = lib }, headers = p .. "/include" }
end
recipe.toml 981 bytes · raw
# The otok recipe of libpng (https://github.com/apotocki/otok): libpng16 for Windows, from the release tag, with MSVC
# or with clang-cl across from Linux, with zlib of its own recipe; static or dynamic.
[recipe]
api = 1
library = "libpng"
name = "libpng"
version = "1.6.47"
revision = 1
license = "libpng-2.0"
license-files = ["LICENSE"]
homepage = "http://www.libpng.org/pub/png/libpng.html"
description = "libpng, the reference library for PNG images."
keywords = ["png", "image"]
linkage = ["static", "dynamic"]

[source]
git = "https://github.com/pnggroup/libpng"
commit = "872555f4ba910252783af1507f9e7fe1653be252"
tag = "v1.6.47"

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

[deps.zlib]
version = ">= 1.2"
default-recipe = "apotocki/zlib"

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

[[product]]
name = "PNG"
libraries = ["png16"]