# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem                  1.0

name                        e2fsprogs
version                     1.47.1
checksums                   rmd160  90b52eb760e460c1d58d2db2b699025832107499 \
                            sha256  9afcd201f39429d2db2492aeb13dba5e75d6cc50682b732dca35643bd5f092e3 \
                            size    9952468

categories                  sysutils
maintainers                 {ryandesign @ryandesign} openmaintainer
license                     GPL-2 LGPL-2+ MIT BSD

description                 Utilities for use with the ext2, ext3 and ext4 \
                            filesystems

long_description            Utilities to create, check and manipulate extended 2, \
                            3 and 4 filesystem (ext2, ext3, ext4) which are \
                            commonly used on Linux.

homepage                    https://e2fsprogs.sourceforge.net
master_sites                sourceforge:project/e2fsprogs/e2fsprogs/v${version}

depends_build               port:gettext \
                            path:bin/pkg-config:pkgconfig

depends_lib                 port:gettext-runtime

patchfiles-append           patch-lib__Makefile.darwin-lib.diff

configure.args-append       --enable-bsd-shlibs \
                            --disable-fuse2fs

configure.checks.implicit_function_declaration.whitelist-append strchr

# Enable verbose build messages
build.args-append           V=1

if {${subport} eq ${name}} {
    revision                    0

    universal_variant           no

    configure.args-append       --disable-libuuid \
                                --disable-uuidd

    depends_lib-append          port:ossp-uuid \
                                port:libarchive \
                                port:libcomerr \
                                port:libmagic

    patchfiles-append           patch-Makefile.in-remove-included-libcomerr.diff \
                                patch_xlocale_h.diff

    pre-build {
        ln -fs ${prefix}/bin/compile_et ${worksrcpath}/lib/et/compile_et
        ln -fs ${prefix}/lib/libcom_err.dylib ${worksrcpath}/lib/libcom_err.dylib
    }

    destroot.target-append      install-libs

    livecheck.type              regex
    livecheck.regex             ${name}-(\[0-9.\]+)\\.tar
} else {
    livecheck.type              none
}

subport libcomerr {
    revision                    0

    description                 common error description library
    long_description            \
        libcomerr is an attempt to present a common error-handling mechanism to \
        manipulate the most common form of error code in a fashion that does \
        not have the problems identified with mechanisms commonly in use.
    license                     MIT BSD

    # Don't look for libmagic. It's not used by this subport.
    configure.args-append       ac_cv_lib_magic_magic_file=no

    # If we don't force this version of awk, we'd have to add a dependency on
    # gawk.
    configure.env-append        AWK=/usr/bin/awk

    build.args-append           -C lib/et
    destroot.args-append        -C lib/et
    post-destroot {
        ln -fs {*}[glob -tails -directory ${destroot}${prefix}/lib libcom_err.*.dylib] ${destroot}${prefix}/lib/libcom_err.dylib
    }
}

platform darwin {
    patchfiles-append           dlopen-darwin.patch
    post-patch {
        reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/lib/support/plausible.c
    }
}
