xmake.lua 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. package("scotch")
  2. set_homepage("https://www.labri.fr/perso/pelegrin/scotch/")
  3. set_description("Scotch: a software package for graph and mesh/hypergraph partitioning, graph clustering, and sparse matrix ordering")
  4. add_urls("https://gitlab.inria.fr/scotch/scotch/-/archive/$(version)/scotch-$(version).zip",
  5. "https://gitlab.inria.fr/scotch/scotch.git")
  6. add_versions("v6.1.1", "21d001c390ec63ac60f987b9921f33cc1967b41cf07567e22cbf3253cda8962a")
  7. add_versions("v7.0.5", "fd52e97844115dce069220bacbfb45fccdf83d425614b02b67b44cedf9d72640")
  8. if is_plat("windows", "mingw", "msys", "bsd") then
  9. add_patches("7.0.5", "patches/7.0.5/cmake.patch", "5104181d78dcf31779ab70cae61bb80fa2f6f836ce5d73628ef9b2d074fb8d8c")
  10. end
  11. add_configs("zlib", {description = "Use ZLIB compression format.", default = true, type = "boolean"})
  12. add_configs("lzma", {description = "Use LZMA compression format.", default = false, type = "boolean"})
  13. add_configs("bz2", {description = "Use BZ2 compression format.", default = false, type = "boolean"})
  14. if is_plat("linux", "bsd") then
  15. add_syslinks("pthread")
  16. end
  17. add_links("ptesmumps", "esmumps", "scotch", "scotcherr", "scotcherrexit", "scotchmetis", "scotchmetisv5", "scotchmetisv3")
  18. if on_check then
  19. on_check(function (package)
  20. if package:is_cross() then
  21. raise("package(scotch) unsupported cross-compilation")
  22. end
  23. end)
  24. end
  25. on_load(function (package)
  26. if package:gitref() or package:version():ge("7.0.0") then
  27. package:add("deps", "cmake")
  28. package:add("deps", "flex", "bison")
  29. if package:is_plat("linux", "macosx") then
  30. package:add("deps", "gfortran", {kind = "binary"})
  31. end
  32. if package:config("zlib") then
  33. package:add("deps", "zlib")
  34. end
  35. if package:config("lzma") then
  36. package:add("deps", "xz")
  37. end
  38. if package:config("bz2") then
  39. package:add("deps", "bzip2")
  40. end
  41. else
  42. package:add("deps", "zlib")
  43. end
  44. end)
  45. -- mingw require to fix xrepo flex package
  46. on_install("windows|x64", "windows|arm64", "linux", "macosx", "bsd", function (package)
  47. if package:gitref() or package:version():ge("7.0.0") then
  48. local configs = {"-DENABLE_TESTS=OFF", "-DBUILD_PTSCOTCH=OFF"}
  49. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  50. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  51. table.insert(configs, "-DUSE_ZLIB=" .. (package:config("zlib") and "ON" or "OFF"))
  52. table.insert(configs, "-DUSE_LZMA=" .. (package:config("lzma") and "ON" or "OFF"))
  53. table.insert(configs, "-DUSE_BZ2=" .. (package:config("bz2") and "ON" or "OFF"))
  54. if package:is_plat("windows") then
  55. os.mkdir(path.join(package:buildir(), "src/scotch/pdb"))
  56. os.mkdir(path.join(package:buildir(), "src/esmumps/pdb"))
  57. os.mkdir(path.join(package:buildir(), "src/libscotch/pdb"))
  58. os.mkdir(path.join(package:buildir(), "src/libscotchmetis/pdb"))
  59. if package:config("shared") then
  60. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  61. end
  62. end
  63. import("package.tools.cmake").install(package, configs)
  64. elseif package:is_plat("macosx", "linux") then
  65. import("package.tools.make")
  66. os.cd("src")
  67. if package:is_plat("macosx") then
  68. os.cp("Make.inc/Makefile.inc.i686_mac_darwin10", "Makefile.inc")
  69. elseif package:is_plat("linux") then
  70. local basename
  71. if package:is_arch("x86_64") then
  72. basename = "Make.inc/Makefile.inc.x86-64_pc_linux2"
  73. elseif package:is_arch("i386", "x86") then
  74. basename = "Make.inc/Makefile.inc.i686_pc_linux2"
  75. end
  76. os.cp(basename .. (package:config("shared") and ".shlib" or ""), "Makefile.inc")
  77. end
  78. io.replace("Makefile.inc", "CFLAGS%s+=", "CFLAGS := $(CFLAGS)")
  79. io.replace("Makefile.inc", "LDFLAGS%s+=", "LDFLAGS := $(LDFLAGS)")
  80. local envs = make.buildenvs(package)
  81. local zlib = package:dep("zlib"):fetch()
  82. if zlib then
  83. local cflags, ldflags
  84. for _, includedir in ipairs(zlib.sysincludedirs or zlib.includedirs) do
  85. cflags = (cflags or "") .. " -I" .. includedir
  86. end
  87. for _, linkdir in ipairs(zlib.linkdirs) do
  88. ldflags = (ldflags or "") .. " -L" .. linkdir
  89. end
  90. envs.CFLAGS = cflags
  91. envs.LDFLAGS = ldflags
  92. end
  93. make.make(package, {"scotch"}, {envs = envs})
  94. make.make(package, {"esmumps"}, {envs = envs})
  95. make.make(package, {"prefix=" .. package:installdir(), "install"}, {envs = envs})
  96. else
  97. raise("Unsupported platform!")
  98. end
  99. end)
  100. on_test(function (package)
  101. assert(package:has_cfuncs("SCOTCH_graphInit", {includes = {"stdio.h", "stdlib.h", "scotch.h"}}))
  102. end)