xmake.lua 2.5 KB

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