From 4c9e0ebbce4afced1e6b6cda145727d89b0b302a Mon Sep 17 00:00:00 2001 From: Hoildkv <42310255+xq114@users.noreply.github.com> Date: Mon, 20 Dec 2021 13:53:58 +0800 Subject: [PATCH] add libidn2 (#770) * add libidn2 * improve libiconv * use packagedeps * fix packagedeps --- packages/l/libiconv/xmake.lua | 6 ++++++ packages/l/libidn2/xmake.lua | 28 ++++++++++++++++++++++++++++ packages/l/libunistring/xmake.lua | 14 ++++++-------- 3 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 packages/l/libidn2/xmake.lua diff --git a/packages/l/libiconv/xmake.lua b/packages/l/libiconv/xmake.lua index 42b85f9e9..d42eb19d1 100644 --- a/packages/l/libiconv/xmake.lua +++ b/packages/l/libiconv/xmake.lua @@ -16,6 +16,12 @@ package("libiconv") "d09e4212040f5adf1faa5cf5a9a18f6f79d4cdce9affb05f2e75df2ea3b3d686") end + on_fetch("macosx", "linux", function (package, opt) + if opt.system then + return package:find_package("system::iconv", {includes = "iconv.h"}) + end + end) + on_load(function (package) package:addenv("PATH", "bin") end) diff --git a/packages/l/libidn2/xmake.lua b/packages/l/libidn2/xmake.lua new file mode 100644 index 000000000..2f05a39ee --- /dev/null +++ b/packages/l/libidn2/xmake.lua @@ -0,0 +1,28 @@ +package("libidn2") + + set_homepage("https://www.gnu.org/software/libidn/") + set_description("Libidn2 is an implementation of the IDNA2008 + TR46 specifications.") + set_license("LGPL-3.0") + + add_urls("https://ftp.gnu.org/gnu/libidn/libidn2-$(version).tar.gz", + "https://ftpmirror.gnu.org/libidn/libidn2-$(version).tar.gz") + add_versions("2.3.2", "76940cd4e778e8093579a9d195b25fff5e936e9dc6242068528b437a76764f91") + + add_deps("libunistring") + if is_plat("linux") then + add_extsources("apt::libidn2-dev") + end + + on_install("macosx", "linux", function (package) + local configs = {"--disable-dependency-tracking"} + table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no")) + table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes")) + if package:config("pic") ~= false then + table.insert(configs, "--with-pic") + end + import("package.tools.autoconf").install(package, configs, {packagedeps = {"libunistring"}}) + end) + + on_test(function (package) + assert(package:has_cfuncs("idn2_to_ascii_8z", {includes = "idn2.h"})) + end) diff --git a/packages/l/libunistring/xmake.lua b/packages/l/libunistring/xmake.lua index d999db314..22dcd4c76 100644 --- a/packages/l/libunistring/xmake.lua +++ b/packages/l/libunistring/xmake.lua @@ -10,15 +10,13 @@ package("libunistring") add_deps("libiconv") on_install("linux", "macosx", function (package) - local configs = {"--disable-dependency-tracking", "--with-pic"} - if package:config("shared") then - table.insert(configs, "--enable-shared=yes") - table.insert(configs, "--enable-static=no") - else - table.insert(configs, "--enable-static=yes") - table.insert(configs, "--enable-shared=no") + local configs = {"--disable-dependency-tracking"} + table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no")) + table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes")) + if package:config("pic") ~= false then + table.insert(configs, "--with-pic") end - import("package.tools.autoconf").install(package, configs) + import("package.tools.autoconf").install(package, configs, {packagedeps = {"libiconv"}}) end) on_test(function (package)