xmake.lua 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package("libiconv")
  2. set_homepage("https://www.gnu.org/software/libiconv")
  3. set_description("Character set conversion library.")
  4. set_urls("https://ftp.gnu.org/gnu/libiconv/libiconv-$(version).tar.gz",
  5. "https://ftpmirror.gnu.org/libiconv/libiconv-$(version).tar.gz")
  6. add_versions("1.16", "e6a1b1b589654277ee790cce3734f07876ac4ccfaecbee8afa0b649cf529cc04")
  7. add_versions("1.15", "ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc8913178")
  8. if is_plat("macosx") then
  9. add_patches("1.15", path.join(os.scriptdir(), "patches", "1.15", "patch-utf8mac.diff"),
  10. "e8128732f22f63b5c656659786d2cf76f1450008f36bcf541285268c66cabeab")
  11. elseif is_plat("android") then
  12. add_patches("1.x", path.join(os.scriptdir(), "patches", "1.16", "makefile.in.patch"),
  13. "d09e4212040f5adf1faa5cf5a9a18f6f79d4cdce9affb05f2e75df2ea3b3d686")
  14. end
  15. on_fetch("macosx", "linux", function (package, opt)
  16. if opt.system then
  17. return package:find_package("system::iconv", {includes = "iconv.h"})
  18. end
  19. end)
  20. on_load(function (package)
  21. package:addenv("PATH", "bin")
  22. end)
  23. on_install("windows", function (package)
  24. io.gsub("config.h.in", "%$", "")
  25. io.gsub("config.h.in", "# ?undef (.-)\n", "${define %1}\n")
  26. io.gsub("libcharset/config.h.in", "%$", "")
  27. io.gsub("libcharset/config.h.in", "# ?undef (.-)\n", "${define %1}\n")
  28. io.gsub("srclib/safe-read.c", "#include <unistd.h>", "")
  29. io.gsub("srclib/progreloc.c", "#include <unistd.h>", "")
  30. os.cp(path.join(os.scriptdir(), "port", "xmake.lua"), ".")
  31. import("package.tools.xmake").install(package, {
  32. relocatable = true,
  33. installprefix = package:installdir():gsub("\\", "\\\\"),
  34. vers = package:version_str()
  35. })
  36. end)
  37. on_install("macosx", "linux", "android", "mingw@msys", function (package)
  38. local configs = {"--disable-dependency-tracking", "--enable-extra-encodings"}
  39. if not package:is_plat("macosx") then
  40. table.insert(configs, "--enable-relocatable")
  41. end
  42. table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
  43. table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
  44. if package:debug() then
  45. table.insert(configs, "--enable-debug")
  46. end
  47. if package:config("pic") ~= false then
  48. table.insert(configs, "--with-pic")
  49. end
  50. if package:is_plat("android") then
  51. io.replace("./configure", "#define gid_t int", "")
  52. io.replace("./configure", "#define uid_t int", "")
  53. end
  54. os.vrunv("make", {"-f", "Makefile.devel", "CFLAGS=" .. (package:config("cflags") or "")})
  55. import("package.tools.autoconf").install(package, configs)
  56. end)
  57. on_test(function (package)
  58. if package:is_plat("macosx", "linux") then
  59. os.vrun("iconv --version")
  60. end
  61. assert(package:has_cfuncs("iconv_open(0, 0);", {includes = "iconv.h"}))
  62. end)