--- Portfile.old	2010-04-02 17:09:59.000000000 -0400
+++ Portfile	2010-10-14 14:51:22.000000000 -0400
@@ -1,48 +1,201 @@
-# $Id: Portfile 54783 2009-08-02 02:49:36Z toby@macports.org $
+# -*- 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$
 
 PortSystem          1.0
 
 name                tesseract
-version             2.04
+version             3.00
+revision            0
 categories          textproc graphics pdf
+platforms           darwin
+
 maintainers         emer.net:emer
+
 description         Open source OCR engine
-long_description    The Tesseract OCR engine was one of the top 3 engines in \
-                    the 1995 UNLV Accuracy test. Between 1995 and 2006 it had \
-                    little work done on it, but it is probably one of the \
-                    most accurate open source OCR engines available. The \
-                    source code will read a binary, grey or color image and \
-                    output text. A tiff reader is built in that will read \
-                    uncompressed TIFF images, or libtiff can be added to read \
+long_description    The Tesseract OCR engine was one of the top  3  engines in \
+                    the 1995 UNLV Accuracy test.  Between 1995 and 2006 it had \
+                    little work done on it,  but it is  probably  one  of  the \
+                    most accurate  open  source  OCR  engines  available.  The \
+                    source code will read a binary, grey or  color  image  and \
+                    output text.  A tiff reader is built  in  that  will  read \
+                    uncompressed TIFF images,  or libtiff can be added to read \
                     compressed images.
 
-platforms           darwin
 homepage            http://code.google.com/p/tesseract-ocr/
 master_sites        http://tesseract-ocr.googlecode.com/files:src \
                     http://tesseract-ocr.googlecode.com/files:langdata
 
-set lang_data       ${name}-2.00.eng${extract.suffix}
+dist_subdir         ${name}/${version}_${revision}
+
+distfiles           ${distname}${extract.suffix}:src
 
