Skip to content
34 changes: 15 additions & 19 deletions packages/b/brotli/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ package("brotli")
"333e2a0306cf33f2fac381aa6b81afd3d1237e7511e5cc8fe7fb760d16d01ca1")
end

if is_plat("cross") then
add_syslinks("m")
end

add_links("brotlienc", "brotlidec", "brotlicommon")

if is_plat("mingw") and is_subhost("msys") then
Expand All @@ -28,45 +32,37 @@ package("brotli")
add_extsources("brew::brotli")
end

on_load(function (package)
package:addenv("PATH", "bin")
end)

if on_fetch then
on_fetch("linux", "macosx", function (package, opt)
on_fetch("linux", "macosx", "mingw", function (package, opt)
if opt.system then
local result
local pkginfo
for _, name in ipairs({"libbrotlidec", "libbrotlienc", "libbrotlicommon"}) do
local pkginfo = package.find_package and package:find_package("pkgconfig::" .. name, opt)
if pkginfo then
if not result then
result = table.copy(pkginfo)
else
local includedirs = pkginfo.sysincludedirs or pkginfo.includedirs
result.links = table.wrap(result.links)
result.linkdirs = table.wrap(result.linkdirs)
result.includedirs = table.wrap(result.includedirs)
table.join2(result.includedirs, includedirs)
table.join2(result.linkdirs, pkginfo.linkdirs)
table.join2(result.links, pkginfo.links)
end
pkginfo = package:find_package("pkgconfig::" .. name, opt)
if not pkginfo then
return
end
result = (result and result .. pkginfo) or pkginfo
end
result.version = pkginfo.version
return result
end
end)
end

on_install(function (package)
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
local configs = {buildir = "xbuild", vers = package:version_str()}
local configs = {buildir = "xbuild", vers = package:version_str():gsub("^v", "")}
if package:config("shared") then
configs.kind = "shared"
end
if package:is_plat("linux") and package:config("pic") ~= false then
configs.cxflags = "-fPIC"
end
import("package.tools.xmake").install(package, configs)
if not package:is_cross() then
package:addenv("PATH", "bin")
end
end)

on_test(function(package)
Expand Down
12 changes: 11 additions & 1 deletion packages/g/gmp/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,15 @@ package("gmp")
end)

on_test(function (package)
assert(package:has_cfuncs("gmp_randinit", {includes = "gmp.h"}))
assert(package:check_csnippets([[
void factorial(int n) {
int i;
mpz_t p;
mpz_init_set_ui(p,1);
for (i=1; i <= n ; ++i){
mpz_mul_ui(p,p,i);
}
mpz_clear(p);
}
]], {includes = "gmp.h"}))
end)
46 changes: 46 additions & 0 deletions packages/g/gnutls/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package("gnutls")
set_homepage("https://www.gnutls.org/")
set_description("GnuTLS is a secure communications library implementing the SSL, TLS and DTLS protocols and technologies around them.")
set_license("LGPL-2.1")

add_urls("https://www.gnupg.org/ftp/gcrypt/gnutls/v3.8/gnutls-$(version).tar.xz")
add_versions("3.8.9", "69e113d802d1670c4d5ac1b99040b1f2d5c7c05daec5003813c049b5184820ed")

if is_plat("mingw") then
add_syslinks("ws2_32", "crypt32", "bcrypt", "ncrypt")
end

add_links("gnutls-openssl", "gnutlsxx", "gnutls")

add_deps("pkg-config")
add_deps("p11-kit")

on_load(function (package)
package:add("deps", "nettle", "libtasn1", "libidn2", "gmp", "libunistring", "brotli", "zlib", "zstd", { configs = {shared = package:config("shared")} })
end)

on_install("linux", "mingw", "cross", function (package)
local configs = {"--disable-tests", "--disable-doc", "--disable-nls",
"--with-tpm2=no",
"--with-idn",
"--with-brotli",
"--with-zstd",
"--enable-openssl-compatibility",
"--with-default-trust-store-pkcs11=pkcs11:",
}
table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
if package:is_debug() then
table.insert(configs, "--enable-debug")
end
import("package.tools.autoconf").install(package, configs, {packagedeps = {"nettle", "p11-kit", "libtasn1", "libidn2", "gmp", "libunistring", "brotli", "zlib", "zstd"}})
end)

on_test(function (package)
assert(package:check_csnippets([[
#include <gnutls/gnutls.h>
void test(void) {
gnutls_session_t session;
gnutls_global_deinit();
}
]]))
end)
9 changes: 5 additions & 4 deletions packages/n/nettle/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ package("nettle")
add_versions("3.9.1", "ccfeff981b0ca71bbd6fbcb054f407c60ffb644389a5be80d6716d5b550c6ce3")
add_versions("3.10.1", "b0fcdd7fc0cdea6e80dcf1dd85ba794af0d5b4a57e26397eee3bc193272d9132")

add_links("hogweed", "nettle")

add_deps("m4")
add_deps("gmp")
if is_plat("linux") then
Expand All @@ -29,11 +31,10 @@ package("nettle")
table.insert(configs, "--disable-shared")
table.insert(configs, "--enable-static")
end
import("package.tools.autoconf")
local envs = autoconf.buildenvs(package, {packagedeps = {"gmp"}})
autoconf.install(package, configs, {envs = envs})
if os.isfile(package:installdir("lib64", "pkgconfig", "nettle.pc")) then
import("package.tools.autoconf").install(package, configs, {packagedeps = {"gmp"}})
if os.isfile(path.join(package:installdir(), "lib64", "pkgconfig", "nettle.pc")) then
package:add("linkdirs", "lib64")
os.trycp((package:installdir("lib64", "pkgconfig")), package:installdir("lib"))
end
end)

Expand Down
6 changes: 4 additions & 2 deletions packages/p/p11-kit/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ package("p11-kit")

add_versions("0.25.5", "04d0a86450cdb1be018f26af6699857171a188ac6d5b8c90786a60854e1198e5")

add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true})

if is_plat("mingw") and is_subhost("msys") then
add_extsources("pacman::p11-kit")
elseif is_plat("linux") then
Expand All @@ -16,6 +18,8 @@ package("p11-kit")
add_extsources("brew::p11-kit")
end

add_includedirs("include/p11-kit-1")

add_deps("meson", "ninja")
add_deps("libffi", "libtasn1")

Expand All @@ -29,9 +33,7 @@ package("p11-kit")

on_install("linux", "mingw", "macosx", "iphoneos", "bsd", "cross", function (package)
local configs = {"-Dsystemd=disabled", "-Dbash_completion=disabled", "-Dtest=false"}
table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
import("package.tools.meson").install(package, configs)
os.trymv(package:installdir("include", "p11-kit-1", "*"), package:installdir("include"))
end)

on_test(function (package)
Expand Down
Loading