xmake.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. if is_plat("mingw") and is_subhost("msys") then
  11. add_extsources("pacman::gmp")
  12. elseif is_plat("linux") then
  13. add_extsources("pacman::gmp", "apt::libgmp-dev")
  14. elseif is_plat("macosx") then
  15. add_extsources("brew::gmp")
  16. end
  17. on_fetch(function (package, opt)
  18. if opt.system then
  19. return package:find_package("system::gmp", {includes = "gmp.h"})
  20. end
  21. end)
  22. add_deps("m4")
  23. on_install("macosx", "linux", function (package)
  24. local configs = {}
  25. table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
  26. table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
  27. if package:debug() then
  28. table.insert(configs, "--enable-debug")
  29. end
  30. if package:config("pic") ~= false then
  31. table.insert(configs, "--with-pic")
  32. end
  33. if package:is_plat("macosx") and package:is_arch("arm64") and os.arch() == "x86_64" then
  34. import("package.tools.autoconf")
  35. table.insert(configs, "--build=x86_64-apple-darwin")
  36. table.insert(configs, "--host=arm64-apple-darwin")
  37. local envs = autoconf.buildenvs(package, {cflags = "--target=arm64-apple-darwin"})
  38. envs.CC = package:build_getenv("cc") .. " -arch arm64" -- for linker flags
  39. autoconf.install(package, configs, {envs = envs})
  40. else
  41. import("package.tools.autoconf").install(package, configs)
  42. end
  43. end)
  44. on_test(function (package)
  45. assert(package:has_cfuncs("gmp_randinit", {includes = "gmp.h"}))
  46. end)