xmake.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package("ncurses")
  2. set_homepage("https://invisible-island.net/ncurses/")
  3. set_description("A free software emulation of curses.")
  4. set_license("MIT")
  5. add_urls("https://ftpmirror.gnu.org/ncurses/ncurses-$(version).tar.gz",
  6. "https://ftp.gnu.org/pub/gnu/ncurses/ncurses-$(version).tar.gz",
  7. "https://invisible-mirror.net/archives/ncurses/ncurses-$(version).tar.gz")
  8. add_versions("6.1", "aa057eeeb4a14d470101eff4597d5833dcef5965331be3528c08d99cebaa0d17")
  9. add_versions("6.2", "30306e0c76e0f9f1f0de987cf1c82a5c21e1ce6568b9227f7da5b71cbea86c9d")
  10. add_versions("6.3", "97fc51ac2b085d4cde31ef4d2c3122c21abc217e9090a43a30fc5ec21684e059")
  11. add_versions("6.4", "6931283d9ac87c5073f30b6290c4c75f21632bb4fc3603ac8100812bed248159")
  12. add_versions("6.5", "136d91bc269a9a5785e5f9e980bc76ab57428f604ce3e5a5a90cebc767971cc6")
  13. add_versions("6.6", "355b4cbbed880b0381a04c46617b7656e362585d52e9cf84a67e2009b749ff11")
  14. add_configs("widec", {description = "Compile with wide-char/UTF-8 code.", default = true, type = "boolean"})
  15. if is_plat("linux") then
  16. add_extsources("apt::libncurses-dev")
  17. end
  18. if on_check then
  19. on_check("mingw", function(package)
  20. if is_subhost("macosx") then
  21. assert(package:version():lt("6.6"), "package(ncurses >= 6.6): unsupported version on mingw@macosx.")
  22. end
  23. end)
  24. end
  25. on_load(function (package)
  26. if package:is_cross() then
  27. package:add("deps", "ncurses", {private = true, host = true})
  28. end
  29. if package:config("widec") then
  30. package:add("links", "ncursesw", "formw", "panelw", "menuw")
  31. package:add("includedirs", "include/ncursesw", "include")
  32. else
  33. package:add("links", "ncurses", "form", "panel", "menu")
  34. package:add("includedirs", "include/ncurses", "include")
  35. end
  36. if not package:config("shared") then
  37. package:add("defines", "NCURSES_STATIC")
  38. end
  39. end)
  40. on_install("!wasm and !iphoneos and @!windows", function (package)
  41. local configs = {
  42. "--without-manpages",
  43. "--enable-sigwinch",
  44. -- Prevent `strip` command issues with cross-compiled binaries
  45. "--disable-stripping",
  46. "--with-gpm=no",
  47. "--without-tests",
  48. "--without-ada",
  49. "--enable-pc-files",
  50. "--with-pkg-config-libdir=" .. path.unix(package:installdir("lib", "pkgconfig")):gsub("^(%a):", "/%1"),
  51. }
  52. table.insert(configs, "--with-debug=" .. (package:is_debug() and "yes" or "no"))
  53. table.insert(configs, "--with-shared=" .. (package:config("shared") and "yes" or "no"))
  54. table.insert(configs, "--enable-widec=" .. (package:config("widec") and "yes" or "no"))
  55. if not package:is_cross() then
  56. package:addenv("PATH", "bin")
  57. else
  58. local ncurses_host = package:dep("ncurses")
  59. if ncurses_host then
  60. local tic = path.join(ncurses_host:installdir("bin"), "tic" .. (is_host("windows") and ".exe" or ""))
  61. if os.isexec(tic) then
  62. table.insert(configs, "--with-tic-path=" .. path.unix(tic))
  63. end
  64. end
  65. end
  66. local cflags = {}
  67. if package:version():le("6.6") then
  68. table.insert(cflags, "-std=c17")
  69. end
  70. if package:is_plat("mingw", "cygwin", "msys") then
  71. table.insert(configs, "--enable-term-driver")
  72. table.insert(cflags, "-D__USE_MINGW_ACCESS") -- Pass X_OK to access() on Windows which isn't supported with ucrt
  73. end
  74. import("package.tools.autoconf").install(package, configs, {cflags = cflags, arflags = {"-curvU"}})
  75. for _, file in ipairs(os.files(path.join(package:installdir("include"), "**.h"))) do
  76. io.replace(file, "#include <ncursesw/(.-)>", '#include "%1"', {plain = false})
  77. end
  78. end)
  79. on_test(function (package)
  80. assert(package:has_cfuncs("initscr", {includes = "curses.h"}))
  81. end)