xmake.lua 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package("libntl")
  2. set_homepage("https://libntl.org/")
  3. set_description("NTL: A Library for doing Number Theory")
  4. set_license("LGPL-2.1")
  5. add_urls("https://github.com/libntl/ntl/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/libntl/ntl.git")
  7. add_versions("v11.5.1", "ef578fa8b6c0c64edd1183c4c303b534468b58dd3eb8df8c9a5633f984888de5")
  8. add_deps("gmp")
  9. on_install("macosx|native", "linux|native", function (package)
  10. local gmp = package:dep("gmp")
  11. local gmp_prefix = "";
  12. if gmp and not gmp:is_system() then
  13. gmp_prefix = gmp:installdir()
  14. end
  15. local compiler = package:build_getenv("cxx")
  16. if package:is_plat("macosx") then
  17. local cc = package:build_getenv("ld")
  18. if cc and cc:find("clang", 1, true) and cc:find("Xcode", 1, true) then
  19. compiler = "xcrun --sdk macosx clang++"
  20. end
  21. end
  22. compiler = compiler:gsub("gcc$", "g++")
  23. compiler = compiler:gsub("clang$", "clang++")
  24. os.cd("src")
  25. os.vrunv("./configure", {
  26. "CXX=" .. compiler,
  27. "CXXFLAGS=" .. table.concat(table.wrap(package:build_getenv("cxxflags")), " "),
  28. "AR=" .. (package:build_getenv("ar") or "ar"),
  29. "ARFLAGS=" .. table.concat(table.wrap(package:build_getenv("arflags") or "ruv"), " "),
  30. "RANLIB=" .. (package:build_getenv("ranlib") or "ranlib"),
  31. "LDFLAGS=" .. table.concat(table.wrap(package:build_getenv("ldflags")), " "),
  32. "CPPFLAGS=" .. table.concat(table.wrap(package:build_getenv("cppflags")), " "),
  33. "PREFIX=" .. package:installdir(),
  34. "GMP_PREFIX=" .. gmp_prefix,
  35. "SHARED=" .. (package:config("shared") and "on" or "off")
  36. }, {shell = true})
  37. os.vrunv("make", {})
  38. os.vrunv("make", {"install"})
  39. if package:config("shared") then
  40. os.rm(path.join(package:installdir(), "lib", "libntl.a"))
  41. end
  42. end)
  43. on_test(function (package)
  44. assert(package:check_cxxsnippets({test = [[
  45. #include <NTL/ZZ.h>
  46. #include <iostream>
  47. #include <cassert>
  48. void test() {
  49. NTL::ZZ a{2}, b{3}, c;
  50. c = (a + 1) * (b + 1);
  51. std::cout << c << std::endl;
  52. }
  53. ]]}, {configs = {languages = "cxx11"}}))
  54. end)