Portfile

# $Id: Portfile 20498 2006-11-03 15:51:17Z blair@macports.org $

PortSystem 1.0
name kxterm
version 5.0pl3
categories x11 chinese
maintainers nomaintainer@macports.org
description Chinese-capable xterm with dictionary-lookup capability
long_description \
kxterm is an extension of cxterm, where cxterm is a terminal emulator \
for X11, just like xterm, but with the capability of displaying and \
inputting Chinese. kxterms enhancement is that, while reading Chinese \
text, each time you see a character you do not know, click on it with \
the left mouse button. Pronunciations in Cantonese (Sidney Lau system), \
then Mandarin (standard pinyin), as well as an approximate English \
translation, for the character will then appear at the bottom of the \
kxterm screen. If this character, along with neighboring characters, \
forms a character-compound found in Compound.b5, this compound will be \
displayed as well.

platforms darwin

homepage http://heather.cs.ucdavis.edu/~matloff/Chinese/KX/Index.html
master_sites http://heather.cs.ucdavis.edu/~matloff/Chinese/KX/Packages/
distname KXTerm

worksrcdir cxterm-5.0

checksums md5 ece6a83c1fe1c3451e3667f51c77b2ec

depends_build bin:xmkmf:XFree86

patchfiles patch-cxterm_misc.c patch-CXterm.ad

configure {
cd ${worksrcpath}
system "xmkmf"
}

build.target -f Makefile.ini World

destroot.args DOCHTMLDIR="${prefix}/share/doc/${name}" \
MANPATH="${prefix}/share/man" \
DICTDIR="${prefix}/share/${name}" \
FONTINSTDIR="${prefix}/share/${name}/fonts" \
INSTALLFLAGS="-c" INSTUIDFLAGS=""

post-destroot {
# Move executables to proper DP location
xinstall -m 755 -d ${destroot}${prefix}/bin
eval file rename [glob ${destroot}/usr/X11R6/bin/*] \
${destroot}${prefix}/bin
# Docs
xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
xinstall -m 644 -W ${worksrcpath} README.kxterm \
${destroot}${prefix}/share/doc/${name}
xinstall -m 644 -W ${worksrcpath}/cxterm SampleText.b5 SampleText.gb \
${destroot}${prefix}/share/doc/${name}
eval file copy [glob ${worksrcpath}/Doc/*] \
${destroot}${prefix}/share/doc/${name}
# Fix doc file and dir perms
system "find ${destroot}${prefix}/share/doc/${name} -type f -print0 | \
xargs -0 chmod +r"
system "find ${destroot}${prefix}/share/doc/${name} -type d -print0 | \
xargs -0 chmod +rx"
# DP-specific readme
xinstall -m 644 -W ${filespath} DarwinPorts_ReadMe.txt \
${destroot}${prefix}/share/doc/${name}
reinplace "s|@@PREFIX@@|${prefix}|g" \
${destroot}${prefix}/share/doc/${name}/DarwinPorts_ReadMe.txt
reinplace "s|@@NAME@@|${name}|g" \
${destroot}${prefix}/share/doc/${name}/DarwinPorts_ReadMe.txt

# X resource file
xinstall -m 644 -W ${worksrcpath} CXterm.ad \
${destroot}${prefix}/share/${name}
reinplace "s|cxterm-5.0/dict|${prefix}/share/${name}|g" \
${destroot}${prefix}/share/${name}/CXterm.ad

# Files not installed via make
xinstall -m 644 -W ${worksrcpath}/cxterm CanMan.b5 Compound.b5 \
${destroot}${prefix}/share/${name}/big5
xinstall -m 644 -W ${worksrcpath}/cxterm CanMan.gb Compound.gb \
${destroot}${prefix}/share/${name}/gb

# Convenience link for big5 usage
system "ln -s ${prefix}/bin/cxterm ${destroot}${prefix}/bin/cxtermb5"

# Wrapper script (install as CXterm.sh since CXterm would interfere
# with cxterm on certain filesystems
xinstall -m 755 -W ${filespath} CXterm.sh.head \
${destroot}${prefix}/bin/CXterm.sh
reinplace "s|@@PREFIX@@|${prefix}|g" ${destroot}${prefix}/bin/CXterm.sh
system "cat ${worksrcpath}/scripts/CXterm.sh >> \
${destroot}${prefix}/bin/CXterm.sh"
}

post-install {
ui_msg "Three lines need to be added to your .xinitrc file (and to others"
ui_msg "who wish to use kxterm):"
ui_msg ""
ui_msg "xrdb -merge ${prefix}/share/${name}/CXterm.ad"
ui_msg "xset fp+ ${prefix}/share/${name}/fonts"
ui_msg "xset fp rehash"
ui_msg ""
ui_msg "Be sure to have a look at "
ui_msg "${prefix}/share/doc/${name}/README if the basic configuration"
ui_msg "as set by the DarwinPorts install does not do enough for you"
ui_msg "(cxterm and cxtermb5 are both installed, for GB and Big5 use,"
ui_msg "respectively)."
ui_msg "${prefix}/share/doc/${name}/DarwinPorts_ReadMe.txt also"
ui_msg "contains this information."
}

variant darwin {
patchfiles-append patch-cxterm_Imakefile
}

files