gdal-2.0.2-r1.ebuild 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. WANT_AUTOCONF="2.5"
  5. GENTOO_DEPEND_ON_PERL="no"
  6. PYTHON_COMPAT=( python2_7 python3_4 )
  7. DISTUTILS_OPTIONAL=1
  8. inherit autotools eutils libtool perl-module distutils-r1 python-r1 toolchain-funcs java-pkg-opt-2
  9. DESCRIPTION="Translator library for raster geospatial data formats (includes OGR support)"
  10. HOMEPAGE="http://www.gdal.org/"
  11. SRC_URI="http://download.osgeo.org/${PN}/${PV}/${P}.tar.gz"
  12. SLOT="0/2"
  13. LICENSE="BSD Info-ZIP MIT"
  14. KEYWORDS="amd64 ~arm ~ppc ~ppc64 ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos"
  15. IUSE="armadillo +aux_xml curl debug doc fits geos gif gml hdf5 java jpeg jpeg2k mdb mysql netcdf odbc ogdi opencl pdf perl png postgres python spatialite sqlite threads xls"
  16. RDEPEND="
  17. dev-libs/expat
  18. dev-libs/json-c
  19. dev-libs/libpcre
  20. dev-libs/libxml2
  21. media-libs/tiff:0=
  22. sci-libs/libgeotiff
  23. sys-libs/zlib[minizip(+)]
  24. armadillo? ( sci-libs/armadillo[lapack] )
  25. curl? ( net-misc/curl )
  26. fits? ( sci-libs/cfitsio )
  27. geos? ( >=sci-libs/geos-2.2.1 )
  28. gif? ( media-libs/giflib:= )
  29. gml? ( >=dev-libs/xerces-c-3 )
  30. hdf5? ( >=sci-libs/hdf5-1.6.4[szip] )
  31. java? ( >=virtual/jre-1.6:* )
  32. jpeg? ( virtual/jpeg:0= )
  33. jpeg2k? ( media-libs/jasper:= )
  34. mysql? ( virtual/mysql )
  35. netcdf? ( sci-libs/netcdf )
  36. odbc? ( dev-db/unixODBC )
  37. ogdi? ( sci-libs/ogdi )
  38. opencl? ( virtual/opencl )
  39. pdf? ( >=app-text/poppler-0.24.3:= )
  40. perl? ( dev-lang/perl:= )
  41. png? ( media-libs/libpng:0= )
  42. postgres? ( >=dev-db/postgresql-8.4:= )
  43. python? (
  44. ${PYTHON_DEPS}
  45. dev-python/setuptools[${PYTHON_USEDEP}]
  46. dev-python/numpy[${PYTHON_USEDEP}]
  47. )
  48. sqlite? ( dev-db/sqlite:3 )
  49. spatialite? ( dev-db/spatialite )
  50. xls? ( dev-libs/freexl )
  51. "
  52. DEPEND="${RDEPEND}
  53. doc? ( app-doc/doxygen )
  54. java? ( >=virtual/jdk-1.6 )
  55. perl? ( dev-lang/swig:0 )
  56. python? ( dev-lang/swig:0 )"
  57. AT_M4DIR="${S}/m4"
  58. MAKEOPTS+=" -j1"
  59. REQUIRED_USE="
  60. spatialite? ( sqlite )
  61. mdb? ( java )
  62. "
  63. pkg_setup() {
  64. java-pkg-opt-2_pkg_setup
  65. }
  66. src_prepare() {
  67. java-pkg-opt-2_src_prepare
  68. # fix datadir and docdir placement
  69. sed -i \
  70. -e "s:@datadir@:@datadir@/gdal:" \
  71. -e "s:@exec_prefix@/doc:@exec_prefix@/share/doc/${PF}/html:g" \
  72. "${S}"/GDALmake.opt.in || die
  73. # the second sed expression should fix bug 371075
  74. sed -i \
  75. -e "s:setup.py install:setup.py install --root=\$(DESTDIR):" \
  76. -e "s:--prefix=\$(DESTDIR):--prefix=:" \
  77. "${S}"/swig/python/GNUmakefile || die
  78. # -soname is only accepted by GNU ld/ELF
  79. [[ ${CHOST} == *-darwin* ]] \
  80. && epatch "${FILESDIR}"/${PN}-1.5.0-install_name.patch \
  81. || epatch "${FILESDIR}"/${PN}-1.5.0-soname.patch
  82. # Fix spatialite/sqlite include issue
  83. sed -i \
  84. -e 's:spatialite/sqlite3.h:sqlite3.h:g' \
  85. ogr/ogrsf_frmts/sqlite/ogr_sqlite.h || die
  86. # Fix freexl configure check
  87. sed -i \
  88. -e 's:FREEXL_LIBS=missing):FREEXL_LIBS=missing,-lm):g' \
  89. configure.in || die
  90. sed \
  91. -e "s: /usr/: \"${EPREFIX}\"/usr/:g" \
  92. -i configure.in || die
  93. sed \
  94. -e 's:^ar:$(AR):g' \
  95. -i ogr/ogrsf_frmts/sdts/install-libs.sh || die
  96. tc-export AR RANLIB
  97. eautoreconf
  98. prepare_python() {
  99. mkdir -p "${BUILD_DIR}" || die
  100. find "${S}" -type d -maxdepth 1 -exec ln -s {} "${BUILD_DIR}"/ \; ||die
  101. find "${S}" -type f -maxdepth 1 -exec cp --target="${BUILD_DIR}"/ {} + ||die
  102. # mkdir -p "${BUILD_DIR}"/swig/python || die
  103. # mkdir -p "${BUILD_DIR}"/apps || die
  104. # cp -dpR --target="${BUILD_DIR}"/swig/ \
  105. # "${S}"/swig/{python,SWIGmake.base,GNUmakefile} || die
  106. # ln -s "${S}"/swig/include "${BUILD_DIR}"/swig/ || die
  107. # ln -s "${S}"/apps/gdal-config "${BUILD_DIR}"/apps/ || die
  108. # ln -s "${S}"/port "${BUILD_DIR}"/ || die
  109. }
  110. if use python; then
  111. python_foreach_impl prepare_python
  112. fi
  113. }
  114. gdal_src_configure() {
  115. local myopts=""
  116. if use java; then
  117. myopts+="
  118. --with-java=$(java-config --jdk-home 2>/dev/null)
  119. $(use_with mdb)"
  120. else
  121. myopts+=" --without-java --without-mdb"
  122. use mdb && ewarn "mdb requires java use enabled. disabling"
  123. fi
  124. if use sqlite; then
  125. myopts+=" LIBS=-lsqlite3"
  126. fi
  127. # pcidsk is internal, because there is no such library yet released
  128. # also that thing is developed by the gdal people
  129. # kakadu, mrsid jp2mrsid - another jpeg2k stuff, ignore
  130. # bsb - legal issues
  131. # oracle - disabled, i dont have and can't test
  132. # ingres - same story as oracle oci
  133. # podofo - we use poppler instead they are exclusive for each other
  134. # tiff is a hard dep
  135. ECONF_SOURCE="${S}" econf \
  136. --includedir="${EPREFIX}/usr/include/${PN}" \
  137. --disable-static \
  138. --enable-shared \
  139. --with-expat \
  140. --with-geotiff \
  141. --with-grib \
  142. --with-libtiff \
  143. --with-libz="${EPREFIX}/usr/" \
  144. --with-ogr \
  145. --without-bsb \
  146. --without-dods-root \
  147. --without-dwgdirect \
  148. --without-epsilon \
  149. --without-fme \
  150. --without-grass \
  151. --without-hdf4 \
  152. --without-idb \
  153. --without-ingres \
  154. --without-jp2mrsid \
  155. --without-kakadu \
  156. --without-libtool \
  157. --without-mrsid \
  158. --without-msg \
  159. --without-oci \
  160. --without-pcraster \
  161. --without-podofo \
  162. --without-sde \
  163. $(use_enable debug) \
  164. $(use_with armadillo) \
  165. $(use_with aux_xml pam) \
  166. $(use_with curl) \
  167. --without-ecw \
  168. $(use_with fits cfitsio) \
  169. $(use_with geos) \
  170. $(use_with gif) \
  171. $(use_with gml xerces) \
  172. $(use_with hdf5) \
  173. $(use_with jpeg pcidsk) \
  174. $(use_with jpeg) \
  175. $(use_with jpeg2k jasper) \
  176. $(use_with mysql mysql "${EPREFIX}"/usr/bin/mysql_config) \
  177. $(use_with netcdf) \
  178. $(use_with odbc) \
  179. $(use_with ogdi ogdi "${EPREFIX}"/usr) \
  180. $(use_with opencl) \
  181. $(use_with pdf poppler) \
  182. $(use_with perl) \
  183. $(use_with png) \
  184. $(use_with postgres pg) \
  185. $(use_with python) \
  186. $(use_with spatialite) \
  187. $(use_with sqlite sqlite3 "${EPREFIX}"/usr) \
  188. $(use_with threads) \
  189. $(use_with xls freexl) \
  190. ${myopts}
  191. # mysql-config puts this in (and boy is it a PITA to get it out)
  192. if use mysql; then
  193. sed -i \
  194. -e "s: -rdynamic : :" \
  195. GDALmake.opt || die "sed LIBS failed"
  196. fi
  197. if [[ -n $use_python ]]; then
  198. # updated for newer swig (must specify the path to input files)
  199. sed -i \
  200. -e "s: gdal_array.i: ../include/gdal_array.i:" \
  201. -e "s:\$(DESTDIR)\$(prefix):\$(DESTDIR)\$(INST_PREFIX):g" \
  202. swig/python/GNUmakefile || die "sed python makefile failed"
  203. sed -i \
  204. -e "s:library_dirs = :library_dirs = /usr/$(get_libdir):g" \
  205. swig/python/setup.cfg || die "sed python setup.cfg failed"
  206. # -e "s:gdal_config=.*$:gdal_config=../../../apps/gdal-config:g" \
  207. fi
  208. }
  209. src_configure() {
  210. local use_python=""
  211. gdal_src_configure
  212. if use python; then
  213. use_python="yes"
  214. python_foreach_impl run_in_build_dir gdal_src_configure
  215. fi
  216. }
  217. src_compile() {
  218. if use perl; then
  219. rm "${S}"/swig/perl/*_wrap.cpp || die
  220. emake -C "${S}"/swig/perl generate
  221. fi
  222. default
  223. if use perl ; then
  224. pushd "${S}"/swig/perl > /dev/null
  225. perl-module_src_configure
  226. perl-module_src_compile
  227. popd > /dev/null
  228. fi
  229. use doc && emake docs
  230. compile_python() {
  231. rm -f swig/python/*_wrap.cpp || die
  232. emake -C swig/python generate
  233. emake -C swig/python build
  234. }
  235. if use python; then
  236. python_foreach_impl run_in_build_dir compile_python
  237. fi
  238. }
  239. src_install() {
  240. if use perl ; then
  241. pushd "${S}"/swig/perl > /dev/null
  242. perl-module_src_install
  243. popd > /dev/null
  244. sed -e 's:BINDINGS = \(.*\) perl:BINDINGS = \1:g' \
  245. -i GDALmake.opt || die
  246. fi
  247. default
  248. use perl && perl_delete_localpod
  249. dodoc Doxyfile HOWTO-RELEASE NEWS
  250. use doc && dohtml html/*
  251. install_python() {
  252. emake -C swig/python DESTDIR="${D}" install
  253. }
  254. if use python; then
  255. python_foreach_impl run_in_build_dir install_python
  256. newdoc swig/python/README.txt README-python.txt
  257. insinto /usr/share/${PN}/samples
  258. doins swig/python/samples/*
  259. python_replicate_script "${ED}"/usr/bin/*py
  260. fi
  261. pushd man/man1 > /dev/null
  262. for i in * ; do
  263. newman ${i} ${i}
  264. done
  265. popd > /dev/null
  266. }
  267. pkg_postinst() {
  268. elog "Check available image and data formats after building with"
  269. elog "gdalinfo and ogrinfo (using the --formats switch)."
  270. }