summaryrefslogtreecommitdiff
blob: ad7b0c96ad8004dd3b84d2a2da2c8821650b7605 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{10..11} )
inherit cmake java-pkg-opt-2 python-single-r1

DESCRIPTION="Translator library for raster geospatial data formats (includes OGR support)"
HOMEPAGE="https://gdal.org/"
SRC_URI="https://download.osgeo.org/${PN}/${PV}/${P}.tar.xz"
SRC_URI+=" test? ( https://download.osgeo.org/${PN}/${PV}/${PN}autotest-${PV}.tar.gz )"

LICENSE="BSD Info-ZIP MIT"
SLOT="0/33" # subslot is libgdal.so.<SONAME>
KEYWORDS="amd64 ~arm arm64 ~ia64 ~ppc ppc64 ~riscv x86 ~amd64-linux ~x86-linux ~ppc-macos"
IUSE="armadillo +curl cpu_flags_x86_avx cpu_flags_x86_avx2 cpu_flags_x86_sse cpu_flags_x86_sse2 cpu_flags_x86_sse4_1 cpu_flags_x86_ssse3 doc fits geos gif gml hdf5 heif java jpeg jpeg2k lzma mysql netcdf odbc ogdi opencl oracle pdf png postgres python spatialite sqlite test webp xls zstd"
RESTRICT="!test? ( test )"

REQUIRED_USE="
	python? ( ${PYTHON_REQUIRED_USE} )
	spatialite? ( sqlite )
	test? ( ${PYTHON_REQUIRED_USE} )
"

