Skip to content

Commit 48fb759

Browse files
Univstarxq114
andauthored
add fmm3d (#8664)
Co-authored-by: Inari0 <[email protected]>
1 parent 389c1fe commit 48fb759

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

packages/f/fmm3d/xmake.lua

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package("fmm3d")
2+
set_homepage("https://fmm3d.readthedocs.io/")
3+
set_description("A set of libraries to compute N-body interactions governed by the Laplace and Helmholtz equations, to a specified precision, in three dimensions, on a multi-core shared-memory machine.")
4+
set_license("Apache-2.0")
5+
6+
set_urls("https://github.com/flatironinstitute/FMM3D/archive/refs/tags/$(version).zip",
7+
"https://github.com/flatironinstitute/FMM3D.git")
8+
add_versions("v1.0.4", "59fa04965cd46cd564ba4784d91f00f8b0d24e0a08967a7b90f076dd5eb30faf")
9+
10+
if is_plat("windows") then
11+
add_deps("mingw-w64", "make")
12+
end
13+
14+
on_install("linux", "macosx", "windows", function (package)
15+
if package:is_plat("windows") then
16+
os.cp("make.inc.windows.mingw", "make.inc")
17+
18+
io.replace("makefile", "mkdir -p $(FMM_INSTALL_DIR)", "", {plain = true})
19+
io.replace("makefile", "cp -f lib/$(DYNAMICLIB) $(FMM_INSTALL_DIR)/", "copy /y lib\\$(DYNAMICLIB) $(FMM_INSTALL_DIR)", {plain = true})
20+
io.replace("makefile", "cp -f lib-static/$(STATICLIB) $(FMM_INSTALL_DIR)/", "copy /y lib-static\\$(STATICLIB) $(FMM_INSTALL_DIR)", {plain = true})
21+
io.replace("makefile", "[ ! -f lib/$(LIMPLIB) ] || cp lib/$(LIMPLIB) $(FMM_INSTALL_DIR)/", "if exist lib\\$(LIMPLIB) copy lib\\$(LIMPLIB) $(FMM_INSTALL_DIR)", {plain = true})
22+
23+
io.replace("makefile", "mv $(STATICLIB) lib-static/", "move $(STATICLIB) lib-static", {plain = true})
24+
io.replace("makefile", "mv $(DYNAMICLIB) lib/", "move $(DYNAMICLIB) lib", {plain = true})
25+
io.replace("makefile", "[ ! -f $(LIMPLIB) ] || mv $(LIMPLIB) lib/", "if exist $(LIMPLIB) move $(LIMPLIB) lib", {plain = true})
26+
27+
io.replace("makefile", "\" $(FMM_INSTALL_DIR) \"", "$(FMM_INSTALL_DIR)", {plain = true})
28+
io.replace("makefile", "\"$(FMM_INSTALL_DIR) \"", "$(FMM_INSTALL_DIR)", {plain = true})
29+
elseif package:is_plat("macosx") then
30+
os.cp("make.inc.macos.gnu", "make.inc")
31+
end
32+
33+
import("package.tools.make").build(package, {"install", "PREFIX=" .. package:installdir("lib")})
34+
35+
local preface = " #pragma once\n\n #include <stdint.h>\n"
36+
local ex_begin = "\n #ifdef __cplusplus\n extern \"C\" {\n #endif\n"
37+
local ex_end = "\n #ifdef __cplusplus\n }\n #endif\n"
38+
39+
io.replace("c/lfmm3d_c.h", "#include \"utils.h\"\n", "", {plain = true})
40+
local lfmm3d_h = io.readfile("c/lfmm3d_c.h")
41+
lfmm3d_h = preface .. ex_begin .. lfmm3d_h .. ex_end
42+
io.writefile("c/lfmm3d_c.h", lfmm3d_h)
43+
44+
io.replace("c/hfmm3d_c.h", "#include \"utils.h\"\n", "", {plain = true})
45+
local hfmm3d_h = io.readfile("c/hfmm3d_c.h")
46+
if package:is_plat("windows") then
47+
hfmm3d_h = preface .. " #include <complex.h>\n\n typedef _Dcomplex CPX;\n" .. ex_begin .. hfmm3d_h .. ex_end
48+
else
49+
hfmm3d_h = preface .. " #include <complex.h>\n\n typedef double complex CPX;\n" .. ex_begin .. hfmm3d_h .. ex_end
50+
end
51+
io.writefile("c/hfmm3d_c.h", hfmm3d_h)
52+
53+
os.cp("c/lfmm3d_c.h", package:installdir("include"))
54+
os.cp("c/hfmm3d_c.h", package:installdir("include"))
55+
end)
56+
57+
on_test(function (package)
58+
assert(package:has_cfuncs("lfmm3d_s_c_p_", {includes = {"lfmm3d_c.h"}, configs = {languages = "c99"}}))
59+
assert(package:has_cfuncs("hfmm3d_s_c_p_", {includes = {"hfmm3d_c.h"}, configs = {languages = "c99"}}))
60+
end)

0 commit comments

Comments
 (0)