defpkgbuild(elfutils, #:pkgname, "elfutils", #:pkgver, "0.191", #:pkgrel, 1, #:pkgdesc, "ELF and DWARF libraries and utilities", #:arch, [#:x86-64, #:aarch64], #:url, "https://sourceware.org/elfutils/", #:license, "GPL-3.0-or-later AND (GPL-2.0-or-later OR LGPL-3.0-or-later)", #:depends, ["libelf=0.191-2", "gcc-libs", "musl", "musl-fts", "musl-obstack", "zlib", "xz", "zstd", "bzip2"], #:makedepends, ["gcc", "argp-standalone", "bsd-compat-headers", "linux-headers", "musl-legacy-error"], #:provides, ["libdw=0.191", "libasm=0.191"], #:source, ["https://sourceware.org/elfutils/ftp/0.191/elfutils-0.191.tar.bz2", "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/elfutils/fix-aarch64_fregs.patch", "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/elfutils/fix-uninitialized.patch", "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/elfutils/musl-macros.patch", "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/elfutils/musl-asm-ptrace-h.patch"], #:sha256sums, ["df76db71366d1d708365fc7a6c60ca48398f14367eb2b8954efc8897147ad871", "a5b131c65927da751aae47a476f26e59ce53300777d54aef6c65c1eceef1a12d", "ee94f9ab26049f8100db1b6bfc760454f5a220190a5eb907faee65129ec9e962", "8e3924f08d4af34a45d0059224ea42b7afdc43837d053243e855cdaf295dde67", "f03d703dc76002413f4cd04e82c1da79365885df65fbd4eb660f1de42ee41ba9"], #:prepare, fn() { for-each(fn(file) { run("patch", "--batch", "-d", "elfutils-0.191", "-p1", "-i", string-append("../", file)) }, list("fix-aarch64_fregs.patch", "fix-uninitialized.patch", "musl-macros.patch", "musl-asm-ptrace-h.patch")) }, #:build, fn() { root := get-environment-variable("VPAC_MAKEPKG_ROOT") selected := get-environment-variable("VPAC_TARGET_ARCH") arch := if string?(selected) { selected } else if memq(string->symbol("aarch64"), features()) { "aarch64" } else { "x86_64" } headers := string-append(root, "/usr/include/c++/14.2.0") arch-headers := string-append(headers, "/", arch, "-linux-musl") compiler-support := string-append(root, "/usr/lib/gcc/", arch, "-linux-musl/14.2.0/") run("test", "-f", string-append(arch-headers, "/bits/c++config.h")) run("test", "-f", string-append(compiler-support, "libgcc_eh.a")) ; The musl compatibility headers deliberately warn when used. ; Use the SDK's C++ runtime and unwind tables with the bootstrap driver. run("env", "CFLAGS=-O2 -D_GNU_SOURCE -Wno-error -Wno-null-dereference", string-append("CXXFLAGS=-O2 -D_GNU_SOURCE -Wno-error -B", compiler-support, " -nostdinc++ -isystem ", headers, " -isystem ", arch-headers), string-append("LDFLAGS=-L", root, "/usr/lib -Wl,--eh-frame-hdr,--no-as-needed,", root, "/usr/lib/libgcc_s.so.1,--as-needed"), "vinix-configure", "elfutils-0.191/configure", "--program-prefix=eu-", "--enable-deterministic-archives", "--disable-nls", "--disable-libdebuginfod", "--disable-debuginfod", "--with-zstd") run("make") }, #:check, fn() { run("vinix-run", "--library-path", "libelf:libdw:libasm", "src/readelf", "-h", "src/readelf") run("vinix-run", "--library-path", "libelf:libdw:libasm", "src/readelf", "-V", "libelf/libelf.so") }, #:package, fn() { run("make", "install", string-append("DESTDIR=", pkgdir())) run("make", "-C", "libelf", "uninstall", string-append("DESTDIR=", pkgdir())) run("rm", "-f", string-append(pkgdir(), "/usr/lib/pkgconfig/libelf.pc")) for-each(fn(file) { run("install", "-Dm644", string-append("elfutils-0.191/", file), string-append(pkgdir(), "/usr/share/licenses/elfutils/", file)) }, list("COPYING", "COPYING-GPLV2", "COPYING-LGPLV3")) })