# -*- 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
PortGroup               github 1.0
PortGroup               active_variants 1.1

github.setup            mchehab zbar 0.23.93
github.tarball_from     archive
revision                0

checksums               rmd160  2e83289a940f1192fda8c55ce244d65d754bd3ea \
                        sha256  212dfab527894b8bcbcc7cd1d43d63f5604a07473d31a5f02889e372614ebe28 \
                        size    1009320

categories              graphics
maintainers             {chello.at:knapoc @Knapoc} openmaintainer

description             ZBar is an open source software suite for reading bar codes from \
                        various sources
long_description        {*}${description}, such as video streams, image files \
                        and raw intensity sensors. It supports EAN-13/UPC-A, UPC-E, EAN-8, \
                        Code 128, Code 93, Code 39, Codabar, Interleaved 2 of 5, QR Code and SQ Code.

license                 LGPL-2.1+

depends_build-append    port:libtool \
                        port:pkgconfig \
                        port:xmlto
depends_lib-append      port:ImageMagick \
                        port:libiconv \
                        path:include/turbojpeg.h:libjpeg-turbo

use_autoreconf          yes
autoreconf.args         -fvi
configure.args          --disable-nls \
                        --disable-silent-rules \
                        --disable-video \
                        --with-imagemagick \
                        --with-jpeg \
                        --without-dbus \
                        --without-gir \
                        --without-gtk \
                        --without-java \
                        --without-python \
                        --without-qt \
                        --without-qt6 \
                        --without-x \
                        --without-xv

variant dbus description {Enable dbus support} {
    depends_lib-append      port:dbus
    configure.args-replace  --without-dbus --with-dbus
}

variant graphicsmagick description {Use GraphicsMagick instead of ImageMagick} {
    depends_lib-replace     port:ImageMagick port:GraphicsMagick
    configure.args-replace  --with-imagemagick --with-graphicsmagick
}

variant gtk3 description {Include GTK 3 Widget} {
    depends_lib-append      path:lib/pkgconfig/gtk+-3.0.pc:gtk3
    require_active_variants gtk3 x11
    configure.args-replace  --without-gtk --with-gtk=gtk3
}

variant python39 description {Include Python 3.9 binding} {
    depends_lib-append      port:python39
    configure.args-replace  --without-python --with-python
    configure.python        ${prefix}/bin/python3.9
}

variant x11 {
    depends_build-append    port:xorg-libXext
    depends_lib-append      port:xorg-libice \
                            port:xorg-libsm \
                            port:xorg-libX11 \
                            port:xorg-libXv
    configure.args-replace  --without-x --with-x \
                            --without-xv --with-xv
}

# perl bindings come in the perl subdir of the main tarball
foreach ver [list 28 30 32 34] {
    subport p5.${ver}-barcode-zbar {
        depends_lib-append  port:zbar \
                            port:perl5.${ver}
        use_autoreconf      no
        configure.perl      ${prefix}/bin/perl5.${ver}
        worksrcdir          ${distname}/perl
        configure.cmd       ${configure.perl} Makefile.PL

        # Perl module ports shouldn't create 'perllocal.pod' file,
        # which can conflict with other ports
        # see: https://trac.macports.org/ticket/26325#comment:3
        post-destroot {
            delete [glob ${destroot}${prefix}/lib/perl5/*/*/perllocal.pod]
        }
    }
}
