tesseract-9999.ebuild 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. MY_PN="tesseract-ocr"
  5. LANGPACKV="4.00"
  6. URI_PREFIX="https://github.com/${MY_PN}/tessdata/raw/${LANGPACKV}/"
  7. JAVA_PKG_OPT_USE="scrollview"
  8. inherit autotools git-r3 java-pkg-opt-2 toolchain-funcs
  9. DESCRIPTION="An OCR Engine, orginally developed at HP, now open source."
  10. HOMEPAGE="https://github.com/tesseract-ocr"
  11. SRC_URI="${URI_PREFIX}eng.traineddata -> eng.traineddata-${LANGPACKV}
  12. math? ( ${URI_PREFIX}equ.traineddata -> equ.traineddata-${LANGPACKV} )
  13. osd? ( ${URI_PREFIX}osd.traineddata -> osd.traineddata-${LANGPACKV} )"
  14. EGIT_REPO_URI="https://github.com/${MY_PN}/${PN}.git"
  15. LICENSE="Apache-2.0"
  16. SLOT="0"
  17. KEYWORDS=""
  18. IUSE="doc examples jpeg math opencl openmp osd png scrollview static-libs tiff training webp"
  19. # List of supported Gentoo linguas and their upstream mapping
  20. # https://github.com/tesseract-ocr/tesseract/wiki/Data-Files
  21. # "old" variants were regrouped in the matching modern locale
  22. LANGUAGES="af:afr am:amh ar:ara as:asm az:aze,aze_cyrl be:bel bn:ben bo:bod bs:bos bg:bul ca:cat cs:ces zh:chi_sim,chi_tra cy:cym da:dan de:deu,frk dz:dzo el:ell,grc en:enm eo:epo et:est eu:eus fa:fas fi:fin fr:fra,frm ga:gle gl:glg gu:guj he:heb hi:hin hr:hrv hu:hun id:ind is:isl it:ita,ita_old ja:jpn kn:kan ka:kat,kat_old kk:kaz km:khm ky:kir ko:kor ku:kur lo:lao la:lat lv:lav lt:lit ml:mal mr:mar mk:mkd ms:msa my:mya ne:nep nl:nld no:nor or:ori pa:pan pl:pol pt:por ro:ron ru:rus sa:san si:sin sk:slk sl:slv es:spa,spa_old sq:sqi sr:srp,srp_latn sw:swa sv:swe syc:syr ta:tam te:tel tg:tgk tl:tgl th:tha tr:tur ug:uig uk:ukr uz:uzb,uzb_cyrl vi:vie"
  23. # Missing matches:
  24. # ceb Cebuano
  25. # chr Cherokee
  26. # hat Haitian; Haitian Creole
  27. # iku Inuktitut
  28. # jav Javanese
  29. # mlt Maltese
  30. # pus Pushto; Pashto
  31. # tir Tigrinya
  32. # urd Urdu
  33. # yid Yiddish
  34. # l10n_en provides the additional data:
  35. # enm English, Middle (1100-1500)
  36. for lang in ${LANGUAGES}; do
  37. gentoo_lang=${lang%:*}
  38. tess_langs=${lang#*:}
  39. for tess_lang in ${tess_langs//,/ }; do
  40. SRC_URI+=" l10n_${gentoo_lang}? ( ${URI_PREFIX}${tess_lang}.traineddata -> ${tess_lang}.traineddata-${LANGPACKV} )"
  41. done
  42. IUSE+=" l10n_${gentoo_lang}"
  43. done
  44. # With opencl USE=tiff is necessary in leptonica
  45. CDEPEND=">=media-libs/leptonica-1.74:=[zlib,tiff?,jpeg?,png?,webp?]
  46. opencl? (
  47. virtual/opencl
  48. media-libs/tiff:0=
  49. media-libs/leptonica:=[tiff]
  50. )
  51. scrollview? (
  52. >=dev-java/piccolo2d-3.0:0
  53. )
  54. training? (
  55. dev-libs/icu:=
  56. x11-libs/pango:=
  57. x11-libs/cairo:=
  58. )"
  59. DEPEND="${CDEPEND}
  60. doc? ( app-doc/doxygen )
  61. scrollview? ( >=virtual/jdk-1.7 )"
  62. RDEPEND="${CDEPEND}
  63. scrollview? ( >=virtual/jre-1.7 )"
  64. DOCS=( AUTHORS ChangeLog NEWS README.md )
  65. PATCHES=(
  66. "${FILESDIR}/${PN}-4.00.00-use-system-piccolo2d.patch"
  67. )
  68. pkg_pretend() {
  69. [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
  70. }
  71. pkg_setup() {
  72. [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
  73. }
  74. src_unpack() {
  75. git-r3_src_unpack
  76. for file in ${A}; do
  77. if [[ "${file}" == *traineddata* ]]; then
  78. cp "${DISTDIR}/${file}" "${S}/tessdata/${file%-*}" || die
  79. fi
  80. done
  81. }
  82. src_prepare() {
  83. default
  84. eautoreconf
  85. java-pkg-opt-2_src_prepare
  86. }
  87. src_configure() {
  88. local myeconfargs=(
  89. --enable-shared
  90. $(use_enable opencl)
  91. $(use_enable openmp)
  92. $(use_enable scrollview graphics)
  93. $(use_enable static-libs static)
  94. )
  95. econf "${myeconfargs[@]}"
  96. }
  97. src_compile() {
  98. default
  99. use doc && emake doc
  100. use scrollview && emake ScrollView.jar JAVAC="javac $(java-pkg_javac-args)"
  101. use training && emake training
  102. }
  103. src_install() {
  104. use doc && HTML_DOCS=( doc/html/. )
  105. default
  106. prune_libtool_files
  107. if use training; then
  108. emake DESTDIR="${D}" training-install
  109. fi
  110. if use examples; then
  111. insinto /usr/share/doc/${PF}/examples
  112. doins testing/eurotext.tif testing/phototest.tif
  113. fi
  114. insinto /usr/share/tessdata
  115. doins tessdata/*traineddata* # language files
  116. use scrollview && doins java/ScrollView.jar # scrollview
  117. }