Skip to content

Commit 2b6b498

Browse files
committed
libqalculate: add package
1 parent 564c5f9 commit 2b6b498

File tree

9 files changed

+319
-10
lines changed

9 files changed

+319
-10
lines changed

packages/g/gmp/xmake.lua

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ package("gmp")
2727
add_deps("m4")
2828

2929
on_install("@!windows and !wasm", function (package)
30+
if is_host("windows") then
31+
io.replace("configure", "LIBTOOL='$(SHELL) $(top_builddir)/libtool'", "LIBTOOL='\"$(SHELL)\" $(top_builddir)/libtool'", {plain = true})
32+
end
3033
local configs = {}
3134
table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
3235
table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
@@ -49,5 +52,15 @@ package("gmp")
4952
end)
5053

5154
on_test(function (package)
52-
assert(package:has_cfuncs("gmp_randinit", {includes = "gmp.h"}))
55+
assert(package:check_csnippets([[
56+
void factorial(int n) {
57+
int i;
58+
mpz_t p;
59+
mpz_init_set_ui(p,1);
60+
for (i=1; i <= n ; ++i){
61+
mpz_mul_ui(p,p,i);
62+
}
63+
mpz_clear(p);
64+
}
65+
]], {includes = "gmp.h"}))
5366
end)
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
add_rules("mode.debug", "mode.release")
2+
add_requires("libcurl", "gmp", "icu4c", "mpfr", "readline", "libxml2")
3+
add_packages("libcurl", "gmp", "icu4c", "mpfr", "readline", "libxml2")
4+
add_includedirs(".", "libqalculate")
5+
set_languages("c++17") -- Use C++17 to avoid template syntax issues with nested angle brackets for Apple Clang
6+
7+
includes("@builtin/check")
8+
check_cxxincludes("HAVE_UNORDERED_MAP", "unordered_map")
9+
check_cincludes("HAVE_PTHREADS", "pthread.h")
10+
check_cincludes("HAVE_STDIO_H", "stdio.h")
11+
check_cfuncs("HAVE_PIPE2", "pipe2", {includes = {"unistd.h", "fcntl.h"}})
12+
-- External dependencies
13+
-- check_cincludes("HAVE_ICONV", "iconv.h")
14+
check_cincludes("HAVE_ICU", "unicode/ucasemap.h")
15+
check_cincludes("HAVE_LIBCURL", "curl/curl.h")
16+
check_cincludes("HAVE_LIBREADLINE", {"stdio.h", "readline/readline.h"})
17+
-- Check if 'int_n_cs_precedes' is a member of 'struct lconv'
18+
-- check_csnippets("HAVE_STRUCT_LCONV_INT_N_CS_PRECEDES", [[
19+
-- #include <locale.h>
20+
-- void* test(void) {
21+
-- return &((struct lconv *)0)->int_n_cs_precedes;
22+
-- }
23+
-- ]])
24+
-- check_csnippets("HAVE_STRUCT_LCONV_INT_P_CS_PRECEDES", [[
25+
-- #include <locale.h>
26+
-- void* test(void) {
27+
-- return &((struct lconv *)0)->int_p_cs_precedes;
28+
-- }
29+
-- ]])
30+
-- -- Define "ICONV_CONST" as "const" if the declaration of iconv() needs const.
31+
-- option("iconv_not_need_const")
32+
-- add_csnippets("iconv_const", [[
33+
-- #include <iconv.h>
34+
-- #include <string.h>
35+
36+
-- #ifndef ICONV_CONST
37+
-- # define ICONV_CONST
38+
-- #endif
39+
-- int main(int argc, char **argv) {
40+
-- int result = 0;
41+
-- /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
42+
-- returns. */
43+
-- iconv_t cd_utf8_to_88591 = iconv_open("ISO8859-1", "UTF-8");
44+
-- if (cd_utf8_to_88591 != (iconv_t)(-1)) {
45+
-- static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */
46+
-- char buf[10];
47+
-- ICONV_CONST char *inptr = input;
48+
-- size_t inbytesleft = strlen(input);
49+
-- char *outptr = buf;
50+
-- size_t outbytesleft = sizeof(buf);
51+
-- size_t res = iconv(cd_utf8_to_88591,
52+
-- &inptr, &inbytesleft,
53+
-- &outptr, &outbytesleft);
54+
-- if (res == 0)
55+
-- result |= 1;
56+
-- iconv_close(cd_utf8_to_88591);
57+
-- }
58+
-- return result;
59+
-- }
60+
-- ]])
61+
-- option_end()
62+
-- if get_config("iconv_not_need_const") then
63+
-- add_defines("ICONV_CONST=")
64+
-- else
65+
-- add_defines("ICONV_CONST=const")
66+
-- end
67+
68+
option("version", {default = "0.0.1"})
69+
local version = get_config("version")
70+
if version then
71+
add_defines("VERSION=\"" .. version .. "\"")
72+
end
73+
74+
target("libqalculate") -- Expect `libqalculate.pc` to be generated
75+
set_basename("qalculate")
76+
set_kind("$(kind)")
77+
add_headerfiles("(libqalculate/BuiltinFunctions.h)",
78+
"(libqalculate/Calculator.h)",
79+
"(libqalculate/DataSet.h)",
80+
"(libqalculate/ExpressionItem.h)",
81+
"(libqalculate/Function.h)",
82+
"(libqalculate/MathStructure.h)",
83+
"(libqalculate/Number.h)",
84+
"(libqalculate/Prefix.h)",
85+
"(libqalculate/QalculateDateTime.h)",
86+
"(libqalculate/Unit.h)",
87+
"(libqalculate/Variable.h)",
88+
"(libqalculate/includes.h)",
89+
"(libqalculate/qalculate.h)",
90+
"(libqalculate/util.h)")
91+
add_files("libqalculate/*.cc")
92+
93+
target("qalc")
94+
set_kind("binary")
95+
add_files("src/qalc.cc")
96+
add_deps("libqalculate")

