# -*- 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                    convertlit
version                 1.8
revision                3
checksums               rmd160  6104a7d951ed60ea73705e401be8b55633ea2d47 \
                        sha256  d70a85f5b945104340d56f48ec17bcf544e3bb3c35b1b3d58d230be699e557ba \
                        size    135120

set my_version          [strsed ${version} {g/\.//}]
categories              textproc
platforms               darwin
maintainers             {ryandesign @ryandesign} openmaintainer
license                 GPL-2

description             converts Microsoft Reader eBooks into open format

long_description        Convert LIT (clit) converts eBooks in Microsoft \
                        Reader format into open format for use with software \
                        or devices which are not directly compatible with \
                        Microsoft's Reader.

homepage                http://www.convertlit.com/
master_sites            ${homepage}
distname                ${name}${my_version}src
use_zip                 yes

depends_lib             port:libtommath

extract.mkdir           yes
post-extract {
    move ${worksrcpath}/clit${my_version} ${worksrcpath}/clit
    copy ${filespath}/Makefile ${worksrcpath}
    
    # DOS to UNIX line endings so we can patch
    reinplace -W ${worksrcpath} "s|\r||g" \
                        clit/Makefile \
                        clit/drm5.c \
                        clit/explode.c \
                        clit/manifest.c \
                        lib/Makefile \
                        lib/newlzx/lzx.h \
                        lib/newlzx/lzxglue.c
}

patchfiles              patch-clit-Makefile.diff \
                        implicit.patch \
                        patch-lib-Makefile.diff

use_configure           no

configure.cppflags-append -I${prefix}/include/libtommath

variant universal {}

build.args              CC="${configure.cc} [get_canonical_archflags]" \
                        CPPFLAGS="${configure.cppflags}" \
                        LDFLAGS="${configure.ldflags}"

destroot {
    xinstall ${worksrcpath}/clit/clit ${destroot}${prefix}/bin
    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 0644 ${worksrcpath}/README ${destroot}${prefix}/share/doc/${name}
}

livecheck.type          regex
livecheck.url           ${homepage}download.php
livecheck.regex         {([0-9.]+) source}
