xmake.lua 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package("mpfr")
  2. set_homepage("https://www.mpfr.org/")
  3. set_description("The MPFR library is a C library for multiple-precision floating-point computations with correct rounding.")
  4. set_license("LGPL-3.0")
  5. add_urls("https://www.mpfr.org/mpfr-$(version)/mpfr-$(version).tar.gz")
  6. add_versions("4.1.0", "3127fe813218f3a1f0adf4e8899de23df33b4cf4b4b3831a5314f78e65ffa2d6")
  7. add_versions("4.2.0", "f1cc1c6bb14d18f0c61cc416e083f5e697b6e0e3cf9630b9b33e8e483fc960f0")
  8. if is_plat("mingw") and is_subhost("msys") then
  9. add_extsources("pacman::mpfr")
  10. elseif is_plat("linux") then
  11. add_extsources("pacman::mpfr", "apt::libmpfr-dev")
  12. elseif is_plat("macosx") then
  13. add_extsources("brew::mpfr")
  14. end
  15. on_load(function (package)
  16. package:add("deps", "gmp", { configs = {shared = package:config("shared")} })
  17. end)
  18. on_install("@!windows and !wasm", function (package)
  19. if is_host("windows") then
  20. io.replace("configure", "LIBTOOL='$(SHELL) $(top_builddir)/libtool'", "LIBTOOL='\"$(SHELL)\" $(top_builddir)/libtool'", {plain = true})
  21. end
  22. local configs = {"--disable-dependency-tracking"}
  23. table.insert(configs, "--with-gmp=" .. package:dep("gmp"):installdir())
  24. if package:config("shared") then
  25. table.insert(configs, "--enable-shared=yes")
  26. table.insert(configs, "--enable-static=no")
  27. else
  28. table.insert(configs, "--enable-static=yes")
  29. table.insert(configs, "--enable-shared=no")
  30. end
  31. if package:config("pic") ~= false then
  32. table.insert(configs, "--with-pic")
  33. end
  34. import("package.tools.autoconf")
  35. local envs = autoconf.buildenvs(package)
  36. if envs.ARFLAGS and envs.ARFLAGS:match("^%s*$") then
  37. envs.ARFLAGS = nil
  38. end
  39. autoconf.install(package, configs, {envs = envs})
  40. end)
  41. on_test(function (package)
  42. assert(package:has_cfuncs("mpfr_get_version", {includes = "mpfr.h"}))
  43. end)