packages/l/libqalculate/xmake.lua

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package("libqalculate")
2+
set_homepage("https://qalculate.github.io/")
3+
set_description("Qalculate! is a multi-purpose cross-platform desktop calculator.")
4+
set_license("GPL-2.0")
5+
6+
add_urls("https://github.com/Qalculate/libqalculate/archive/refs/tags/$(version).tar.gz",
7+
"https://github.com/Qalculate/libqalculate.git")
8+
9+
add_versions("v5.5.2", "3b8f65583779fb584a0e2fa7be95bfcc8a7e71e8e4d2ba64f00856640d32b805")
10+
11+
if is_plat("linux") then
12+
add_extsources("apt::libqalculate-dev")
13+
end
14+
15+
add_deps("libcurl", "gmp", "icu4c", "mpfr", "readline", "libxml2")
16+
17+
on_install("linux", "macosx", "mingw", function (package)
18+
io.replace("libqalculate/util.cc", "PACKAGE_DATA_DIR", '"' .. package:installdir("share") .. '"', {plain = true})
19+
io.replace("libqalculate/util.cc", "PACKAGE_LOCALE_DIR", '"' .. package:installdir("share", "locale") .. '"', {plain = true})
20+
if package:is_plat("mingw") then
21+
local src_files = {"libqalculate/MathStructure-print.cc", "libqalculate/Number.cc", "src/qalc.cc"}
22+
for _, src_file in ipairs(src_files) do
23+
io.replace(src_file, "#%s*include%s*<VersionHelpers.h>", "# include <versionhelpers.h>")
24+
end
25+
end
26+
local version = try { function() return io.readfile("configure.ac"):match("AC_INIT%(([%d%.]+)") end }
27+
version = version or (package:version() and package:version_str():gsub("^v", ""))
28+
local configs = {version = version}
29+
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
30+
import("package.tools.xmake").install(package, configs)
31+
if not package:is_cross() then
32+
package:addenv("PATH", "bin")
33+
end
34+
end)
35+
36+
on_test(function (package)
37+
assert(package:check_cxxsnippets({test = [[
38+
void test() {
39+
Calculator calc;
40+
calc.calculate("1+1");
41+
}
42+
]]}, {includes = "libqalculate/Calculator.h"}))
43+
if not package:is_cross() then
44+
os.vrunv("qalc", {"-version"})
45+
end
46+
end)

