xmake.lua 4.8 KB

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