mpfr and mpc: build and exercise the GNU arithmetic libraries
@@ -0,0 +1,23 @@
1+defpkgbuild(mpc,
2+ #:pkgname, "mpc",
3+ #:pkgver, "1.3.1",
4+ #:pkgrel, 1,
5+ #:pkgdesc, "Multiple precision complex arithmetic",
6+ #:arch, [#:x86-64],
7+ #:url, "https://www.multiprecision.org/mpc/",
8+ #:license, "LGPL-3.0-or-later",
9+ #:depends, ["musl", "gmp", "mpfr"],
10+ #:source, ["https://distfiles.alpinelinux.org/distfiles/v3.21/mpc-1.3.1.tar.gz"],
11+ #:sha256sums, ["ab642492f5cf882b74aa0cb730cd410a81edcdbec895183ce930e706c1c759b8"],
12+ #:build, fn() {
13+ run("env", "CC=vinix-cc", "CFLAGS=-O2 -std=gnu17", "CC_FOR_BUILD=gcc", "mpc-1.3.1/configure", "--prefix=/usr",
14+ "--build=x86_64-pc-linux-gnu", "--host=x86_64-linux-musl", "--enable-shared", "--enable-static")
15+ run("make")
16+ },
17+ #:package, fn() {
18+ run("make", string-append("DESTDIR=", pkgdir()), "install")
19+ run("rm", "-f", string-append(pkgdir(), "/usr/share/info/dir"))
20+ run("test", "-f", string-append(pkgdir(), "/usr/lib/libmpc.so"))
21+ run("rm", string-append(pkgdir(), "/usr/lib/libmpc.la"))
22+ run("install", "-Dm644", "mpc-1.3.1/COPYING.LESSER", string-append(pkgdir(), "/usr/share/licenses/mpc/COPYING"))
23+ })
@@ -0,0 +1,23 @@
1+defpkgbuild(mpfr,
2+ #:pkgname, "mpfr",
3+ #:pkgver, "4.2.1",
4+ #:pkgrel, 1,
5+ #:pkgdesc, "Multiple precision floating-point arithmetic with correct rounding",
6+ #:arch, [#:x86-64],
7+ #:url, "https://www.mpfr.org/",
8+ #:license, "LGPL-3.0-or-later",
9+ #:depends, ["musl", "gmp"],
10+ #:source, ["https://distfiles.alpinelinux.org/distfiles/v3.21/mpfr-4.2.1.tar.xz"],
11+ #:sha256sums, ["277807353a6726978996945af13e52829e3abd7a9a5b7fb2793894e18f1fcbb2"],
12+ #:build, fn() {
13+ run("env", "CC=vinix-cc", "CFLAGS=-O2 -std=gnu17", "CC_FOR_BUILD=gcc", "mpfr-4.2.1/configure", "--prefix=/usr",
14+ "--build=x86_64-pc-linux-gnu", "--host=x86_64-linux-musl", "--enable-shared", "--enable-static")
15+ run("make")
16+ },
17+ #:package, fn() {
18+ run("make", string-append("DESTDIR=", pkgdir()), "install")
19+ run("rm", "-f", string-append(pkgdir(), "/usr/share/info/dir"))
20+ run("test", "-f", string-append(pkgdir(), "/usr/lib/libmpfr.so"))
21+ run("rm", string-append(pkgdir(), "/usr/lib/libmpfr.la"))
22+ run("install", "-Dm644", "mpfr-4.2.1/COPYING.LESSER", string-append(pkgdir(), "/usr/share/licenses/mpfr/COPYING"))
23+ })
@@ -0,0 +1,26 @@
1+#include <gmp.h>
2+#include <mpfr.h>
3+#include <mpc.h>
4+#include <stdio.h>
5+
6+int main(void)
7+{
8+ mpz_t integer;
9+ mpfr_t real;
10+ mpc_t number;
11+ mpz_init_set_ui(integer, 27);
12+ mpz_mul_ui(integer, integer, 11);
13+ mpfr_init2(real, 128);
14+ mpfr_set_z(real, integer, MPFR_RNDN);
15+ mpc_init2(number, 128);
16+ mpc_set_fr(number, real, MPC_RNDNN);
17+ mpc_sqr(number, number, MPC_RNDNN);
18+ int ok = mpfr_cmp_ui(mpc_realref(number), 88209) == 0
19+ && mpfr_zero_p(mpc_imagref(number));
20+ mpc_clear(number);
21+ mpfr_clear(real);
22+ mpz_clear(integer);
23+ if (ok)
24+ puts("Vinix C, GMP, MPFR and MPC passed");
25+ return ok ? 0 : 1;
26+}