packages/m/mpfr/xmake.lua

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ package("mpfr")
1616
add_extsources("brew::mpfr")
1717
end
1818

19-
add_deps("gmp")
20-
on_install("macosx", "linux", function (package)
19+
on_load(function (package)
20+
package:add("deps", "gmp", { configs = {shared = package:config("shared")} })
21+
end)
22+
23+
on_install("@!windows and !wasm", function (package)
24+
if is_host("windows") then
25+
io.replace("configure", "LIBTOOL='$(SHELL) $(top_builddir)/libtool'", "LIBTOOL='\"$(SHELL)\" $(top_builddir)/libtool'", {plain = true})
26+
end
2127
local configs = {"--disable-dependency-tracking"}
2228
table.insert(configs, "--with-gmp=" .. package:dep("gmp"):installdir())
2329
if package:config("shared") then
@@ -30,7 +36,12 @@ package("mpfr")
3036
if package:config("pic") ~= false then
3137
table.insert(configs, "--with-pic")
3238
end
33-
import("package.tools.autoconf").install(package, configs)
39+
import("package.tools.autoconf")
40+
local envs = autoconf.buildenvs(package)
41+
if envs.ARFLAGS and envs.ARFLAGS:match("^%s*$") then
42+
envs.ARFLAGS = nil
43+
end
44+
autoconf.install(package, configs, {envs = envs})
3445
end)
3546

3647
on_test(function (package)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
diff -ruN a/c++/Makefile.in b/c++/Makefile.in
2+
--- a/c++/Makefile.in 2021-07-03 20:53:57.000000000 +0200
3+
+++ b/c++/Makefile.in 2021-11-03 10:58:04.147647447 +0100
4+
@@ -118,7 +118,7 @@
5+
-l@FORM_NAME@@USE_LIB_SUFFIX@ \
6+
-l@MENU_NAME@@USE_LIB_SUFFIX@ \
7+
-l@PANEL_NAME@@USE_LIB_SUFFIX@ \
8+
- -lncurses@USE_LIB_SUFFIX@ @SHLIB_LIST@
9+
+ -lncurses@USE_LIB_SUFFIX@
10+
11+
LIBROOT = ncurses++
12+
13+
@@ -157,8 +157,7 @@
14+
LDFLAGS_DEFAULT = $(LINK_@DFT_UPR_MODEL@) $(LDFLAGS_@DFT_UPR_MODEL@)
15+
16+
# flags for library built by this makefile
17+
-LDFLAGS = $(TEST_ARGS) @LDFLAGS@ \
18+
- @LD_MODEL@ $(TEST_LIBS) @LIBS@ $(CXXLIBS)
19+
+LDFLAGS = @LDFLAGS@ @LD_MODEL@ @LIBS@ $(CXXLIBS)
20+
21+
AUTO_SRC = \
22+
etip.h
23+
diff -ruN a/form/Makefile.in b/form/Makefile.in
24+
--- a/form/Makefile.in 2021-07-03 17:45:33.000000000 +0200
25+
+++ b/form/Makefile.in 2021-11-03 10:58:45.301114373 +0100
26+
@@ -110,7 +110,7 @@
27+
LDFLAGS = @LDFLAGS@ @LD_MODEL@ @LIBS@
28+
29+
SHLIB_DIRS = -L../lib
30+
-SHLIB_LIST = $(SHLIB_DIRS) -lncurses@USE_LIB_SUFFIX@ @SHLIB_LIST@
31+
+SHLIB_LIST = $(SHLIB_DIRS) -lncurses@USE_LIB_SUFFIX@
32+
33+
RPATH_LIST = @RPATH_LIST@
34+
RESULTING_SYMS = @RESULTING_SYMS@
35+
diff -ruN a/menu/Makefile.in b/menu/Makefile.in
36+
--- a/menu/Makefile.in 2021-07-03 17:45:33.000000000 +0200
37+
+++ b/menu/Makefile.in 2021-11-03 10:58:59.461160284 +0100
38+
@@ -110,7 +110,7 @@
39+
LDFLAGS = @LDFLAGS@ @LD_MODEL@ @LIBS@
40+
41+
SHLIB_DIRS = -L../lib
42+
-SHLIB_LIST = $(SHLIB_DIRS) -lncurses@USE_LIB_SUFFIX@ @SHLIB_LIST@
43+
+SHLIB_LIST = $(SHLIB_DIRS) -lncurses@USE_LIB_SUFFIX@
44+
45+
RPATH_LIST = @RPATH_LIST@
46+
RESULTING_SYMS = @RESULTING_SYMS@
47+
diff -ruN a/panel/Makefile.in b/panel/Makefile.in
48+
--- a/panel/Makefile.in 2021-07-03 17:45:33.000000000 +0200
49+
+++ b/panel/Makefile.in 2021-11-03 10:59:33.957938691 +0100
50+
@@ -112,7 +112,7 @@
51+
LDFLAGS = @LDFLAGS@ @LD_MODEL@ @LIBS@
52+
53+
SHLIB_DIRS = -L../lib
54+
-SHLIB_LIST = $(SHLIB_DIRS) -lncurses@USE_LIB_SUFFIX@ @SHLIB_LIST@
55+
+SHLIB_LIST = $(SHLIB_DIRS) -lncurses@USE_LIB_SUFFIX@
56+
57+
RPATH_LIST = @RPATH_LIST@
58+
RESULTING_SYMS = @RESULTING_SYMS@
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
diff -ruN a/misc/gen-pkgconfig.in b/misc/gen-pkgconfig.in
2+
--- a/misc/gen-pkgconfig.in 2021-08-07 23:36:33.000000000 +0200
3+
+++ b/misc/gen-pkgconfig.in 2021-11-03 11:12:51.127160950 +0100
4+
@@ -83,7 +83,7 @@
5+
fi
6+
7+
lib_flags=
8+
-for opt in -L$libdir @EXTRA_PKG_LDFLAGS@ @LIBS@
9+
+for opt in -L$libdir @LIBS@
10+
do
11+
case $opt in
12+
-l*) # LIBS is handled specially below
13+
diff -ruN a/misc/ncurses-config.in b/misc/ncurses-config.in
14+
--- a/misc/ncurses-config.in 2021-08-07 23:36:14.000000000 +0200
15+
+++ b/misc/ncurses-config.in 2021-11-03 11:26:12.393533954 +0100
16+
@@ -101,7 +101,7 @@
17+
# There is no portable way to find the list of standard library directories.
18+
# Require a POSIX shell anyway, to keep this simple.
19+
lib_flags=
20+
-for opt in -L$libdir @EXTRA_PKG_LDFLAGS@ $LIBS
21+
+for opt in -L$libdir $LIBS
22+
do
23+
case $opt in
24+
-specs*) # ignore linker specs-files which were used to build library

