# $Id: Portfile 65139 2010-03-22 19:51:18Z macsforever2000@macports.org $

PortSystem 1.0

name            texlive_base
version         2007
revision        8
categories      tex
maintainers     nomaintainer
description     TeX Live Binaries.
long_description    TeX Live is an easy way to get up and running with TeX. \
    It provides a comprehensive TeX system with binaries for most flavors \
    of Unix, including GNU/Linux, and also Windows. It includes all the \
    major TeX-related programs, macro packages, and fonts that are free \
    software, including support for many languages around the world.

homepage        http://www.tug.org/texlive/
platforms       darwin

master_sites    openbsd:distfiles \
                http://students.dec.bournemouth.ac.uk/ebarrett/texlive/distfiles/
distname        ${name}-${version}-src
worksrcdir      ${name}-${version}
use_bzip2       yes

# Bug #17555
universal_variant no

# Bug #18303
use_parallel_build no

checksums       md5 db006e9f0f63e9be72bd5c45d07905f6 \
                sha1 f6f0192c200473c361aedfa8d34691a99e4f7065
depends_lib     port:freetype port:fontconfig port:ncurses port:zlib \
                port:libpng port:texinfo port:texi2html port:ghostscript \
                port:texlive_texmf-minimal port:texlive_texmf-full \
                port:xorg-libXp

conflicts       pTeX ps2eps

depends_build   path:bin/perl:perl5

configure.args  --mandir=${prefix}/share/man \
                --infodir=${prefix}/share/info \
                --with-system-freetype2 --with-system-ncurses \
                --with-freetype2-libdir=${prefix}/lib \
                --with-freetype2-include=${prefix}/include \
                --with-system-pnglib --with-system-zlib \
                --with-system-gd --with-fontconfig=${prefix} \
                --disable-multiplatform --without-texinfo \
                --without-xdvipdfmx --without-texi2html \
                --without-psutils --without-system-icu \
                --x-includes=${prefix}/include \
                --x-libraries=${prefix}/lib

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

post-destroot   {
    copy ${destroot}${prefix}/share/texmf/web2c/texmf.cnf \
        ${destroot}${prefix}/share/texmf/web2c/texmf.cnf-dist
    reinplace "s/^TEXMFSYSCONFIG = .*/TEXMFSYSCONFIG = \$TEXMFMAIN/g" \
        ${destroot}${prefix}/share/texmf/web2c/texmf.cnf
#
#   if there is no graphics support (no_x11) then only mf is built
#   not mf-nowin.  if mf-nowin does not exist, make a link to mf named mf-nowin for scripts
#   that expect to have it
#
    if {![file exists ${destroot}${prefix}/bin/mf-nowin]} {
        file link ${destroot}${prefix}/bin/mf-nowin ${destroot}${prefix}/bin/mf
    }
}

post-activate   {
        system "mktexlsr"
        system "fmtutil-sys --all"
        system "updmap-sys --syncwithtrees"
}

if {![variant_isset no_x11] && ![variant_isset motif] && ![variant_isset xaw] && ![variant_isset xaw3d] && ![variant_isset nextaw]} {
    default_variants    +motif
}

variant no_x11 conflicts xaw motif xaw3d nextaw {
    depends_lib-delete port:xorg-libXp
    configure.args-append --without-x --without-pdfopen
    configure.args-delete  --x-includes=${prefix}/include \
                           --x-libraries=${prefix}/lib
}
variant motif conflicts no_x11 xaw xaw3d nextaw description {Use Motif to build xdvi} {
     depends_lib-append lib:libXm:openmotif
     configure.args-append --with-xdvi-x-toolkit=motif
}
variant xaw conflicts no_x11 motif xaw3d nextaw description {Use Xaw to build xdvi} {
    depends_lib-append port:xorg-libXaw
    configure.args-append --with-xdvi-x-toolkit=xaw
}
variant xaw3d conflicts no_x11 motif xaw nextaw description {Use Xaw3d to build xdvi} {
    depends_lib-append port:Xaw3d
    configure.args-append --with-xdvi-x-toolkit=xaw3d
}
variant nextaw conflicts no_x11 motif xaw xaw3d description {Use neXtaw to build xdvi} {
    depends_lib-append port:neXtaw
    configure.args-append --with-xdvi-x-toolkit=neXtaw
}

livecheck.type      regex
livecheck.url       ${homepage}acquire.html
livecheck.regex     "TeX Live (\[0-9\]+) "

