Merge remote-tracking branch 'github/pr/517'.
[gentoo.git] / sci-geosciences / qgis / qgis-2.12.1.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 PYTHON_COMPAT=( python2_7 )
8 PYTHON_REQ_USE="sqlite"
9
10 inherit eutils multilib 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"
19 SLOT="0"
20 KEYWORDS="~amd64 ~x86"
21 IUSE="examples grass gsl mapserver postgres python test"
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         gsl? ( sci-libs/gsl )
33         sci-libs/libspatialindex
34         sci-libs/proj
35         dev-qt/qtcore:4
36         dev-qt/qtgui:4
37         dev-qt/qtsvg:4
38         dev-qt/qtsql:4
39         dev-qt/qtwebkit:4
40         dev-qt/designer:4
41         x11-libs/qscintilla
42         || (
43                 ( || ( <x11-libs/qwt-6.1.2:6[svg] >=x11-libs/qwt-6.1.2:6[svg,qt4] ) >=x11-libs/qwtpolar-1 )
44                 ( x11-libs/qwt:5[svg] <x11-libs/qwtpolar-1 )
45         )
46         grass? ( || ( >=sci-geosciences/grass-7.0.0 ) )
47         mapserver? ( dev-libs/fcgi )
48         postgres? ( dev-db/postgresql:* )
49         python? (
50                 dev-python/PyQt4[X,sql,svg,webkit,${PYTHON_USEDEP}]
51                 dev-python/sip[${PYTHON_USEDEP}]
52                 dev-python/qscintilla-python[${PYTHON_USEDEP}]
53                 postgres? ( dev-python/psycopg:2[${PYTHON_USEDEP}] )
54                 ${PYTHON_DEPS}
55         )
56         dev-db/sqlite:3
57         dev-db/spatialite
58         app-crypt/qca:2[qt4,openssl]
59 "
60
61 DEPEND="${RDEPEND}
62         sys-devel/bison
63         sys-devel/flex"
64
65 pkg_setup() {
66         python-single-r1_pkg_setup
67 }
68
69 src_configure() {
70         local mycmakeargs=(
71                 "-DQGIS_MANUAL_SUBDIR=/share/man/"
72                 "-DBUILD_SHARED_LIBS=ON"
73                 "-DQGIS_LIB_SUBDIR=$(get_libdir)"
74                 "-DQGIS_PLUGIN_SUBDIR=$(get_libdir)/qgis"
75                 "-DWITH_INTERNAL_QWTPOLAR=OFF"
76                 "-DPEDANTIC=OFF"
77                 "-DWITH_APIDOC=OFF"
78                 "-DWITH_SPATIALITE=ON"
79                 "-DWITH_INTERNAL_SPATIALITE=OFF"
80                 $(cmake-utils_use_with postgres POSTGRESQL)
81                 $(cmake-utils_use_with grass GRASS)
82                 $(cmake-utils_use_with mapserver SERVER)
83                 $(cmake-utils_use_with python BINDINGS)
84                 $(cmake-utils_use python BINDINGS_GLOBAL_INSTALL)
85                 $(cmake-utils_use_with python PYSPATIALITE)
86                 $(cmake-utils_use_with gsl GSL)
87                 $(cmake-utils_use_enable test TESTS)
88                 $(usex grass "-DGRASS_PREFIX=/usr/" "")
89         )
90
91         if has_version '>=x11-libs/qwtpolar-1' &&  has_version 'x11-libs/qwt:5' ; then
92                 elog "Both >=x11-libs/qwtpolar-1 and x11-libs/qwt:5 installed. Force build with qwt6"
93                 if has_version '>=x11-libs/qwt-6.1.2' ; then
94                         mycmakeargs+=(
95                                 "-DQWT_INCLUDE_DIR=/usr/include/qwt6"
96                                 "-DQWT_LIBRARY=/usr/$(get_libdir)/libqwt6-qt4.so"
97                         )
98                 else
99                         mycmakeargs+=(
100                                 "-DQWT_INCLUDE_DIR=/usr/include/qwt6"
101                                 "-DQWT_LIBRARY=/usr/$(get_libdir)/libqwt6.so"
102                         )
103                 fi
104         fi
105
106         cmake-utils_src_configure
107 }
108
109 src_install() {
110         cmake-utils_src_install
111         dodoc BUGS ChangeLog CODING
112
113         newicon -s 128 images/icons/qgis-icon.png qgis.png
114         make_desktop_entry qgis "QGIS " qgis
115
116         if use examples; then
117                 insinto /usr/share/doc/${PF}/examples
118                 doins -r "${WORKDIR}"/qgis_sample_data/*
119         fi
120
121         python_optimize "${D}"/usr/share/qgis/python/plugins \
122                 "${D}"/$(python_get_sitedir)/qgis
123
124         if use grass; then
125                 python_fix_shebang "${D}"/usr/share/qgis/grass/scripts
126                 python_optimize "${D}"/usr/share/qgis/grass/scripts
127         fi
128 }
129
130 pkg_preinst() {
131         gnome2_icon_savelist
132 }
133
134 pkg_postinst() {
135         if use postgres; then
136                 elog "If you don't intend to use an external PostGIS server"
137                 elog "you should install:"
138                 elog "   dev-db/postgis"
139         else
140                 if use python ; then
141                         elog "Support of PostgreSQL is disabled."
142                         elog "But some installed python-plugins needs import psycopg2 module."
143                         elog "If you do not need this modules just disable them in main menu."
144                         elog "Or you need to set USE=postgres"
145                 fi
146         fi
147
148         gnome2_icon_cache_update
149 }
150
151 pkg_postrm() {
152         gnome2_icon_cache_update
153 }