# -*- 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 115966 2014-01-15 16:51:19Z devans@macports.org $

PortSystem              1.0
PortGroup               qt4 1.0

name                    texstudio
version                 2.5.1
categories              editors
platforms               darwin
license                 GPL-2+
maintainers             nomaintainer
supported_archs         i386 x86_64

description             TeX editor

long_description        texstudio is a TeX editor forked off texmarker.

homepage                http://texstudio.sourceforge.net/
master_sites            sourceforge:project/texstudio/texstudio/TeXstudio%20${version}
extract.suffix          .orig.tar.gz

checksums               rmd160  e2b90518a60b4c70771a4885e920a324d68ceb60 \
                        sha256  7f7ae53818d74a06fffef81e1aa9552badd85045a9953b13f28d15b393962015

depends_lib-append      port:poppler-qt4-mac

pre-patch {
    # DOS to UNIX line endings so we can patch
    reinplace "s|\r||g" ${worksrcpath}/texstudio.pro
}

patchfiles              patch-texstudio.pro.diff

post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/texstudio.pro
}

# error: unable to read PCH file: 'Is a directory'
# https://bugreports.qt-project.org/browse/QTBUG-27018
compiler.blacklist      *clang*

universal_variant       no

configure.cmd           ${qt_qmake_cmd}
configure.pre_args      PREFIX=${prefix}
configure.args-append   CONFIG+="${qt_arch_types}"

build.args              CC="${configure.cc} [get_canonical_archflags cc]" \
                        CXX="${configure.cxx} [get_canonical_archflags cxx]" \
                        LINK="${configure.cxx} [get_canonical_archflags cxx]"

destroot {
    copy ${worksrcpath}/texstudio.app ${destroot}${applications_dir}
    ln -s ${applications_dir}/texstudio.app/Contents/MacOS/texstudio ${destroot}${prefix}/bin/texstudio
}
