# -*- 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

name                libcaca
categories          graphics
license             WTFPL-2 LGPL-2+
maintainers         nomaintainer
description         Colour AsCii Art library
long_description    \
    The libcaca library is a graphics library that outputs text \
    instead of pixels, so that it can work on older video cards \
    or text terminals. It is not unlike the famous AAlib library.

# common directory for storing downloaded tarballs
dist_subdir         libcaca

if {${name} eq ${subport}} {

    github.setup    cacalabs libcaca 0.99.beta20 v
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    checksums       rmd160  f1221e7364baf700e7839a6f18d33266b79b1473 \
                    sha256  0241d42af3c46949768b956f2e96e8fe2fbc73c66fde3b0280cf1ab70da9e2c3 \
                    size    729687
    revision        1

    long_description ${long_description} ${subport} \
provides the release version.
    conflicts       libcaca-devel

}

subport libcaca-devel {

    github.setup    cacalabs libcaca f42aa68fc798db63b7b2a789ae8cf5b90b57b752
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball
    version         20211207
    checksums       rmd160  6b0ecedd167041fd656c7f99a5fb1c62691249a4 \
                    sha256  e135874d7d8c9b73ec739c70f56c1d8d2e162fbfafb9a5ed333b76f25357813a \
                    size    729740
    revision        0

    conflicts       libcaca
    long_description ${long_description} ${subport} \
provides the libcaca GIT master branch and is typically updated monthly.

    github.livecheck.branch main

}

homepage            http://caca.zoy.org/wiki/libcaca

depends_build       port:pkgconfig
depends_lib         port:ncurses port:zlib

# temporary patch to fix use of implcitily declared function
patchfiles-append   patch-libcaca-common-image.diff

platform darwin 8 {
    # https://trac.macports.org/ticket/63758
    patchfiles-append patch-libcaca-tiger.diff
}

use_autoconf         yes
# these dependencies are removed by use_autoconf, so add them after
depends_build-append port:libtool port:autoconf port:automake
autoconf.cmd         ./bootstrap

# require C++11 for CppUnit API
compiler.cxx_standard   2011
configure.cxxflags-append -std=gnu++11

configure.args      \
    --disable-kernel \
    --disable-slang \
    --disable-win32 \
    --disable-conio \
    --disable-cocoa \
    --disable-network \
    --disable-vga \
    --disable-csharp \
    --disable-java \
    --disable-cxx \
    --disable-python \
    --disable-ruby \
    --disable-debug \
    --disable-profiling \
    --disable-plugins \
    --disable-doc \
    --disable-cppunit \
    --disable-zzuf

configure.args-append \
    --mandir=${prefix}/share/man \
    --enable-ncurses

# Disable silent rules
build.args-append   V=1

variant x11 {
    depends_lib-append \
        port:imlib2 \
        port:freeglut \
        port:libGLU \
        port:ftgl \
        port:mesa \
        port:xorg-libX11
}

if {[variant_isset x11]} {
    configure.args-append \
        --enable-x11 --enable-gl \
        --x-includes=${prefix}/include \
        --x-libraries=${prefix}/lib
} else {
    configure.args-append \
        --disable-x11 \
        --disable-gl \
        --disable-imlib2
}

test.run            yes
test.target         check