# -*- 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 115962 2014-01-15 15:22:01Z mojca@macports.org $

PortSystem          1.0
PortGroup           texlive 1.0

name                pgf
version             3.0.0
categories          tex textproc
platforms           darwin
license             {GPL-2 LPPL-1.3}
maintainers         nomaintainer

supported_archs     noarch

description         PGF and TikZ -- Graphic systems for TeX
long_description    PGF is a TeX macro package for generating graphics. \
                    It is platform- and format-independent and works \
                    together with the most important TeX backend \
                    drivers, including pdftex and dvips. It comes \
                    with a user-friedly syntax layer called TikZ.
homepage            http://sourceforge.net/projects/pgf/

depends_lib         bin:texhash:texlive-basic

master_sites        sourceforge:project/pgf/pgf/version%20${version}
use_zip             yes
distname            ${name}_${version}.tds
checksums           rmd160  572204fedbaf9034dc56d9049e40c919b08d4b9e \
                    sha256  672b15d0a73fcaee1efefdaf396db1d8313e08d91db9b15bfde293eb6132474e

extract.mkdir       yes

# the patchfiles are only relevant if building the C code gets enabled one day,
# but the patches are not complete yet (building the module is not working)
patchfiles          patch-MakefileConfig.mk.diff \
                    patch-Makefile.diff
post-patch {
    # instead of patching all this one could also create LocalMakefileConfig.mk
    set mymakefileconfig ${worksrcpath}/source/generic/pgf/c/config/MakefileConfig.mk
    reinplace s|@@PREFIX@@|${prefix}| ${mymakefileconfig}
    reinplace s|@@CC@@|${configure.cc}| ${mymakefileconfig}
    reinplace s|@@ARCHFLAGS@@|-arch\ ${build_arch}| ${mymakefileconfig}
    reinplace s|@@CFLAGS@@|${configure.cflags}| ${mymakefileconfig}
    reinplace s|@@LDFLAGS@@|${configure.ldflags}\ -llua| ${mymakefileconfig}
}

use_configure       no

# we won't build anything for now, but if anyone wants to finish the work,
# see https://trac.macports.org/ticket/42088
build { }
# build.dir         ${worksrcpath}/source/generic/pgf/c

destroot {
    set r ${workpath}/${name}_${version}.tds
    file mkdir ${destroot}${texlive_texmfports}/
    file copy ${r}/doc ${destroot}${texlive_texmfports}/
    file copy ${r}/source ${destroot}${texlive_texmfports}/
    file copy ${r}/tex ${destroot}${texlive_texmfports}/
}

post-activate {
    texlive.mktexlsr
}

post-deactivate {
    texlive.mktexlsr
}

livecheck.regex     {/version ([.\d]+)}