-distfiles \
-    ${distname}${extract.suffix}:src \
-    ${lang_data}:langdata
-
-checksums\
-    ${distname}${extract.suffix} \
- 		md5     b44eba1a9f4892ac62e484c807fe0533 \
-		sha1    850c42c92a4471c5f41d4384c57045e812fde26a \
-	    rmd160  826718ddf491c8b925b02c343d4a4992fd4631d8 \
-    ${lang_data} \
-        md5     b8291d6b3a63ce7879d688e845e341a9 \
-		sha1    40292c8d206090c4ab342f6b7814ea41c075abce \
-		rmd160  4a8090729504c216b3988f189ea79a5a5e223173
-		
-post-extract {
-    foreach f [exec ls ${workpath}/tessdata/] {
-        copy ${workpath}/tessdata/${f} ${worksrcpath}/tessdata
-    }
-    delete ${workpath}/tessdata
-    delete ${worksrcpath}/java/makefile
+set langs {
+    chi_tra chi_sim ind swe ron slv srp tgl tur hun fin ita nld nor
+    jpn vie spa ukr fra slk kor ell rus por bul lav lit pol deu dan 
+    ces cat eng
 }
 
-depends_lib         port:tiff
+foreach lang ${langs} {
+    eval [subst {
+        variant ${lang} description "Build with ${lang} data" {
+            distfiles-append ${lang}.traineddata.gz:langdata
+
+            post-destroot {
+                system "zcat ${distpath}/${lang}.traineddata.gz > ${destroot}${prefix}/share/tessdata/${lang}.traineddata"
+            }
+        }
+    }]
+}
+
+universal_variant   no
+
+default_variants    +eng
+
+extract.only        ${distname}${extract.suffix}
+
+checksums           ${distname}${extract.suffix} \
+                    md5     cc812a261088ea0c3d2da735be35d09f \
+                    sha1    1d797cae3d0047d7be6c9b17d1973a9afcf6bd81 \
+                    rmd160  82c84c33c414b9196d42f4675251f3ef3ab11b3a \
+                    chi_tra.traineddata.gz \
+                    md5     06fce5f5c0221286eab591819406d91e \
+                    sha1    a9798de7e068d85613602aa33a153da721aadc82 \
+                    rmd160  590262a166a86f55177dde0dd0b10926a91c1ef4 \
+                    chi_sim.traineddata.gz \
+                    md5     127e0b742b615d81c3b97a555acd8285 \
+                    sha1    35f0254f159edeed509ec1e0779073bf998b6cdb \
+                    rmd160  7a3e5f0f33f9869c10f793daee4883a5167eb178 \
+                    ind.traineddata.gz \
+                    md5     f4ae2e5668f693cc51c6e3c3f57a8f1d \
+                    sha1    f4214ce40c5f6ef92085a8a45e9ff03f7cf7afca \
+                    rmd160  bc714068a10982dcf32816e823dbca6be63489ee \
+                    swe.traineddata.gz \
+                    md5     3787ff0fc1a07517203466830f6f868e \
+                    sha1    55291e8ea664155ad51db867284c11ad1a1c5d00 \
+                    rmd160  7653dd8a57f75a9e240a8e256c7a4b20a2e91040 \
+                    ron.traineddata.gz \
+                    md5     7b50075692e7a07ac8f59e0cde51cfb9 \
+                    sha1    c20c73a2e17f5fe692de0fe9ac681da3984229ae \
+                    rmd160  9755d5002e6dfd581003168bae24bc0697c89318 \
+                    slv.traineddata.gz \
+                    md5     defc498fa09480ef0052fde79f4f84e5 \
+                    sha1    fbe464cd49d6a7495e6d95600d421aa2dd0b9d77 \
+                    rmd160  854b6ec39d09ec210a7850d56573f5a77da37b6e \
+                    srp.traineddata.gz \
+                    md5     c1e0f0ef07d26a72063802370bbfe2c9 \
+                    sha1    47afc601b62998e4cc3f7403d846ba861f30b416 \
+                    rmd160  70ef247a50a72c5d551f2f7dc246275b9096a9b8 \
+                    tgl.traineddata.gz \
+                    md5     af86cab0da52fff7e83f9c7668617a21 \
+                    sha1    153ba1d0ddd209e1581d81d42fe5346f748e2f27 \
+                    rmd160  669a4ea7bb6beac425070d8ba424f341eee447a9 \
+                    tur.traineddata.gz \
+                    md5     b0f4798bf1f9ee541ae73aff49f08821 \
+                    sha1    a01da62f3830833b258e2d46ce0f2852571470e6 \
+                    rmd160  15cebea216b539681d7306cab3f31f2773cd93e2 \
+                    hun.traineddata.gz \
+                    md5     966fa3ebe24d7dfade951e0a4a9f52b5 \
+                    sha1    32ecad03877a841fbc0cb31c269214640008d604 \
+                    rmd160  7acc341ed55ca61869c7876b8b37ac2a143abd5b \
+                    fin.traineddata.gz \
+                    md5     33812ef03197dce20b8c888409d8541a \
+                    sha1    004d74d13f7b53cbefb86e2ba12bc67dce81d936 \
+                    rmd160  a467774acf081aff2bd7fc5e1557eb1486336b6f \
+                    ita.traineddata.gz \
+                    md5     9a307661a010703cd2bb265a3da5eaff \
+                    sha1    c166ba79256f6e7c1b993b2db7403d794131fe05 \
+                    rmd160  522f4110223c0da1894d39bc49fd1400b1527e2e \
+                    nld.traineddata.gz \
+                    md5     89992f69802b9f4a36fec40efd95c503 \
+                    sha1    f7e3d46b1747a19158ac0797e859b65c56b5045f \
+                    rmd160  4026b44d7849a0c78d1831e00805f985ffad6421 \
+                    nor.traineddata.gz \
+                    md5     e09cc75fa17b8d4a5c2d02de73267aae \
+                    sha1    fb65dede5fbe120823ecdcb0c6cbd1222ae7e245 \
+                    rmd160  36ee419e1ba3a49db749f15c5b204bfaee0bc848 \
+                    jpn.traineddata.gz \
+                    md5     cad3dd7c9401fa0676bf195456ba0c14 \
+                    sha1    6d605eee29e76fb841924916bd34095bbbbc45c0 \
+                    rmd160  47dba0ff10e9bd6979a31fa1ccc79b7d84775432 \
+                    vie.traineddata.gz \
+                    md5     af75c7a696b18a1d2e4f7e21a222cf95 \
+                    sha1    9158748a63afe87e4e25b5f32c222555f2ad8417 \
+                    rmd160  74826cef758cf5a8c561c2e6381e053e151a6a91 \
+                    spa.traineddata.gz \
+                    md5     dd9078211127189995504f034468fcd6 \
+                    sha1    7b30950749e84891fdef5f89409c3cf1b6418cd3 \
+                    rmd160  92303810e9429ca5a9daa39e02a015a78ac09cd6 \
+                    ukr.traineddata.gz \
+                    md5     56a82ac3994f0552d54fd14ff5ed6817 \
+                    sha1    06ceebfd91fa473d6d91f8a2856c66733bea0131 \
+                    rmd160  0f040ec98453c38a0f19e90d7f34ab0dee8e9778 \
+                    fra.traineddata.gz \
+                    md5     e6000550883684b5e93b7e0a21016287 \
+                    sha1    8d698bb3b659e862b3274970a57b3214de76f1ff \
+                    rmd160  97ab2fb064da5d7d15032fd1c5e87aa2f14dc1b3 \
+                    slk.traineddata.gz \
+                    md5     2e7fbf80215b38f423dcf78e396b92d7 \
+                    sha1    16207e26d53504f98a7b1fadcb873dc4611149ec \
+                    rmd160  4e661fce45076128455f2b2d0e60b93d67a8038d \
+                    kor.traineddata.gz \
+                    md5     909b811739b2e7d51cc3ca109998353a \
+                    sha1    37bcd8110a426714f54d99f58b30104b3014ce5a \
+                    rmd160  1aa22020b2bcdea7721d111065b2070191149e32 \
+                    ell.traineddata.gz \
+                    md5     0d3a21c18f752eb058e7b854c37b7a69 \
+                    sha1    b7a449fc320cc579a729c0352e5cc642f565e64e \
+                    rmd160  791acfb5a60875d02e23ebc8c66243adedb5cf39 \
+                    rus.traineddata.gz \
+                    md5     c477b7faddc044a4595135d0378be34c \
+                    sha1    2740accefc45e4ae004269ccb195948b8037a583 \
+                    rmd160  aeb8ab308499f2414c21f5299f2abf5082c6a282 \
+                    por.traineddata.gz \
+                    md5     d0b59fcfd80f9e09be890647ae93f00d \
+                    sha1    883e5e1fa1d991ef6d202951ee9d26a71db181dc \
+                    rmd160  90a73ffdf23c3ca9cc1b30d5f30943c67f4f59a0 \
+                    bul.traineddata.gz \
+                    md5     a7501f9a48bc7ef2fa50cba8b8f0c7b1 \
+                    sha1    a9efae5e347a36ea90bd2ad357e732ad4da47fd3 \
+                    rmd160  cbcdb7532af8c03abb5f8bcdb5b34516b6a522e4 \
+                    lav.traineddata.gz \
+                    md5     1f366f55e5e0725deb751ec847bf42dc \
+                    sha1    b4efd308e725d743884f2984f804c82dd5382f63 \
+                    rmd160  eb1efa104597850e47cdae8fa70cc4f120959810 \
+                    lit.traineddata.gz \
+                    md5     1b4460ab998151f1ed8e48928ded58be \
+                    sha1    7adbe396a281c0f87c0b95da7e84b5b6029e3dbd \
+                    rmd160  65aab59e4be61c3734645f96e688dbd81aa384b1 \
+                    pol.traineddata.gz \
+                    md5     c3d6447245663138f1d3aa4567c72192 \
+                    sha1    a303fc31b4b60532b01b4ccdc838f02ff0113f27 \
+                    rmd160  08197fede8151cfdef50a6d2e41c55f384d3f909 \
+                    deu.traineddata.gz \
+                    md5     be81a761f61800f6d39393a31435fff3 \
+                    sha1    c4b3ecde18ce9f114faba88cdfd0308f90801266 \
+                    rmd160  f5e26562dfb3259c0c6fca0c9d1a23589f6af981 \
+                    dan.traineddata.gz \
+                    md5     7aaeb321dbf069d14d2601dc36d3dddc \
+                    sha1    bfac9c00d28fc4b19034c2098d41087a173084ae \
+                    rmd160  f354451e42486609ff631b5a3ba52134cc0a706f \
+                    ces.traineddata.gz \
+                    md5     2e97c952075064834f1cad6a133970fa \
+                    sha1    dbec19aa23f42a08e6b195a96e64b443f7519620 \
+                    rmd160  356bc1982be43cb89e1fa62b1af53a0f28d14444 \
+                    cat.traineddata.gz \
+                    md5     308099b2b95834916ec410191c86cd48 \
+                    sha1    0301a9c81c1d646bd1b135ca89476fb63bd634f8 \
+                    rmd160  3b1a5067e97e4c104ee766fc89cc47c261b55b38 \
+                    eng.traineddata.gz \
+                    md5     d91041ad156cf2db36664e91ef799451 \
+                    sha1    bf72c6c4542d67ce1d6def9d4e8432c7e98a654b \
+                    rmd160  d35ef8383c58faa6765e2eceb4da11fc688f488b
+
+depends_lib         port:tiff \
+                    port:zlib \
+                    port:libpng \
+					port:leptonica \
+                    port:jpeg
+
+livecheck.type      regex
+livecheck.url       ${master_sites}
+livecheck.regex     "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
