# -*- 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
# $Id: Portfile 73041 2010-11-01 23:34:21Z ryandesign@macports.org $

PortSystem              1.0

name                    convertlit
version                 1.8
set my_version          [strsed ${version} {g/\.//}]
categories              textproc
platforms               darwin
maintainers             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

checksums               sha1    0fa9aead468bd8640c49374d46d78d2a3e79489f \
                        rmd160  6104a7d951ed60ea73705e401be8b55633ea2d47

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 "s|\r||g" ${worksrcpath}/clit/Makefile \
                        ${worksrcpath}/lib/Makefile
}

patchfiles              patch-clit-Makefile.diff \
                        patch-clit-hexdump.c.diff \
                        patch-lib-Makefile.diff

use_configure           no

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

variant universal {}
if {[variant_isset universal]} {
    set archflags ${configure.universal_cflags}
} else {
    set archflags ${configure.cc_archflags}
}

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

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

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