xmake.lua 7.3 KB

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