vinix-ports / ports / elfutils / PKGBUILD.vile
58 lines · 58 sloc · 3.89 KB
Raw
1defpkgbuild(elfutils,
2 #:pkgname, "elfutils",
3 #:pkgver, "0.191",
4 #:pkgrel, 1,
5 #:pkgdesc, "ELF and DWARF libraries and utilities",
6 #:arch, [#:x86-64, #:aarch64],
7 #:url, "https://sourceware.org/elfutils/",
8 #:license, "GPL-3.0-or-later AND (GPL-2.0-or-later OR LGPL-3.0-or-later)",
9 #:depends, ["libelf=0.191-2", "gcc-libs", "musl", "musl-fts", "musl-obstack", "zlib", "xz", "zstd", "bzip2"],
10 #:makedepends, ["gcc", "argp-standalone", "bsd-compat-headers", "linux-headers", "musl-legacy-error"],
11 #:provides, ["libdw=0.191", "libasm=0.191"],
12 #:source, ["https://sourceware.org/elfutils/ftp/0.191/elfutils-0.191.tar.bz2",
13 "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/elfutils/fix-aarch64_fregs.patch",
14 "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/elfutils/fix-uninitialized.patch",
15 "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/elfutils/musl-macros.patch",
16 "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/elfutils/musl-asm-ptrace-h.patch"],
17 #:sha256sums, ["df76db71366d1d708365fc7a6c60ca48398f14367eb2b8954efc8897147ad871",
18 "a5b131c65927da751aae47a476f26e59ce53300777d54aef6c65c1eceef1a12d",
19 "ee94f9ab26049f8100db1b6bfc760454f5a220190a5eb907faee65129ec9e962",
20 "8e3924f08d4af34a45d0059224ea42b7afdc43837d053243e855cdaf295dde67",
21 "f03d703dc76002413f4cd04e82c1da79365885df65fbd4eb660f1de42ee41ba9"],
22 #:prepare, fn() {
23 for-each(fn(file) {
24 run("patch", "--batch", "-d", "elfutils-0.191", "-p1", "-i", string-append("../", file))
25 }, list("fix-aarch64_fregs.patch", "fix-uninitialized.patch", "musl-macros.patch", "musl-asm-ptrace-h.patch"))
26 },
27 #:build, fn() {
28 root := get-environment-variable("VPAC_MAKEPKG_ROOT")
29 selected := get-environment-variable("VPAC_TARGET_ARCH")
30 arch := if string?(selected) { selected } else if memq(string->symbol("aarch64"), features()) { "aarch64" } else { "x86_64" }
31 headers := string-append(root, "/usr/include/c++/14.2.0")
32 arch-headers := string-append(headers, "/", arch, "-linux-musl")
33 compiler-support := string-append(root, "/usr/lib/gcc/", arch, "-linux-musl/14.2.0/")
34 run("test", "-f", string-append(arch-headers, "/bits/c++config.h"))
35 run("test", "-f", string-append(compiler-support, "libgcc_eh.a"))
36 ; The musl compatibility headers deliberately warn when used.
37 ; Use the SDK's C++ runtime and unwind tables with the bootstrap driver.
38 run("env", "CFLAGS=-O2 -D_GNU_SOURCE -Wno-error -Wno-null-dereference",
39 string-append("CXXFLAGS=-O2 -D_GNU_SOURCE -Wno-error -B", compiler-support,
40 " -nostdinc++ -isystem ", headers, " -isystem ", arch-headers),
41 string-append("LDFLAGS=-L", root, "/usr/lib -Wl,--eh-frame-hdr,--no-as-needed,",
42 root, "/usr/lib/libgcc_s.so.1,--as-needed"), "vinix-configure", "elfutils-0.191/configure",
43 "--program-prefix=eu-", "--enable-deterministic-archives",
44 "--disable-nls", "--disable-libdebuginfod", "--disable-debuginfod", "--with-zstd")
45 run("make")
46 },
47 #:check, fn() {
48 run("vinix-run", "--library-path", "libelf:libdw:libasm", "src/readelf", "-h", "src/readelf")
49 run("vinix-run", "--library-path", "libelf:libdw:libasm", "src/readelf", "-V", "libelf/libelf.so")
50 },
51 #:package, fn() {
52 run("make", "install", string-append("DESTDIR=", pkgdir()))
53 run("make", "-C", "libelf", "uninstall", string-append("DESTDIR=", pkgdir()))
54 run("rm", "-f", string-append(pkgdir(), "/usr/lib/pkgconfig/libelf.pc"))
55 for-each(fn(file) {
56 run("install", "-Dm644", string-append("elfutils-0.191/", file), string-append(pkgdir(), "/usr/share/licenses/elfutils/", file))
57 }, list("COPYING", "COPYING-GPLV2", "COPYING-LGPLV3"))
58 })
59