Browse Source

intelrdfpmathlib: add package

star9029 1 year ago
parent
commit
5051f4d597
2 changed files with 143 additions and 0 deletions
  1. 108 0
      packages/i/intelrdfpmathlib/port/xmake.lua
  2. 35 0
      packages/i/intelrdfpmathlib/xmake.lua

+ 108 - 0
packages/i/intelrdfpmathlib/port/xmake.lua

@@ -0,0 +1,108 @@
+add_rules("mode.debug", "mode.release")
+
+target("bid")
+    set_kind("$(kind)")
+    add_headerfiles("LIBRARY/src/*.h", {prefixdir = "intelrdfpmathlib"})
+
+    add_defines(
+        "BID_BIG_ENDIAN=1",
+        "DECIMAL_CALL_BY_REFERENCE=0",
+        "DECIMAL_GLOBAL_ROUNDING=0",
+        "DECIMAL_GLOBAL_EXCEPTION_FLAGS=0"
+    )
+
+    if is_plat("windows", "mingw", "msys") then
+        add_defines("WINDOWS")
+    elseif is_plat("macosx") then
+        add_defines("LINUX=1", "mach=1")
+    elseif is_plat("bsd") then
+        add_defines("LINUX=1", "freebsd=1")
+    else
+        add_defines("LINUX=1", "linux=1")
+    end
+
+    if is_plat("windows") and is_kind("shared") then
+        add_rules("utils.symbols.export_all")
+    end
+
+    on_config(function (target)
+        local native_128 = target:has_tool("cc", "icl")
+        if native_128 then
+            target:add("files", "LIBRARY/src/*.c", {
+                defines = {"USE_COMPILER_F128_TYPE=1", "USE_COMPILER_F80_TYPE=1"},
+                cflags = {"/Qlong-double", "/Qpc80", "/Qstd=c99", "-Qoption,cpp,--extended_float_types"},
+            })
+        else
+            target:add("files", "LIBRARY/src/*.c", {
+                defines = {"USE_COMPILER_F128_TYPE=0", "USE_COMPILER_F80_TYPE=0"},
+            })
+        end
+
+        if native_128 then
+            return
+        end
+
+        -- local defines = {}
+        -- local is_64 = (target:check_sizeof("void*") == 8)
+        -- if target:is_plat("windows", "mingw", "msys") then
+        --     table.insert(defines, (is_64 and "win64" or "winnt"))
+        -- end
+
+        -- local float128 = {
+        --     "dpml_ux_bid.c",
+        --     "dpml_ux_bessel.c",
+        --     "dpml_ux_cbrt.c",
+        --     "dpml_ux_erf.c",
+        --     "dpml_ux_exp.c",
+        --     "dpml_ux_int.c",
+        --     "dpml_ux_inv_hyper.c",
+        --     "dpml_ux_inv_trig.c",
+        --     "dpml_ux_lgamma.c",
+        --     "dpml_ux_log.c",
+        --     "dpml_ux_mod.c",
+        --     "dpml_ux_powi.c",
+        --     "dpml_ux_pow.c",
+        --     "dpml_ux_sqrt.c",
+        --     "dpml_ux_trig.c",
+        --     "dpml_ux_ops.c",
+        --     "dpml_ux_ops_64.c",
+        --     "dpml_four_over_pi.c",
+        --     "dpml_exception.c",
+        --     "sqrt_tab_t.c",
+        -- }
+        -- for _, file in ipairs(float128) do
+        --     target:add("files", path.join("LIBRARY/float128", file), {
+        --         defines = table.join({"USE_NATIVE_QUAD_TYPE=0"}, defines)
+        --     })
+        -- end
+
+        -- if target:has_tool("cc", "cl") then
+        --     local float53 = {
+        --         "dpml_asinh_t.c", {defines = "ASINH"}
+        --         "dpml_acosh_t.c",
+        --         "dpml_cbrt_t.c",
+        --         "dpml_erf_t.c",
+        --         "dpml_erfc_t.c",
+        --         "dpml_expm1_t.c",
+        --         "dpml_exp10_t.c",
+        --         "dpml_exp2_t.c",
+        --         "dpml_lgamma_t.c",
+        --         "dpml_log1p_t.c",
+        --         -- "dpml_log2_t.c",
+        --         "dpml_tgamma_t.c",
+        --         "dpml_rt_lgamma_t.c", {defines = "T_FLOAT"}
+        --         "dpml_pow_t_table.c",
+        --         "dpml_cbrt_t_table.c", {defines = {"BUILD_FILE_NAME=dpml_cbrt_t_table.c", "CBRT"}}
+        --         "dpml_special_exp_t.c",
+        --     }
+        --     if target:check_sizeof("void*") == 4 then
+        --         table.insert(float53, "dpml_log2_t.c")
+        --     end
+
+        --     table.join2(defines, "T_FLOAT")
+        --     for file, flags file in pairs(float53) do
+        --         table.join2(flags.defines, defines)
+        --         target:add("files", path.join("LIBRARY/float128", file), flags)
+        --     end
+        -- end
+    end)

+ 35 - 0
packages/i/intelrdfpmathlib/xmake.lua

@@ -0,0 +1,35 @@
+package("intelrdfpmathlib")
+    set_homepage("https://www.intel.com/content/www/us/en/developer/articles/tool/intel-decimal-floating-point-math-library.html")
+    set_description("Intel(R) Decimal Floating-Point Math Library")
+
+    add_urls("https://github.com/xmake-mirror/IntelRDFPMathLib.git")
+    add_urls("http://www.netlib.org/misc/intel/IntelRDFPMathLib$(version).tar.gz", {
+        alias = "intel",
+        version = function (version)
+            return format("%d0U%d", version:major(), version:minor())
+        end
+    })
+
+    add_versions("intel:v2.3", "13f6924b2ed71df9b137a7df98706a0dcc3b43c283a0e32f8b6eadca4305136a")
+
+    add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
+
+    if on_check then
+        on_check(function (package)
+            if package:is_arch("arm.*") then
+                raise("package(intelrdfpmathlib) unsupported arm")
+            end
+        end)
+    end
+
+    on_install(function (package)
+        os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
+        import("package.tools.xmake").install(package)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("bid_to_dpd32", {includes = {
+            "intelrdfpmathlib/bid_conf.h",
+            "intelrdfpmathlib/bid_functions.h"
+        }}))
+    end)