xmake.lua 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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_configs("widec", {description = "Compile with wide-char/UTF-8 code.", default = true, type = "boolean"})
  14. if is_plat("linux") then
  15. add_extsources("apt::libncurses-dev")
  16. end
  17. on_load(function (package)
  18. if package:is_cross() then
  19. package:add("deps", "ncurses", {private = true, host = true})
  20. end
  21. if package:config("widec") then
  22. package:add("links", "ncursesw", "formw", "panelw", "menuw")
  23. package:add("includedirs", "include/ncursesw", "include")
  24. else
  25. package:add("links", "ncurses", "form", "panel", "menu")
  26. package:add("includedirs", "include/ncurses", "include")
  27. end
  28. if not package:config("shared") then
  29. package:add("defines", "NCURSES_STATIC")
  30. end
  31. end)
  32. on_install("!wasm and !iphoneos and @!windows", function (package)
  33. local configs = {
  34. "--without-manpages",
  35. "--enable-sigwinch",
  36. -- Prevent `strip` command issues with cross-compiled binaries
  37. "--disable-stripping",
  38. "--with-gpm=no",
  39. "--without-tests",
  40. "--without-ada",
  41. "--enable-pc-files",
  42. "--with-pkg-config-libdir=" .. path.unix(package:installdir("lib", "pkgconfig")):gsub("^(%a):", "/%1"),
  43. }
  44. table.insert(configs, "--with-debug=" .. (package:is_debug() and "yes" or "no"))
  45. table.insert(configs, "--with-shared=" .. (package:config("shared") and "yes" or "no"))
  46. table.insert(configs, "--enable-widec=" .. (package:config("widec") and "yes" or "no"))
  47. if not package:is_cross() then
  48. package:addenv("PATH", "bin")
  49. else
  50. local ncurses_host = package:dep("ncurses")
  51. if ncurses_host then
  52. local tic = path.join(ncurses_host:installdir("bin"), "tic" .. (is_host("windows") and ".exe" or ""))
  53. if os.isexec(tic) then
  54. table.insert(configs, "--with-tic-path=" .. path.unix(tic))
  55. end
  56. end
  57. end
  58. local cflags = {}
  59. if package:version():le("6.5") then
  60. table.insert(cflags, "-std=c17")
  61. end
  62. if package:is_plat("mingw", "cygwin", "msys") then
  63. table.insert(configs, "--enable-term-driver")
  64. table.insert(cflags, "-D__USE_MINGW_ACCESS") -- Pass X_OK to access() on Windows which isn't supported with ucrt
  65. end
  66. import("package.tools.autoconf").install(package, configs, {cflags = cflags, arflags = {"-curvU"}})
  67. end)
  68. on_test(function (package)
  69. assert(package:has_cfuncs("initscr", {includes = "curses.h"}))
  70. end)