bab1eab9d10808108a20ad6fc23c85348e8482d8
[gentoo.git] / sci-geosciences / qgis / qgis-2.18.2.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="6"
6
7 PYTHON_COMPAT=( python2_7 )
8 PYTHON_REQ_USE="sqlite"
9
10 inherit eutils gnome2-utils cmake-utils python-single-r1
11
12 DESCRIPTION="User friendly Geographic Information System"
13 HOMEPAGE="http://www.qgis.org/"
14 SRC_URI="
15         http://qgis.org/downloads/qgis-${PV}.tar.bz2
16         examples? ( http://download.osgeo.org/qgis/data/qgis_sample_data.tar.gz )"
17
18 LICENSE="GPL-2+ GPL-3+"
19 SLOT="0"
20 KEYWORDS="~amd64 ~x86"
21 IUSE="examples georeferencer grass mapserver oracle postgres python"
22
23 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )
24                 mapserver? ( python )"
25
26 RDEPEND="
27         ${PYTHON_DEPS}
28         dev-libs/expat
29         sci-geosciences/gpsbabel
30         >=sci-libs/gdal-1.6.1:=[geos,python?,${PYTHON_USEDEP}]
31         sci-libs/geos
32         sci-libs/libspatialindex:=
33         sci-libs/proj
34         dev-libs/qjson
35         dev-qt/designer:4
36         dev-qt/qtcore:4
37         dev-qt/qtgui:4
38         dev-qt/qtscript:4
39         dev-qt/qtsvg:4
40         dev-qt/qtsql:4
41         dev-qt/qtwebkit:4
42         x11-libs/qscintilla:=
43         || (
44                 ( || ( <x11-libs/qwt-6.1.2:6[svg] >=x11-libs/qwt-6.1.2:6[svg,qt4] ) >=x11-libs/qwtpolar-1 )
45                 ( x11-libs/qwt:5[svg] <x11-libs/qwtpolar-1 )
46         )
47         georeferencer? ( sci-libs/gsl:= )
48         grass? ( || ( >=sci-geosciences/grass-7.0.0:= ) )
49         mapserver? ( dev-libs/fcgi )
50         oracle? ( dev-db/oracle-instantclient:= )
51         postgres? ( dev-db/postgresql:= )
52         python? (
53                 dev-python/PyQt4[X,sql,svg,webkit,${PYTHON_USEDEP}]
54                 dev-python/sip[${PYTHON_USEDEP}]
55                 dev-python/qscintilla-python[${PYTHON_USEDEP}]
56                 dev-python/python-dateutil[${PYTHON_USEDEP}]
57                 dev-python/httplib2[${PYTHON_USEDEP}]
58                 dev-python/jinja[${PYTHON_USEDEP}]
59                 dev-python/markupsafe[${PYTHON_USEDEP}]
60                 dev-python/pygments[${PYTHON_USEDEP}]
61                 dev-python/pytz[${PYTHON_USEDEP}]
62                 dev-python/six[${PYTHON_USEDEP}]
63                 postgres? ( dev-python/psycopg:2[${PYTHON_USEDEP}] )
64                 ${PYTHON_DEPS}
65         )
66         dev-db/sqlite:3
67         dev-db/spatialite
68         app-crypt/qca:2[qt4,ssl]
69 "
70
71 DEPEND="${RDEPEND}
72         sys-devel/bison
73         sys-devel/flex"
74
75 DOCS=( BUGS ChangeLog NEWS )
76
77 # Disabling test suite because upstream disallow running from install path
78 RESTRICT="test"
79
80 pkg_setup() {
81         python-single-r1_pkg_setup
82 }
83
84 src_prepare() {
85         default
86
87         cd src/plugins || die
88         use georeferencer || cmake_comment_add_subdirectory "georeferencer"
89 }
90
91 src_configure() {
92         local mycmakeargs=(
93                 -DQGIS_MANUAL_SUBDIR=/share/man/
94                 -DBUILD_SHARED_LIBS=ON
95                 -DQGIS_LIB_SUBDIR=$(get_libdir)
96                 -DQGIS_PLUGIN_SUBDIR=$(get_libdir)/qgis
97                 -DWITH_INTERNAL_DATEUTIL=OFF
98                 -DWITH_INTERNAL_HTTPLIB2=OFF
99                 -DWITH_INTERNAL_JINJA2=OFF
100                 -DWITH_INTERNAL_MARKUPSAFE=OFF
101                 -DWITH_INTERNAL_PYGMENTS=OFF
102                 -DWITH_INTERNAL_PYTZ=OFF
103                 -DWITH_INTERNAL_QWTPOLAR=OFF
104                 -DWITH_INTERNAL_SIX=OFF
105                 -DPEDANTIC=OFF
106                 -DWITH_APIDOC=OFF
107                 -DWITH_QSPATIALITE=ON
108                 -DENABLE_TESTS=OFF
109                 -DWITH_BINDINGS="$(usex python)"
110                 -DWITH_GRASS7="$(usex grass)"
111                 $(usex grass "-DGRASS_PREFIX=/usr/" "")
112                 -DWITH_ORACLE="$(usex oracle)"
113                 -DWITH_POSTGRESQL="$(usex postgres)"
114                 -DWITH_PYSPATIALITE="$(usex python)"
115                 -DWITH_SERVER="$(usex mapserver)"
116         )
117
118         if has_version '>=x11-libs/qwtpolar-1' &&  has_version 'x11-libs/qwt:5' ; then
119                 elog "Both >=x11-libs/qwtpolar-1 and x11-libs/qwt:5 installed. Force build with qwt6"
120                 if has_version '>=x11-libs/qwt-6.1.2' ; then
121                         mycmakeargs+=(
122                                 "-DQWT_INCLUDE_DIR=/usr/include/qwt6"
123                                 "-DQWT_LIBRARY=/usr/$(get_libdir)/libqwt6-qt4.so"
124                         )
125                 else
126                         mycmakeargs+=(
127                                 "-DQWT_INCLUDE_DIR=/usr/include/qwt6"
128                                 "-DQWT_LIBRARY=/usr/$(get_libdir)/libqwt6.so"
129                         )
130                 fi
131         fi
132
133         cmake-utils_src_configure
134 }
135
136 src_install() {
137         cmake-utils_src_install
138
139         newicon -s 128 images/icons/qgis-icon.png qgis.png
140         make_desktop_entry qgis "QGIS" qgis
141
142         if use examples; then
143                 insinto /usr/share/doc/${PF}/examples
144                 doins -r "${WORKDIR}"/qgis_sample_data/*
145         fi
146
147         python_optimize "${D}"/usr/share/qgis/python \
148                 "${D}"/$(python_get_sitedir)/qgis \
149                 "${D}"/$(python_get_sitedir)/pyspatialite
150
151         if use grass; then
152                 python_fix_shebang "${D}"/usr/share/qgis/grass/scripts
153                 python_optimize "${D}"/usr/share/qgis/grass/scripts
154         fi
155 }
156
157 pkg_preinst() {
158         gnome2_icon_savelist
159 }
160
161 pkg_postinst() {
162         if use postgres; then
163                 elog "If you don't intend to use an external PostGIS server"
164                 elog "you should install:"
165                 elog "   dev-db/postgis"
166         elif use python; then
167                 elog "Support of PostgreSQL is disabled."
168                 elog "But some installed python-plugins import the psycopg2 module."
169                 elog "If you do not need these plugins just disable them"
170                 elog "in the Plugins menu, else you need to set USE=\"postgres\""
171         fi
172
173         gnome2_icon_cache_update
174 }
175
176 pkg_postrm() {
177         gnome2_icon_cache_update
178 }