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