packages/n/ncurses/xmake.lua

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,19 @@ package("ncurses")
1313
add_versions("6.4", "6931283d9ac87c5073f30b6290c4c75f21632bb4fc3603ac8100812bed248159")
1414
add_versions("6.5", "136d91bc269a9a5785e5f9e980bc76ab57428f604ce3e5a5a90cebc767971cc6")
1515

16+
add_patches(">=6.3", "patches/6.3/libs.patch", "dc4261b6642058a9df1c0945e2409b24f84673ddc3a665d8a15ed3580e51ee25")
17+
add_patches(">=6.3", "patches/6.3/pkgconfig.patch", "b8544a607dfbeffaba2b087f03b57ed1fa81286afca25df65f61b04b5f3b3738")
18+
1619
add_configs("widec", {description = "Compile with wide-char/UTF-8 code.", default = true, type = "boolean"})
1720

1821
if is_plat("linux") then
1922
add_extsources("apt::libncurses-dev")
2023
end
2124

2225
on_load(function (package)
26+
if package:is_cross() then
27+
package:add("deps", "ncurses~host", {kind = "binary", private = true})
28+
end
2329
if package:config("widec") then
2430
package:add("links", "ncursesw", "formw", "panelw", "menuw")
2531
package:add("includedirs", "include/ncursesw", "include")
@@ -33,19 +39,36 @@ package("ncurses")
3339
end
3440
end)
3541

