# -*- 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            colorer
version         take5.be5
revision        2
license         MPL-1.1 GPL-2 LGPL-2.1
categories      textproc devel
platforms       darwin
maintainers     ryandesign openmaintainer
description     A library that provides source text syntax highlighting services

long_description \
    Colorer take5 is a syntax highlighting and text parsing library, that \
    provides services of text parsing in host editor systems in real-time and \
    transforming results into colored text. Result information allows to \
    search and build outlined lists of functions, structures, and to search \
    and indent programming language constructions (brackets, paired tags).

homepage        http://colorer.sourceforge.net/
master_sites    sourceforge:project/colorer/Library%20sources/Colorer-${version}
distname        Colorer-${version}
use_zip         yes

checksums       md5     075ede3afc260766fe13c71850a5e6c0 \
                sha1    53cd454779621c09954ce70b6d06a4e1903ed6af \
                rmd160  87c9ad2b99343c19e74211e658eb73ebcf0bcea9

post-extract {
    copy \
        ${worksrcpath}/src/libcolorer/linux/Makefile.in \
        ${worksrcpath}
}

variant universal {}

patchfiles      patch-Makefile.in.diff \
                patch-src-colorer-makefile.gcc.diff \
                patch-src-libcolorer-makefile.gcc.diff \
                patch-src-shared-common-Logging.cpp.diff

post-patch {
    # error: cast from 'int*' to 'int' loses precision
    reinplace s/int(/bool(/ ${worksrcpath}/src/shared/unicode/BitArray.cpp

    # Do not force installation as root
    reinplace {s/-g 0 -o 0//} ${worksrcpath}/Makefile.in
}

configure.cmd   sh src/libcolorer/linux/configure
configure.args  --srcdir=.

set extra_cflags "[get_canonical_archflags cc]"
if {[string match *clang* ${configure.compiler}]} {
    append extra_cflags " -Wno-error=address-of-temporary"
}

build.target colorer
# Yes, this build system uses "CPP" for the C compiler and "LINK" for the C++ compiler.
build.args          ARCHFLAGS="[get_canonical_archflags]" \
                    CPP=${configure.cc} \
                    CPPFLAGS_CUSTOM="${extra_cflags}" \
                    FLAGS= \
                    LIBINC="[regsub {^lib} ${configure.cxx_stdlib} {-l}]" \
                    LINK=${configure.cxx} \
                    prefix=${prefix}
use_parallel_build yes

destroot.destdir    prefix=${destroot}${prefix}
destroot.args       -B

livecheck.type  regex
livecheck.url   ${homepage}whatsnew/history.html
livecheck.regex {<h2>([^,]*), Latest}
