xmake.lua 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package("m4")
  2. set_kind("binary")
  3. set_homepage("https://www.gnu.org/software/m4")
  4. set_description("Macro processing language")
  5. add_urls("https://ftpmirror.gnu.org/m4/m4-$(version).tar.xz",
  6. "https://ftp.gnu.org/gnu/m4/m4-$(version).tar.xz",
  7. "https://mirrors.ustc.edu.cn/gnu/m4/m4-$(version).tar.xz")
  8. add_versions("1.4.18", "f2c1e86ca0a404ff281631bdc8377638992744b175afb806e25871a24a934e07")
  9. add_versions("1.4.19", "63aede5c6d33b6d9b13511cd0be2cac046f2e70fd0a07aa9573a04a82783af96")
  10. if is_host("macosx") then
  11. -- fix crash from usage of %n in dynamic format strings on High Sierra
  12. -- patch credit to Jeremy Huddleston Sequoia <[email protected]>
  13. add_patches("1.4.18", path.join(os.scriptdir(), "patches", "1.4.18", "secure_snprintf.patch"), "c0a408fbffb7255fcc75e26bd8edab116fc81d216bfd18b473668b7739a4158e")
  14. elseif is_host("linux") then
  15. add_extsources("apt::m4", "pacman::m4")
  16. end
  17. on_install("@macosx", "@linux", "@msys", "@cygwin", "@bsd", function (package)
  18. io.writefile("tests/select.c", "int main(int argc, char **argv) { return 0; }\n") -- Bypass "select" function check
  19. if package:is_plat("linux") then
  20. -- fix freadahead.c:92:3: error: #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."
  21. -- https://git.savannah.gnu.org/cgit/gnulib.git
  22. for _, gnulib_file in ipairs(os.files("lib/*.c")) do
  23. io.replace(gnulib_file, "defined _IO_ftrylockfile", "defined _IO_EOF_SEEN || defined _IO_ftrylockfile")
  24. end
  25. local file = io.open("lib/stdio-impl.h", "a+")
  26. file:write([[
  27. #if defined _IO_EOF_SEEN
  28. # if !defined _IO_UNBUFFERED
  29. # define _IO_UNBUFFERED 0x2
  30. # endif
  31. # if !defined _IO_IN_BACKUP
  32. # define _IO_IN_BACKUP 0x100
  33. # endif
  34. #endif]])
  35. file:close()
  36. end
  37. local configs = {"--disable-dependency-tracking"}
  38. local opt = {}
  39. -- https://mail.gnu.org/archive/html/bug-m4/2024-11/msg00000.html
  40. opt.cflags = "-std=gnu99"
  41. import("package.tools.autoconf").install(package, configs, opt)
  42. end)
  43. on_test(function (package)
  44. os.vrun("m4 --version")
  45. end)