xmake.lua 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. if is_plat("macosx") then
  11. add_deps("libiconv", {system = true})
  12. add_frameworks("CoreFoundation")
  13. else
  14. add_deps("libiconv")
  15. end
  16. on_install("macosx", "linux", "android", function (package)
  17. local configs = {"--disable-dependency-tracking",
  18. "--disable-silent-rules",
  19. "--with-included-glib",
  20. "--with-included-libcroco",
  21. "--with-included-libunistring",
  22. "--with-lispdir=#{elisp}",
  23. "--disable-java",
  24. "--disable-csharp",
  25. "--without-emacs",
  26. "--without-git",
  27. "--without-bzip2",
  28. "--without-cvs",
  29. "--without-xz"}
  30. table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
  31. table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
  32. if package:debug() then
  33. table.insert(configs, "--enable-debug")
  34. end
  35. if package:config("pic") ~= false then
  36. table.insert(configs, "--with-pic")
  37. end
  38. if package:is_plat("macosx") then
  39. table.insert(configs, "--with-included-gettext")
  40. end
  41. if package:is_plat("android") and package:version():le("0.20") then
  42. io.replace("./gettext-tools/configure", "#define gid_t int", "")
  43. io.replace("./gettext-tools/configure", "#define uid_t int", "")
  44. io.replace("./gettext-runtime/configure", "#define gid_t int", "")
  45. io.replace("./gettext-runtime/configure", "#define uid_t int", "")
  46. io.replace("./gettext-tools/gnulib-lib/spawn.in.h", "@HAVE_SPAWN_H@", "0")
  47. io.replace("./gettext-tools/gnulib-lib/spawn.in.h", "@HAVE_POSIX_SPAWNATTR_T@", "0")
  48. io.replace("./gettext-tools/gnulib-lib/spawn.in.h", "@HAVE_POSIX_SPAWN_FILE_ACTIONS_T@", "0")
  49. io.replace("./gettext-runtime/src/Makefile.in",
  50. "bin_PROGRAMS = gettext$(EXEEXT) ngettext$(EXEEXT) envsubst$(EXEEXT)",
  51. "bin_PROGRAMS =", {plain = true})
  52. io.replace("./gettext-tools/src/Makefile.in",
  53. "bin_PROGRAMS = .*noinst_PROGRAMS =",
  54. "bin_PROGRAMS =\nnoinst_PROGRAMS =")
  55. io.replace("./gettext-tools/src/Makefile.in",
  56. "noinst_PROGRAMS = hostname$(EXEEXT) urlget$(EXEEXT) \\",
  57. "bin_PROGRAMS =", {plain = true})
  58. io.replace("./gettext-tools/src/Makefile.in",
  59. "cldr-plurals$(EXEEXT)",
  60. "", {plain = true})
  61. io.replace("./gettext-tools/src/Makefile.in",
  62. "install-exec-local:",
  63. "install-exec-local: \n\ninstall-exec-local_: ", {plain = true})
  64. io.replace("./gettext-tools/config.h.in", "#undef ICONV_CONST", "#define ICONV_CONST const")
  65. io.replace("./gettext-runtime/config.h.in", "#undef ICONV_CONST", "#define ICONV_CONST const")
  66. io.replace("./gettext-tools/libgrep/langinfo.in.h", "@HAVE_LANGINFO_H@", "0")
  67. io.replace("./gettext-tools/gnulib-lib/langinfo.in.h", "@HAVE_LANGINFO_H@", "0")
  68. io.replace("./gettext-runtime/gnulib-lib/langinfo.in.h", "@HAVE_LANGINFO_H@", "0")
  69. end
  70. local cflags = {}
  71. local ldflags = {}
  72. for _, dep in ipairs(package:orderdeps()) do
  73. local fetchinfo = dep:fetch()
  74. if fetchinfo then
  75. for _, includedir in ipairs(fetchinfo.includedirs or fetchinfo.sysincludedirs) do
  76. table.insert(cflags, "-I" .. includedir)
  77. end
  78. for _, linkdir in ipairs(fetchinfo.linkdirs) do
  79. table.insert(ldflags, "-L" .. linkdir)
  80. end
  81. for _, link in ipairs(fetchinfo.links) do
  82. table.insert(ldflags, "-l" .. link)
  83. end
  84. end
  85. end
  86. import("package.tools.autoconf").install(package, configs, {cflags = cflags, ldflags = ldflags})
  87. package:addenv("PATH", "bin")
  88. end)
  89. on_test(function (package)
  90. assert(package:has_cfuncs("ngettext", {includes = "libintl.h"}))
  91. end)