| 1 | cross := get-environment-variable("CROSS_COMPILE") |
| 2 | prefix := if string?(cross) { cross } else { "" } |
| 3 | |
| 4 | defpkgbuild(zstd, |
| 5 | #:pkgname, "zstd", |
| 6 | #:pkgver, "1.6.0", |
| 7 | #:pkgrel, 2, |
| 8 | #:pkgdesc, "Zstandard compression library and development headers", |
| 9 | #:arch, [#:x86-64, #:aarch64], |
| 10 | #:license, "BSD-3-Clause OR GPL-2.0-only", |
| 11 | #:url, "https://facebook.github.io/zstd/", |
| 12 | #:depends, ["musl"], |
| 13 | #:source, ["zstd-1.6.0.tar.gz::https://github.com/facebook/zstd/archive/refs/tags/v1.6.0.tar.gz"], |
| 14 | #:sha256sums, ["289bb207935e5b4f241239f9832e665fa6b9636c3f87f479e125371e13842b8e"], |
| 15 | #:build, fn() { |
| 16 | run("make", "-C", "zstd-1.6.0/lib", "CC=vinix-cc", string-append("AR=", prefix, "ar"), string-append("RANLIB=", prefix, "ranlib"), "libzstd-release") |
| 17 | }, |
| 18 | #:check, fn() { |
| 19 | for-each(fn(program) { |
| 20 | run("vinix-cc", "-Izstd-1.6.0/lib", string-append("zstd-1.6.0/examples/", program, ".c"), |
| 21 | "-Lzstd-1.6.0/lib", "-lzstd", "-o", program) |
| 22 | }, list("simple_compression", "simple_decompression")) |
| 23 | run("cp", "zstd-1.6.0/README.md", "sample") |
| 24 | run("vinix-run", "--library-path", "zstd-1.6.0/lib", "./simple_compression", "sample") |
| 25 | run("vinix-run", "--library-path", "zstd-1.6.0/lib", "./simple_decompression", "sample.zst") |
| 26 | run("zstd", "--quiet", "--decompress", "sample.zst", "-o", "decoded") |
| 27 | run("cmp", "sample", "decoded") |
| 28 | }, |
| 29 | #:package, fn() { |
| 30 | run("make", "-C", "zstd-1.6.0/lib", "CC=vinix-cc", string-append("AR=", prefix, "ar"), string-append("RANLIB=", prefix, "ranlib"), "PREFIX=/usr", string-append("DESTDIR=", pkgdir()), |
| 31 | "install-shared", "install-includes", "install-pc") |
| 32 | for-each(fn(name) { |
| 33 | run("install", "-Dm644", string-append("zstd-1.6.0/", name), string-append(pkgdir(), "/usr/share/licenses/zstd/", name)) |
| 34 | }, list("LICENSE", "COPYING")) |
| 35 | }) |
| 36 | |