36-
on_install("linux", "macosx", "bsd", "msys", function (package)
42+
on_install("linux", "macosx", "bsd", "msys", "mingw", function (package)
3743
local configs = {
3844
"--without-manpages",
3945
"--enable-sigwinch",
4046
"--with-gpm=no",
4147
"--without-tests",
4248
"--without-ada",
4349
}
50+
if package:is_cross() then
51+
local tic = package:dep("ncurses"):installdir("bin", "tic" .. (is_host("windows") and ".exe" or ""))
52+
if os.isfile(tic) then
53+
table.insert(configs, "--with-tic-path=" .. path:unix(tic))
54+
end
55+
end
56+
local cxflags = {}
57+
if package:is_plat("msys", "mingw") then
58+
table.insert(cxflags, "-D__USE_MINGW_ACCESS")
59+
table.insert(configs, "--enable-term-driver")
60+
end
4461

4562
table.insert(configs, "--with-debug=" .. (package:is_debug() and "yes" or "no"))
4663
table.insert(configs, "--with-shared=" .. (package:config("shared") and "yes" or "no"))
4764
table.insert(configs, "--enable-widec=" .. (package:config("widec") and "yes" or "no"))
48-
import("package.tools.autoconf").install(package, configs, {arflags = {"-curvU"}})
65+
import("package.tools.autoconf").install(package, configs, {arflags = {"-curvU"}, cxflags = cxflags})
66+
if package:config("widec") then
67+
os.trycp(package:installdir("include", "ncursesw", "**"), package:installdir("include", "ncurses"))
68+
local suffix = (not package:config("shared")) and ".a"
69+
suffix = suffix or (package:is_plat("msys", "mingw") and ".dll.a" or ".so")
70+
os.trycp(path.join(package:installdir("lib"), "libncursesw" .. suffix), path.join(package:installdir("lib"), "libncurses" .. suffix))
71+
end
4972
end)
5073

5174
on_test(function (package)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
diff --git a/input.c b/input.c
2+
index 6f038d4..da4da45 100644
3+
--- a/input.c
4+
+++ b/input.c
5+
@@ -818,7 +820,7 @@ rl_getc (FILE *stream)
6+
/* We know at this point that _rl_caught_signal == 0 */
7+
8+
#if defined (__MINGW32__)
9+
- if (isatty (fd)
10+
+ if (isatty (fd))
11+
return (_getch ()); /* "There is no error return." */
12+
#endif
13+
result = 0;
14+
diff --git a/rlprivate.h b/rlprivate.h
15+
index d87d07a..cb9cf17 100644
16+
--- a/rlprivate.h
17+
+++ b/rlprivate.h
18+
@@ -303,7 +303,7 @@ extern int _rl_pushed_input_available (void);
19+
20+
extern int _rl_timeout_init (void);
21+
extern int _rl_timeout_handle_sigalrm (void);
22+
-#if defined (_POSIXSELECT_H_)
23+
+#if defined (RL_TIMEOUT_USE_SELECT)
24+
/* use as a sentinel for fd_set, struct timeval, and sigset_t definitions */
25+
extern int _rl_timeout_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *, const sigset_t *);
26+
#endif

0 commit comments

Comments
 (0)