post-patch {
    # Allow configure script to find libraries which end in .dylib.
    reinplace "s|for ac_extension in a so sl; do|for ac_extension in a so sl dylib; do|" \
        ${worksrcpath}/configure

    # Ensure correct compilers are used
    reinplace "s|CXX = c++|CXX = @CXX@|" \
        ${worksrcpath}/texk/xdv2pdf/Makefile.in
    reinplace "s|OBJC = cc|OBJC = \$(CC)|" \
        ${worksrcpath}/texk/xdv2pdf/Makefile.in

    # The check for Carbon is actually used for ATSU which is deprecated, force freetype
    reinplace "s|has_carbon=yes|has_carbon=no|" ${worksrcpath}/texk/web2c/configure
    reinplace "s|has_carbon=yes|has_carbon=no|" ${worksrcpath}/texk/xdv2pdf/configure
}

post-configure {
    # Ensure correct compiler is used
    reinplace "s|gcc -ObjC++ |\$(CC) -ObjC++ |" \
        ${worksrcpath}/texk/web2c/Makefile
}

pre-configure {
    reinplace "s|@echo|@/bin/echo|" ${worksrcpath}/libs/icu-xetex/config/mh-darwin
}

#Include all openBSD patches. Make texlive honor DESTDIR.
patchfiles      patch-Makefile_in\
    patch-libs_icu-xetex_Makefile_in\
    patch-libs_icu-xetex_layout_KernTable_cpp\
    patch-texk_afm2pl_Makefile_in\
    patch-texk_bibtex8_Makefile_in\
    patch-texk_cjkutils_conv_Makefile_in\
    patch-texk_cjkutils_hbf2gf_Makefile_in\
    patch-texk_cjkutils_scripts_Makefile_in\
    patch-texk_detex_Makefile_in\
    patch-texk_dtl_Makefile_in\
    patch-texk_dvi2tty_Makefile_in\
    patch-texk_dvidvi_Makefile_in\
    patch-texk_dviljk_Makefile_in\
    patch-texk_dvipdfm_Makefile_in\
    patch-texk_dvipos_Makefile_in\
    patch-texk_dvipsk_Makefile_in\
    patch-texk_gsftopk_Makefile_in\
    patch-texk_kpathsea_Makefile_in\
    patch-texk_lacheck_Makefile_in\
    patch-texk_make_man_mk\
    patch-texk_makeindexk_Makefile_in\
    patch-texk_musixflx_Makefile_in\
    patch-texk_ps2pkm_Makefile_in\
    patch-texk_seetexk_Makefile_in\
    patch-texk_tetex_Makefile_in\
    patch-texk_tetex_texlinks\
    patch-texk_tex4htk_Makefile_in\
    patch-texk_texlive_Makefile_in\
    patch-texk_ttf2pk_Makefile_in\
    patch-texk_web2c_Makefile_in\
    patch-texk_web2c_alephdir_aleph_mk\
    patch-texk_web2c_doc_Makefile_in\
    patch-texk_web2c_mpware_Makefile_in\
    patch-texk_web2c_omegadir_omega_mk\
    patch-texk_web2c_omegafonts_Makefile_in\
    patch-texk_web2c_otps_Makefile_in\
    patch-texk_web2c_pdftexdir_pdftex_mk\
    patch-texk_web2c_texmfmem_h\
    patch-texk_web2c_xetexdir_XeTeX_ext_c\
    patch-texk_web2c_xetexdir_XeTeX_ext_h\
    patch-texk_web2c_xetexdir_XeTeX_mac_c\
    patch-texk_web2c_xetexdir_jpegimage_c\
    patch-texk_web2c_xetexdir_xetex-new_ch\
    patch-texk_web2c_xetexdir_xetex_defines\
    patch-texk_web2c_xetexdir_xetex_h\
    patch-texk_web2c_xetexdir_xetex_mk\
    patch-texk_xdv2pdf_Makefile_in\
    patch-texk_xdvik_configure.diff\
    patch-texk_xdvik_Makefile_in\
    patch-texk_xdvipdfmx_src_tt_cmap_c\
    patch-utils_dialog_Makefile_in\
    patch-utils_ps2eps_Makefile_in\
    patch-utils_psutils_Makefile_in\
    patch-texk_web2c_omegafonts_pl_l.diff

# MP patches... kept separate from OpenBSD patches for maintainability
patchfiles-append \
    XeTeX_mac-loadAATfont.patch
