xmake.lua 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. package("gettext")
  2. set_homepage("https://www.gnu.org/software/gettext/")
  3. set_description("GNU internationalization (i18n) and localization (l10n) library.")
  4. set_urls("https://mirrors.dotsrc.org/gnu/gettext/gettext-$(version).tar.xz",
  5. "https://ftpmirror.gnu.org/gettext/gettext-$(version).tar.xz",
  6. "https://ftp.gnu.org/gnu/gettext/gettext-$(version).tar.xz",
  7. {version = function (version) return version:gsub('%-', '.') end})
  8. add_versions("0.19.8-1", "105556dbc5c3fbbc2aa0edb46d22d055748b6f5c7cd7a8d99f8e7eb84e938be4")
  9. add_versions("0.21", "d20fcbb537e02dcf1383197ba05bd0734ef7bf5db06bdb241eb69b7d16b73192")
  10. add_versions("0.21.1", "50dbc8f39797950aa2c98e939947c527e5ac9ebd2c1b99dd7b06ba33a6767ae6")
  11. add_versions("0.22.5", "fe10c37353213d78a5b83d48af231e005c4da84db5ce88037d88355938259640")
  12. add_versions("0.23.1", "c1f97a72a7385b7e71dd07b5fea6cdaf12c9b88b564976b23bd8c11857af2970")
  13. add_versions("0.24.1", "6164ec7aa61653ac9cdfb41d5c2344563b21f707da1562712e48715f1d2052a6")
  14. add_versions("0.25", "05240b29f5b0f422e5a4ef8e9b5f76d8fa059cc057693d2723cdb76f36a88ab0")
  15. if is_plat("macosx") then
  16. add_frameworks("CoreFoundation")
  17. end
  18. add_deps("libiconv")
  19. on_load(function(package)
  20. if is_subhost("windows") then
  21. -- get msys2 sh to avoid using git sh
  22. local msystem = "MINGW" .. (package:is_arch64() and "64" or "32")
  23. package:add("deps", "msys2", {configs = {msystem = msystem, base_devel = true, gcc = true, make = true}})
  24. end
  25. end)
  26. on_install("macosx", "linux", "android", function (package)
  27. local configs = {"--disable-dependency-tracking",
  28. "--disable-silent-rules",
  29. "--with-included-glib",
  30. "--with-included-libcroco",
  31. "--with-included-libunistring",
  32. "--with-lispdir=#{elisp}",
  33. "--disable-java",
  34. "--disable-csharp",
  35. "--without-emacs",
  36. "--without-git",
  37. "--without-bzip2",
  38. "--without-cvs",
  39. "--without-xz"}
  40. table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
  41. table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
  42. if package:debug() then
  43. table.insert(configs, "--enable-debug")
  44. end
  45. if package:config("pic") ~= false then
  46. table.insert(configs, "--with-pic")
  47. end
  48. if package:is_plat("macosx") then
  49. table.insert(configs, "--with-included-gettext")
  50. end
  51. local cflags = {}
  52. local ldflags = {}
  53. for _, dep in ipairs(package:orderdeps()) do
  54. local fetchinfo = dep:fetch()
  55. if fetchinfo then
  56. for _, includedir in ipairs(fetchinfo.includedirs or fetchinfo.sysincludedirs) do
  57. table.insert(cflags, "-I" .. includedir)
  58. end
  59. for _, linkdir in ipairs(fetchinfo.linkdirs) do
  60. table.insert(ldflags, "-L" .. linkdir)
  61. end
  62. for _, link in ipairs(fetchinfo.links) do
  63. table.insert(ldflags, "-l" .. link)
  64. end
  65. end
  66. end
  67. import("package.tools.autoconf")
  68. if package:is_plat("android") then
  69. if package:version():le("0.20") then
  70. io.replace("./gettext-tools/configure", "#define gid_t int", "")
  71. io.replace("./gettext-tools/configure", "#define uid_t int", "")
  72. io.replace("./gettext-runtime/configure", "#define gid_t int", "")
  73. io.replace("./gettext-runtime/configure", "#define uid_t int", "")
  74. io.replace("./gettext-tools/gnulib-lib/spawn.in.h", "@HAVE_SPAWN_H@", "0")
  75. io.replace("./gettext-tools/gnulib-lib/spawn.in.h", "@HAVE_POSIX_SPAWNATTR_T@", "0")
  76. io.replace("./gettext-tools/gnulib-lib/spawn.in.h", "@HAVE_POSIX_SPAWN_FILE_ACTIONS_T@", "0")
  77. io.replace("./gettext-runtime/src/Makefile.in",
  78. "bin_PROGRAMS = gettext$(EXEEXT) ngettext$(EXEEXT) envsubst$(EXEEXT)",
  79. "bin_PROGRAMS =", {plain = true})
  80. io.replace("./gettext-tools/src/Makefile.in",
  81. "bin_PROGRAMS = .*noinst_PROGRAMS =",
  82. "bin_PROGRAMS =\nnoinst_PROGRAMS =")
  83. io.replace("./gettext-tools/src/Makefile.in",
  84. "noinst_PROGRAMS = hostname$(EXEEXT) urlget$(EXEEXT) \\",
  85. "bin_PROGRAMS =", {plain = true})
  86. io.replace("./gettext-tools/src/Makefile.in",
  87. "cldr-plurals$(EXEEXT)",
  88. "", {plain = true})
  89. io.replace("./gettext-tools/src/Makefile.in",
  90. "install-exec-local:",
  91. "install-exec-local: \n\ninstall-exec-local_: ", {plain = true})
  92. io.replace("./gettext-tools/config.h.in", "#undef ICONV_CONST", "#define ICONV_CONST const")
  93. io.replace("./gettext-runtime/config.h.in", "#undef ICONV_CONST", "#define ICONV_CONST const")
  94. io.replace("./gettext-tools/libgrep/langinfo.in.h", "@HAVE_LANGINFO_H@", "0")
  95. io.replace("./gettext-tools/gnulib-lib/langinfo.in.h", "@HAVE_LANGINFO_H@", "0")
  96. io.replace("./gettext-runtime/gnulib-lib/langinfo.in.h", "@HAVE_LANGINFO_H@", "0")
  97. end
  98. if is_subhost("windows") then
  99. import("core.base.option")
  100. -- needed to avoid link errors to rpl_fputc, rpl_write, ...
  101. -- rpl_* variants are enabled because SIGPIPE check fail, but i don't understand why, as i'm not very knowledgeable on msys2 and android, the fix is for now is this hack
  102. for _, conffile in ipairs({"./configure", "./gettext-tools/configure", "./gettext-runtime/configure"}) do
  103. io.replace(conffile, "REPLACE_STDIO_WRITE_FUNCS=1", "REPLACE_STDIO_WRITE_FUNCS=0")
  104. io.replace(conffile, "REPLACE_WRITE=1", "REPLACE_WRITE=0")
  105. end
  106. local envs = os.joinenvs(autoconf.buildenvs(package, {cflags = cflags, ldflags = ldflags}), os.getenvs())
  107. envs.SHELL = "sh"
  108. autoconf.configure(package, configs, {envs = envs})
  109. local njob = option.get("jobs") or tostring(os.default_njob())
  110. local argv = {"-j" .. njob}
  111. if option.get("verbose") then
  112. table.insert(argv, "V=1")
  113. end
  114. -- using execv instead of vrunv is needed when compiling on windows, otherwise it fail with
  115. -- ../libtool: line 3331: 0: Bad file descriptor
  116. -- when -v is not supplied to xmake
  117. assert(os.execv("make", argv, {shell = true, envs = envs}))
  118. assert(os.execv("make", table.join({"install"}, argv), {shell = true, envs = envs}))
  119. end
  120. end
  121. if not is_subhost("windows") then
  122. autoconf.install(package, configs, {cflags = cflags, ldflags = ldflags})
  123. end
  124. package:addenv("PATH", "bin")
  125. end)
  126. on_test(function (package)
  127. assert(package:has_cfuncs("ngettext", {includes = "libintl.h"}))
  128. end)