# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0
PortGroup           legacysupport 1.1
PortGroup           qt4 1.0

github.setup        geometer FBReader 0.99.5
revision            0
categories          office net
maintainers         nomaintainer
description         Light-weight e-book reader
long_description    ${description}

checksums           rmd160  95df8bfd78236911063268290b66b82e97dd0179 \
                    sha256  5e4fe6cd18d2fe3f8ea36084da5f15c961479e6e639fdeeff8db293e02471e3f \
                    size    25500250
github.tarball_from archive

depends_lib-append  port:bzip2 \
                    port:expat \
                    port:fribidi \
                    port:libiconv \
                    port:libunibreak \
                    port:libzip \
                    port:sqlite3 \
                    port:zlib

depends_run-append  port:curl

# Sort out the build:
patchfiles-append   fix-build.patch

# https://github.com/geometer/FBReader/pull/311
patchfiles-append   curl.patch

platform darwin {
    patchfiles-append \
                    zlshared-mac.patch

    if {${os.major} < 9} {
        depends_build-append \
                    port:gmake
        build.cmd   ${prefix}/bin/gmake

        patchfiles-append \
                    iconv.patch
    }
}

use_configure       no

configure.cppflags-append \
                    -I${qt_includes_dir}
configure.ldflags-append \
                    -L${qt_libs_dir} -F${qt_frameworks_dir}

build.cmd-prepend   APPS_DIR=${applications_dir} \
                    CC=${configure.cc} \
                    CXX=${configure.cxx} \
                    CFLAGS="${configure.cppflags} ${configure.cflags} [get_canonical_archflags cc]" \
                    CXXFLAGS="${configure.cppflags} ${configure.cxxflags} [get_canonical_archflags cxx]" \
                    LDFLAGS="${configure.ldflags} [get_canonical_archflags ld]" \
                    MOC=${qt_moc_cmd} \
                    PREFIX=${prefix} \
                    QTINCLUDE=${qt_includes_dir}

build.args-append   TARGET_ARCH=macosx \
                    TARGET_STATUS=release \
                    UI_TYPE=${qt_name} \
                    VERBOSE=1

destroot.env-append APPS_DIR=${applications_dir}

destroot.args-append \
                    TARGET_ARCH=macosx \
                    TARGET_STATUS=release \
                    UI_TYPE=${qt_name}
