xmake.lua 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package("gmp")
  2. set_homepage("https://gmplib.org/")
  3. set_description("GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating-point numbers.")
  4. set_license("LGPL-3.0")
  5. add_urls("https://ftpmirror.gnu.org/gmp/gmp-$(version).tar.xz")
  6. add_urls("https://ftp.gnu.org/gnu/gmp/gmp-$(version).tar.xz")
  7. add_urls("https://gmplib.org/download/gmp/gmp-$(version).tar.xz")
  8. add_versions("6.2.1", "fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2")
  9. add_versions("6.3.0", "a3c2b80201b89e68616f4ad30bc66aee4927c3ce50e33929ca819d5c43538898")
  10. add_patches("6.3.0", "patches/6.3.0/gmp-gcc-15.patch", "c9be4854bee73af5ea028fcb6ed5ba5627d40f259d46bcfee4cd67e613173f7b")
  11. if is_plat("mingw") and is_subhost("msys") then
  12. add_extsources("pacman::gmp")
  13. elseif is_plat("linux") then
  14. add_extsources("pacman::gmp", "apt::libgmp-dev")
  15. elseif is_plat("macosx") then
  16. add_extsources("brew::gmp")
  17. end
  18. on_fetch(function (package, opt)
  19. if opt.system then
  20. return package:find_package("system::gmp", {includes = "gmp.h"})
  21. end
  22. end)
  23. add_deps("m4")
  24. on_install("@!windows and !wasm", function (package)
  25. if is_host("windows") then
  26. io.replace("configure", "LIBTOOL='$(SHELL) $(top_builddir)/libtool'", "LIBTOOL='\"$(SHELL)\" $(top_builddir)/libtool'", {plain = true})
  27. end
  28. local configs = {}
  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") and package:is_arch("arm64") and os.arch() == "x86_64" then
  38. import("package.tools.autoconf")
  39. table.insert(configs, "--build=x86_64-apple-darwin")
  40. table.insert(configs, "--host=arm64-apple-darwin")
  41. local envs = autoconf.buildenvs(package, {cflags = "--target=arm64-apple-darwin"})
  42. envs.CC = package:build_getenv("cc") .. " -arch arm64" -- for linker flags
  43. autoconf.install(package, configs, {envs = envs})
  44. else
  45. import("package.tools.autoconf").install(package, configs)
  46. end
  47. end)
  48. on_test(function (package)
  49. assert(package:has_cfuncs("gmp_randinit", {includes = "gmp.h"}))
  50. end)