BDEPEND="
	virtual/pkgconfig
	doc? ( app-doc/doxygen )
	java? (
		dev-java/ant-core
		dev-lang/swig
	)
	python? (
		dev-lang/swig
		$(python_gen_cond_dep '
			dev-python/setuptools[${PYTHON_USEDEP}]
		')
	)
	test? (
		${PYTHON_DEPS}
		dev-cpp/gtest
	)
"
DEPEND="
	dev-libs/expat
	dev-libs/json-c:=
	dev-libs/libpcre2
	dev-libs/libxml2:2
	dev-libs/openssl:=
	media-libs/tiff
	>=sci-libs/libgeotiff-1.5.1-r1:=
	>=sci-libs/proj-6.0.0:=
	sys-libs/zlib[minizip(+)]
	armadillo? ( sci-libs/armadillo:=[lapack] )
	curl? ( net-misc/curl )
	fits? ( sci-libs/cfitsio:= )
	geos? ( >=sci-libs/geos-3.8.0 )
	gif? ( media-libs/giflib:= )
	gml? ( >=dev-libs/xerces-c-3.1 )
	heif? ( media-libs/libheif:= )
	hdf5? ( >=sci-libs/hdf5-1.6.4:=[cxx,szip] )
	java? (
		>=virtual/jdk-1.8:*[-headless-awt]
	)
	jpeg? ( media-libs/libjpeg-turbo:= )
	jpeg2k? ( media-libs/openjpeg:2= )
	lzma? ( || (
		app-arch/xz-utils
		app-arch/lzma
	) )
	mysql? ( virtual/mysql )
	netcdf? ( sci-libs/netcdf:= )
	odbc? ( dev-db/unixODBC )
	ogdi? ( >=sci-libs/ogdi-4.1.0-r1 )
	opencl? ( virtual/opencl )
	oracle? ( dev-db/oracle-instantclient:= )
	pdf? ( app-text/poppler:= )
	png? ( media-libs/libpng:= )
	postgres? ( >=dev-db/postgresql-8.4:= )
	python? (
		${PYTHON_DEPS}
		$(python_gen_cond_dep '
			dev-python/numpy[${PYTHON_USEDEP}]
		')
	)
	spatialite? ( dev-db/spatialite )
	sqlite? ( dev-db/sqlite:3 )
	webp? ( media-libs/libwebp:= )
	xls? ( dev-libs/freexl )
	zstd? ( app-arch/zstd:= )
"
RDEPEND="
	${DEPEND}
	java? ( >=virtual/jre-1.8:* )
"

QA_CONFIG_IMPL_DECL_SKIP=(
	_wstat64 # Windows LFS
)

PATCHES=(
	"${FILESDIR}"/${PN}-3.6.4-abseil-cpp-20230125.2-c++17.patch
	"${FILESDIR}"/${PN}-3.7.0-zlib-OF.patch
)

pkg_setup() {
	if use python || use test ; then
		python-single-r1_pkg_setup
	fi

	use java && java-pkg-opt-2_pkg_setup
}

src_prepare() {
	cmake_src_prepare

	if use test ; then
		mv "${WORKDIR}"/gdalautotest-${PV} "${S}"/autotest || die
	fi
}

src_configure() {
	local mycmakeargs=(
		-DENABLE_IPO=OFF
		-DGDAL_USE_EXTERNAL_LIBS=ON
		-DGDAL_USE_INTERNAL_LIBS=OFF
		-DBUILD_TESTING=$(usex test)

		# bug #844874 and bug #845150
		-DCMAKE_INSTALL_INCLUDEDIR="include/gdal"

		# Options here are generally off because of one of:
		# - Not yet packaged dependencies
		#
		# - Off for autotools build and didn't want more churn by
		#   enabling during port to CMake. Feel free to request them
		#   being turned on if useful for you.
		-DGDAL_USE_ARMADILLO=$(usex armadillo)
		-DGDAL_USE_ARROW=OFF
		-DGDAL_USE_BLOSC=OFF
		-DGDAL_USE_BRUNSLI=OFF
		-DGDAL_USE_CRNLIB=OFF
		-DGDAL_USE_CFITSIO=$(usex fits)
		-DGDAL_USE_CURL=$(usex curl)
		-DGDAL_USE_CRYPTOPP=OFF
		-DGDAL_USE_DEFLATE=OFF
		-DGDAL_USE_ECW=OFF
		-DGDAL_USE_EXPAT=ON
		-DGDAL_USE_FILEGDB=OFF
		-DGDAL_USE_FREEXL=$(usex xls)
		-DGDAL_USE_FYBA=OFF
		-DGDAL_USE_GEOTIFF=ON
		-DGDAL_USE_GEOS=$(usex geos)
		-DGDAL_USE_GIF=$(usex gif)
		-DGDAL_USE_GTA=OFF
		-DGDAL_USE_HEIF=$(usex heif)
		-DGDAL_USE_HDF4=OFF
		-DGDAL_USE_HDF5=$(usex hdf5)
		-DGDAL_USE_HDFS=OFF
		-DGDAL_USE_ICONV=ON # TODO dep
		-DGDAL_USE_IDB=OFF
		-DGDAL_USE_JPEG=$(usex jpeg)

		# https://gdal.org/build_hints.html#jpeg12
		# Independent of whether using system libjpeg
		-DGDAL_USE_JPEG12_INTERNAL=ON

		-DGDAL_USE_JSONC=ON
		-DGDAL_USE_JXL=OFF
		-DGDAL_USE_KDU=OFF
		-DGDAL_USE_KEA=OFF
		-DGDAL_USE_LERC=OFF
		-DGDAL_USE_LIBKML=OFF
		-DGDAL_USE_LIBLZMA=$(usex lzma)
		-DGDAL_USE_LIBXML2=ON
		-DGDAL_USE_LURATECH=OFF
		-DGDAL_USE_LZ4=OFF
		-DGDAL_USE_MONGOCXX=OFF
		-DGDAL_USE_MRSID=OFF
		-DGDAL_USE_MSSQL_NCLI=OFF
		-DGDAL_USE_MSSQL_ODBC=OFF
		-DGDAL_USE_MYSQL=$(usex mysql)
		-DGDAL_USE_NETCDF=$(usex netcdf)
		-DGDAL_USE_ODBC=$(usex odbc)
		-DGDAL_USE_ODBCCPP=OFF
		-DGDAL_USE_OGDI=$(usex ogdi)
		-DGDAL_USE_OPENCAD=OFF
		-DGDAL_USE_OPENCL=$(usex opencl)
		-DGDAL_USE_OPENEXR=OFF
		-DGDAL_USE_OPENJPEG=$(usex jpeg2k)
		-DGDAL_USE_OPENSSL=ON
		-DGDAL_USE_ORACLE=$(usex oracle)
		-DGDAL_USE_PARQUET=OFF
		-DGDAL_USE_PCRE2=ON
		-DGDAL_USE_PDFIUM=OFF
		-DGDAL_USE_PNG=$(usex png)
		-DGDAL_USE_PODOFO=OFF
		-DGDAL_USE_POPPLER=$(usex pdf)
		-DGDAL_USE_POSTGRESQL=$(usex postgres)
		-DGDAL_USE_QHULL=OFF
		-DGDAL_USE_RASTERLITE2=OFF
		-DGDAL_USE_RDB=OFF
		-DGDAL_USE_SPATIALITE=$(usex spatialite)
		-DGDAL_USE_SQLITE3=$(usex sqlite)
		-DGDAL_USE_SFCGAL=OFF
		-DGDAL_USE_TEIGHA=OFF
		-DGDAL_USE_TIFF=ON
		-DGDAL_USE_TILEDB=OFF
		-DGDAL_USE_WEBP=$(usex webp)
		-DGDAL_USE_XERCESC=$(usex gml)
		-DGDAL_USE_ZLIB=ON
		-DGDAL_USE_ZSTD=$(usex zstd)

		# Bindings
		-DBUILD_PYTHON_BINDINGS=$(usex python)
		-DBUILD_JAVA_BINDINGS=$(usex java)
		# bug #845369
		-DBUILD_CSHARP_BINDINGS=OFF

		# Check work/gdal-3.5.0_build/CMakeCache.txt after configure
		# and https://github.com/OSGeo/gdal/blob/master/cmake/helpers/CheckCompilerMachineOption.cmake#L71
		# Commented out: not (yet?) implemented upstream.
		# Also, arm64 stuff is a TODO upstream, but not there (yet?)
		-Dtest_avx=$(usex cpu_flags_x86_avx)
		-Dtest_avx2=$(usex cpu_flags_x86_avx2)
		-Dtest_sse=$(usex cpu_flags_x86_sse)
		-Dtest_sse2=$(usex cpu_flags_x86_sse2)
		#-Dtest_sse3=$(usex cpu_flags_x86_sse3)
		-Dtest_sse4.1=$(usex cpu_flags_x86_sse4_1)
		#-Dtest_sse4.2=$(usex cpu_flags_x86_sse4_2)
		#-Dtest_sse4a=$(usex cpu_flags_x86_sse4a)
		-Dtest_ssse3=$(usex cpu_flags_x86_ssse3)
		#-Dtest_fma4=$(usex cpu_flags_x86_fma4)
		#-Dtest_xop=$(usex cpu_flags_x86_xop)
	)

	if use test ; then
		mycmakeargs+=( -DUSE_EXTERNAL_GTEST=ON )
	fi

	cmake_src_configure
}

src_compile() {
	cmake_src_compile

	use doc && cmake_src_compile doc
}

src_test() {
	export GDAL_RUN_SLOW_TESTS=0
	export GDAL_DOWNLOAD_TEST_DATA=0

	# Two test suites:
	# 1. autotests (much larger, uses pytest)
	# 2. Small set of fuzzing tests (no download needed)

	# Missing file for test-unit?
	cmake_src_test -E "(test-unit)"
}

src_install() {
	cmake_src_install
	use python && python_optimize

	if use java; then
		# Move the native library into the proper place for Gentoo.  The
		# library in ${D} has already had its RPATH fixed, so we use it
		# rather than ${BUILD_DIR}/swig/java/libgdalalljni.so.
		java-pkg_doso "${D}/usr/share/java/libgdalalljni.so"
		rm "${D}/usr/share/java/libgdalalljni.so" || die
	fi

	# TODO: install docs?
}

pkg_postinst() {
	elog "Check available image and data formats after building with"
	elog "gdalinfo and ogrinfo (using the --formats switch)."

	if use java; then
		elog
		elog "To use the Java bindings, you need to pass the following to java:"
		elog "    -Djava.library.path=$(java-config -i gdal)"
	fi
}