pkgname =  "jemalloc" # git repo
pkgver  = "5.3.0" 
source  = f"https://github.com/jemalloc/jemalloc.git"
builddir = f"/tmp/fempkgbuild/{pkgname}"
source_type = "git"
fembuilddir = builddir
outputdir = "/home/gabry/lfs-repo/binpkg"
manifestdir = "/home/gabry/lfs-repo/manifests"
destdir = f"{fembuilddir}/DESTDIR"

deps = ["git"] # well i mean

build = [

    # 64-bit build
    f"cd {builddir} && ./autogen.sh && ./configure --prefix=/usr",
    f"cd {builddir} && make -j$(nproc)",
    f"cd {builddir} && make DESTDIR={destdir} install",

    f"install -v -d -m755 {destdir}/usr/share/licenses/{pkgname}/",
    f"install -v -m644 {builddir}/COPYING {destdir}/usr/share/licenses/{pkgname}/LICENSE",

    # Make tarball + manifests
    f"mkdir -p {outputdir} && cd {destdir} && tar --transform 's|^\\.||' -I zstd -cf {outputdir}/{pkgname}-{pkgver}.tar.zst .",
    f"mkdir -p {manifestdir} && tar -tf {outputdir}/{pkgname}-{pkgver}.tar.zst | grep -v '/$' > {manifestdir}/{pkgname}.txt",

# Cleanup
    f"rm -rf {builddir}"
]
