xmake.lua 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package("readline")
  2. set_homepage("https://tiswww.case.edu/php/chet/readline/rltop.html")
  3. set_description("Library for command-line editing")
  4. set_license("GPL-3.0-or-later")
  5. add_urls("https://ftpmirror.gnu.org/readline/readline-$(version).tar.gz",
  6. "https://ftp.gnu.org/gnu/readline/readline-$(version).tar.gz")
  7. add_versions("8.2.13", "0e5be4d2937e8bd9b7cd60d46721ce79f88a33415dd68c2d738fb5924638f656")
  8. add_versions("8.2", "3feb7171f16a84ee82ca18a36d7b9be109a52c04f492a053331d7d1095007c35")
  9. add_versions("8.1", "f8ceb4ee131e3232226a17f51b164afc46cd0b9e6cef344be87c65962cb82b02")
  10. if is_plat("mingw", "cygwin", "msys") then
  11. add_patches("8.2.13", "patches/8.2.13/mingw_fd_set.patch", "3b5576e51471b248f5c89e0d4c01ac0bc443a239169fa19e25980f9a923f659a")
  12. end
  13. add_deps("ncurses")
  14. on_install("!wasm and !iphoneos and @!windows", function (package)
  15. local configs = {"--with-curses", "--disable-install-examples"}
  16. table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
  17. table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
  18. io.replace("support/shobj-conf", "-Wl,-rpath,$(libdir)", "", {plain = true}) -- Remove RPATH from shared objects (FS#14366)
  19. local makefile_inputs = {"Makefile.in", "shlib/Makefile.in"}
  20. local SHLIB_LIBS = package:dep("ncurses"):config("widec") and "-lncursesw" or "-lncurses"
  21. for _, makefile_input in ipairs(makefile_inputs) do
  22. io.replace(makefile_input, "@SHLIB_LIBS@", SHLIB_LIBS, {plain = true})
  23. end
  24. if is_host("windows") then
  25. -- Avoid issues with /c/dir style paths
  26. for _, makefile_input in ipairs(makefile_inputs) do
  27. io.replace(makefile_input, "@BUILD_DIR@", path.unix(os.curdir()), {plain = true}) -- C:/dir
  28. end
  29. end
  30. local cflags = {}
  31. if package:version():le("8.2.13") then
  32. table.insert(cflags, "-std=c17")
  33. end
  34. if package:is_plat("mingw", "cygwin", "msys") then
  35. table.insert(cflags, "-DNEED_EXTERN_PC=1") -- Use extern PC variable from ncurses
  36. table.join2(cflags, {"-D__USE_MINGW_ALARM", "-D_POSIX"}) -- Make mingw-w64 provide a dummy alarm() function
  37. io.replace("support/shobj-conf", "--export-all", "--export-all-symbols", {plain = true})
  38. end
  39. import("package.tools.autoconf").install(package, configs, {cflags = cflags, packagedeps = {"ncurses"}})
  40. end)
  41. on_test(function (package)
  42. assert(package:has_cfuncs("readline", {includes = {"stdio.h", "readline/readline.h"}}))
  43. end)