gdal-1.11.1-r4.ebuild 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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"
  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 ruby 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. ruby? ( dev-lang/ruby:1.9 )
  49. sqlite? ( dev-db/sqlite:3 )
  50. spatialite? ( dev-db/spatialite )
  51. xls? ( dev-libs/freexl )
  52. "
  53. SWIG_DEP=">=dev-lang/swig-2.0.2"
  54. DEPEND="${RDEPEND}
  55. doc? ( app-doc/doxygen )
  56. java? ( >=virtual/jdk-1.6 )
  57. perl? ( ${SWIG_DEP} )
  58. python? ( ${SWIG_DEP} )
  59. ruby? ( ${SWIG_DEP} )"
  60. AT_M4DIR="${S}/m4"
  61. MAKEOPTS+=" -j1"
  62. REQUIRED_USE="
  63. spatialite? ( sqlite )
  64. mdb? ( java )
  65. "
  66. pkg_setup() {
  67. java-pkg-opt-2_pkg_setup
  68. }
  69. src_prepare() {
  70. java-pkg-opt-2_src_prepare
  71. # fix datadir and docdir placement
  72. sed -i \
  73. -e "s:@datadir@:@datadir@/gdal:" \
  74. -e "s:@exec_prefix@/doc:@exec_prefix@/share/doc/${PF}/html:g" \
  75. "${S}"/GDALmake.opt.in || die
  76. # the second sed expression should fix bug 371075
  77. sed -i \
  78. -e "s:setup.py install:setup.py install --root=\$(DESTDIR):" \
  79. -e "s:--prefix=\$(DESTDIR):--prefix=:" \
  80. "${S}"/swig/python/GNUmakefile || die
  81. epatch "${FILESDIR}"/${PN}-1.10.0-ruby-makefile.patch
  82. # -soname is only accepted by GNU ld/ELF
  83. [[ ${CHOST} == *-darwin* ]] \
  84. && epatch "${FILESDIR}"/${PN}-1.5.0-install_name.patch \
  85. || epatch "${FILESDIR}"/${PN}-1.5.0-soname.patch
  86. # Fix spatialite/sqlite include issue
  87. sed -i \
  88. -e 's:spatialite/sqlite3.h:sqlite3.h:g' \
  89. ogr/ogrsf_frmts/sqlite/ogr_sqlite.h || die
  90. # Fix freexl configure check
  91. sed -i \
  92. -e 's:FREEXL_LIBS=missing):FREEXL_LIBS=missing,-lm):g' \
  93. configure.in || die
  94. sed \
  95. -e "s: /usr/: \"${EPREFIX}\"/usr/:g" \
  96. -i configure.in || die
  97. sed \
  98. -e 's:^ar:$(AR):g' \
  99. -i ogr/ogrsf_frmts/sdts/install-libs.sh || die
  100. # Fix swig-3.0.3 problem (bug #534168)
  101. epatch "${FILESDIR}"/${PN}-1.11.1-swig-3.0.3.patch
  102. # Fix swig-3.0.6 problem, https://trac.osgeo.org/gdal/ticket/6045
  103. epatch "${FILESDIR}"/${PN}-1.11-swig-3.0.6.patch
  104. # bug 540132
  105. epatch "${FILESDIR}"/${PN}-1.11.1-poppler-0.31.0-support.patch
  106. tc-export AR RANLIB
  107. eautoreconf
  108. prepare_python() {
  109. mkdir -p "${BUILD_DIR}" || die
  110. find "${S}" -type d -maxdepth 1 -exec ln -s {} "${BUILD_DIR}"/ \; ||die
  111. find "${S}" -type f -maxdepth 1 -exec cp --target="${BUILD_DIR}"/ {} + ||die
  112. # mkdir -p "${BUILD_DIR}"/swig/python || die
  113. # mkdir -p "${BUILD_DIR}"/apps || die
  114. # cp -dpR --target="${BUILD_DIR}"/swig/ \
  115. # "${S}"/swig/{python,SWIGmake.base,GNUmakefile} || die
  116. # ln -s "${S}"/swig/include "${BUILD_DIR}"/swig/ || die
  117. # ln -s "${S}"/apps/gdal-config "${BUILD_DIR}"/apps/ || die
  118. # ln -s "${S}"/port "${BUILD_DIR}"/ || die
  119. }
  120. if use python; then
  121. python_foreach_impl prepare_python
  122. fi
  123. }
  124. gdal_src_configure() {
  125. local myopts=""
  126. if use ruby; then
  127. RUBY_MOD_DIR="$(ruby19 -r rbconfig -e 'print RbConfig::CONFIG["sitearchdir"]')"
  128. echo "Ruby module dir is: $RUBY_MOD_DIR"
  129. fi
  130. if use java; then
  131. myopts+="
  132. --with-java=$(java-config --jdk-home 2>/dev/null)
  133. $(use_with mdb)"
  134. else
  135. myopts+=" --without-java --without-mdb"
  136. use mdb && ewarn "mdb requires java use enabled. disabling"
  137. fi
  138. if use sqlite; then
  139. myopts+=" LIBS=-lsqlite3"
  140. fi
  141. # pcidsk is internal, because there is no such library yet released
  142. # also that thing is developed by the gdal people
  143. # kakadu, mrsid jp2mrsid - another jpeg2k stuff, ignore
  144. # bsb - legal issues
  145. # oracle - disabled, i dont have and can't test
  146. # ingres - same story as oracle oci
  147. # podofo - we use poppler instead they are exclusive for each other
  148. # tiff is a hard dep
  149. ECONF_SOURCE="${S}" econf \
  150. --includedir="${EPREFIX}/usr/include/${PN}" \
  151. --disable-static \
  152. --enable-shared \
  153. --with-expat \
  154. --with-geotiff \
  155. --with-grib \
  156. --with-libtiff \
  157. --with-libz="${EPREFIX}/usr/" \
  158. --with-ogr \
  159. --without-bsb \
  160. --without-dods-root \
  161. --without-dwgdirect \
  162. --without-epsilon \
  163. --without-fme \
  164. --without-grass \
  165. --without-hdf4 \
  166. --without-idb \
  167. --without-ingres \
  168. --without-jp2mrsid \
  169. --without-kakadu \
  170. --without-libtool \
  171. --without-mrsid \
  172. --without-msg \
  173. --without-oci \
  174. --without-pcraster \
  175. --without-podofo \
  176. --without-sde \
  177. $(use_enable debug) \
  178. $(use_with armadillo) \
  179. $(use_with aux_xml pam) \
  180. $(use_with curl) \
  181. --without-ecw \
  182. $(use_with fits cfitsio) \
  183. $(use_with geos) \
  184. $(use_with gif) \
  185. $(use_with gml xerces) \
  186. $(use_with hdf5) \
  187. $(use_with jpeg pcidsk) \
  188. $(use_with jpeg) \
  189. $(use_with jpeg2k jasper) \
  190. $(use_with mysql mysql "${EPREFIX}"/usr/bin/mysql_config) \
  191. $(use_with netcdf) \
  192. $(use_with odbc) \
  193. $(use_with ogdi ogdi "${EPREFIX}"/usr) \
  194. $(use_with opencl) \
  195. $(use_with pdf poppler) \
  196. $(use_with perl) \
  197. $(use_with png) \
  198. $(use_with postgres pg) \
  199. $(use_with python) \
  200. $(use_with ruby) \
  201. $(use_with spatialite) \
  202. $(use_with sqlite sqlite3 "${EPREFIX}"/usr) \
  203. $(use_with threads) \
  204. $(use_with xls freexl) \
  205. ${myopts}
  206. # mysql-config puts this in (and boy is it a PITA to get it out)
  207. if use mysql; then
  208. sed -i \
  209. -e "s: -rdynamic : :" \
  210. GDALmake.opt || die "sed LIBS failed"
  211. fi
  212. if [[ -n $use_python ]]; then
  213. # updated for newer swig (must specify the path to input files)
  214. sed -i \
  215. -e "s: gdal_array.i: ../include/gdal_array.i:" \
  216. -e "s:\$(DESTDIR)\$(prefix):\$(DESTDIR)\$(INST_PREFIX):g" \
  217. swig/python/GNUmakefile || die "sed python makefile failed"
  218. sed -i \
  219. -e "s:library_dirs = :library_dirs = /usr/$(get_libdir):g" \
  220. swig/python/setup.cfg || die "sed python setup.cfg failed"
  221. # -e "s:gdal_config=.*$:gdal_config=../../../apps/gdal-config:g" \
  222. fi
  223. }
  224. src_configure() {
  225. local use_python=""
  226. gdal_src_configure
  227. if use python; then
  228. use_python="yes"
  229. python_foreach_impl run_in_build_dir gdal_src_configure
  230. fi
  231. }
  232. src_compile() {
  233. local i
  234. for i in perl ruby; do
  235. if use $i; then
  236. rm "${S}"/swig/$i/*_wrap.cpp
  237. emake -C "${S}"/swig/$i generate
  238. fi
  239. done
  240. default
  241. if use perl ; then
  242. pushd "${S}"/swig/perl > /dev/null
  243. perl-module_src_configure
  244. perl-module_src_compile
  245. popd > /dev/null
  246. fi
  247. use doc && emake docs
  248. compile_python() {
  249. rm -f swig/python/*_wrap.cpp
  250. emake -C swig/python generate
  251. emake -C swig/python build
  252. }
  253. if use python; then
  254. python_foreach_impl run_in_build_dir compile_python
  255. fi
  256. }
  257. src_install() {
  258. if use perl ; then
  259. pushd "${S}"/swig/perl > /dev/null
  260. perl-module_src_install
  261. popd > /dev/null
  262. sed -i \
  263. -e "s:BINDINGS = python ruby perl:BINDINGS = python ruby:g" \
  264. GDALmake.opt || die
  265. fi
  266. default
  267. if use ruby ; then
  268. # weird reinstall collision; needs manual intervention...
  269. pushd "${S}"/swig/ruby > /dev/null
  270. rm -rf "${D}"${RUBY_MOD_DIR}/gdal
  271. exeinto ${RUBY_MOD_DIR}/gdal
  272. doexe *.so || die "doins ruby modules failed"
  273. popd > /dev/null
  274. fi
  275. use perl && perl_delete_localpod
  276. dodoc Doxyfile HOWTO-RELEASE NEWS
  277. if use doc ; then
  278. dohtml html/*
  279. docinto ogr
  280. dohtml ogr/html/*
  281. fi
  282. install_python() {
  283. emake -C swig/python DESTDIR="${D}" install
  284. }
  285. if use python; then
  286. python_foreach_impl run_in_build_dir install_python
  287. newdoc swig/python/README.txt README-python.txt
  288. insinto /usr/share/${PN}/samples
  289. doins swig/python/samples/*
  290. python_replicate_script "${ED}"/usr/bin/*py
  291. fi
  292. pushd man/man1 > /dev/null
  293. for i in * ; do
  294. newman ${i} ${i}
  295. done
  296. popd > /dev/null
  297. }
  298. pkg_postinst() {
  299. elog "Check available image and data formats after building with"
  300. elog "gdalinfo and ogrinfo (using the --formats switch)."
  301. }