aboutsummaryrefslogtreecommitdiff
blob: 64a438f4674f20bdafbe1a043282a84d4969bb4e (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
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI="7"

PYTHON_COMPAT=( python3_{6,7,8} )

inherit cmake distutils-r1

MY_PN="GeographicLib"
MY_PV=$(ver_rs 2 -)
MY_P="${MY_PN}-${MY_PV}"

DESCRIPTION="C++ library for converting geographic coordinate systems"
HOMEPAGE="https://sourceforge.net/projects/geographiclib/"

SLOT="0"
KEYWORDS="~amd64"
IUSE_GEOIDS_DATASET="
	geoids_dataset_egm84-30
	geoids_dataset_egm84-15
	geoids_dataset_egm96-15
	geoids_dataset_egm96-5
	geoids_dataset_egm2008-5
	geoids_dataset_egm2008-2-5
	geoids_dataset_egm2008-1
"
IUSE_GRAVITY_MODEL="
	gravity_model_egm84
	gravity_model_egm96
	gravity_model_egm2008
	gravity_model_wgs84
"
IUSE_MAGNETIC_MODEL="
	magnetic_model_wmm2010
	magnetic_model_wmm2015v2
	magnetic_model_wmm2020
	magnetic_model_igrf11
	magnetic_model_igrf12
	magnetic_model_emm2010
	magnetic_model_emm2015
	magnetic_model_emm2017
"
IUSE_PRECISION="
	precision_arbitrary
	+precision_double
	precision_long-double
	precision_quad
	precision_single
"
IUSE="${IUSE_GEOIDS_DATASET} ${IUSE_GRAVITY_MODEL} ${IUSE_MAGNETIC_MODEL} ${IUSE_PRECISION} boost doc examples geoids gravity magnetic python"
IUSE_EXPAND="GEOIDS_DATASET GRAVITY_MODEL MAGNETIC_MODEL PRECISION"

#reverse required use needed, e.g. !geoids? ( !geoids_dataset_egm2008-1 ) and so on, use bash magic to generate them
REQUIRED_USE="
	^^ ( ${IUSE_PRECISION/+/} )
	geoids? ( || ( ${IUSE_GEOIDS_DATASET/+/} ) )
	gravity? ( || ( ${IUSE_GRAVITY_MODEL/+/} ) )
	magnetic? ( || ( ${IUSE_MAGNETIC_MODEL/+/} ) )
	python? ( ${PYTHON_REQUIRED_USE} )
"

COMMON_URI="https://sourceforge.net/projects/${PN}/files"
SRC_URI="
${COMMON_URI}/distrib/${MY_P}.tar.gz/download -> ${P}.tar.gz

geoids_dataset_egm84-30?         ( ${COMMON_URI}/geoids-distrib/egm84-30.tar.bz2	-> geoids-egm84-30.tar.bz2	)
geoids_dataset_egm84-15?         ( ${COMMON_URI}/geoids-distrib/egm84-15.tar.bz2	-> geoids-egm84-15.tar.bz2	)
geoids_dataset_egm96-15?         ( ${COMMON_URI}/geoids-distrib/egm96-15.tar.bz2	-> geoids-egm96-15.tar.bz2	)
geoids_dataset_egm96-5?          ( ${COMMON_URI}/geoids-distrib/egm96-5.tar.bz2		-> geoids-egm96-5.tar.bz2	)
geoids_dataset_egm2008-5?        ( ${COMMON_URI}/geoids-distrib/egm2008-5.tar.bz2	-> geoids-egm2008-5.tar.bz2	)
geoids_dataset_egm2008-2-5?      ( ${COMMON_URI}/geoids-distrib/egm2008-2_5.tar.bz2	-> geoids-egm2008-2_5.tar.bz2	)
geoids_dataset_egm2008-1?        ( ${COMMON_URI}/geoids-distrib/egm2008-1.tar.bz2	-> geoids-egm2008-1.tar.bz2	)

gravity_model_egm84?            ( ${COMMON_URI}/gravity-distrib/egm84.tar.bz2		-> gravity-egm84.tar.bz2	)
gravity_model_egm96?            ( ${COMMON_URI}/gravity-distrib/egm96.tar.bz2		-> gravity-egm96.tar.bz2	)
gravity_model_egm2008?          ( ${COMMON_URI}/gravity-distrib/egm2008.tar.bz2		-> gravity-egm2008.tar.bz2	)
gravity_model_wgs84?            ( ${COMMON_URI}/gravity-distrib/wgs84.tar.bz2		-> gravity-wgs84.tar.bz2	)

magnetic_model_wmm2010?         ( ${COMMON_URI}/magnetic-distrib/wmm2010.tar.bz2	-> magnetic-wmm2010.tar.bz2	)
magnetic_model_wmm2015v2?       ( ${COMMON_URI}/magnetic-distrib/wmm2015v2.tar.bz2	-> magnetic-wmm2015v2.tar.bz2	)
magnetic_model_wmm2020?         ( ${COMMON_URI}/magnetic-distrib/wmm2020.tar.bz2	-> magnetic-wmm2020.tar.bz2	)
magnetic_model_igrf11?          ( ${COMMON_URI}/magnetic-distrib/igrf11.tar.bz2		-> magnetic-igrf11.tar.bz2	)
magnetic_model_igrf12?          ( ${COMMON_URI}/magnetic-distrib/igrf12.tar.bz2		-> magnetic-igrf12.tar.bz2	)
magnetic_model_emm2010?         ( ${COMMON_URI}/magnetic-distrib/emm2010.tar.bz2	-> magnetic-emm2010.tar.bz2	)
magnetic_model_emm2015?         ( ${COMMON_URI}/magnetic-distrib/emm2015.tar.bz2	-> magnetic-emm2015.tar.bz2	)
magnetic_model_emm2017?         ( ${COMMON_URI}/magnetic-distrib/emm2017.tar.bz2	-> magnetic-emm2017.tar.bz2	)
"
#TODO: find out the licenses of the geoid and gravity datasets
LICENSE="
	MIT
	geoids? ( public-domain )
	gravity? ( public-domain )
	magnetic? ( public-domain )
"

RDEPEND="
	>=dev-libs/boost-1.65.0
"
DEPEND="
	${RDEPEND}
	doc? (
		>=app-doc/doxygen-1.8.7
		>=dev-python/sphinx-1.6.3-r2
		>=dev-lang/perl-5.26.1-r1
		>=sys-apps/util-linux-2.31
	)
"

S="${WORKDIR}/${MY_P}"

distutils_enable_tests setup.py
# there are additional docs in the python dir
distutils_enable_sphinx python/doc

src_prepare() {
	#TODO: strip cflags
#	sed -i "s|CXXFLAGS = -g -Wall -Wextra -O3 -std=c++0x||" tools/Makefile.mk || die
#	sed -i "s|CXXFLAGS = -g -Wall -Wextra -O3 -std=c++0x||" src/Makefile.mk || die

	cmake_src_prepare

	if use python; then
		cd "python" || die
		distutils-r1_python_prepare_all
		cd ".." || die
	fi
}

src_configure() {
	local precision
	use precision_arbitrary		&& precision="5"
	use precision_double		&& precision="2"
	use precision_long-double	&& precision="3"
	use precision_quad		&& precision="4"
	use precision_single		&& precision="1"

	export GEODATAPATH="/usr/share/${P}"

	local mycmakeargs=(
		-DGEOGRAPHICLIB_DOCUMENTATION=$(usex doc ON OFF)
		-DGEOGRAPHICLIB_LIB_TYPE="SHARED"
		-DUSE_BOOST_FOR_EXAMPLES=$(usex boost ON OFF)
		-DGEOGRAPHICLIB_PRECISION="${precision}"
		-DGEOGRAPHICLIB_DATA="${GEODATAPATH}"
	)
	cmake_src_configure
}

src_compile() {
	cmake_src_compile

	if use python; then
		cd "python" || die
		python_foreach_impl distutils-r1_python_compile
		cd ".." || die
		use doc && build_sphinx python/doc
	fi
}

src_test() {
	# Only 1 failing test in the C code, python passes for me
	cmake_src_test

	if use python; then
		cd "python" || die
		python_foreach_impl python_test
		cd ".." || die
	fi
}

src_install() {
	insinto "${GEODATAPATH}/geoids"
	use geoids && doins -r "${WORKDIR}"/geoids/.
	insinto "${GEODATAPATH}/gravity"
	use gravity && doins -r "${WORKDIR}"/gravity/.
	insinto "${GEODATAPATH}/magnetic"
	use magnetic && doins -r "${WORKDIR}"/magnetic/.

	cmake_src_install

	# remove python things added by the cmake_src_install function
	# these are installed in the wrong python dir
	rm -rf "${D}/usr/$(get_libdir)/python" || die
	# if use python we re-add these python files correctly
	if use python; then
		cd "python" || die
		python_foreach_impl distutils-r1_python_install
		cd ".."
	fi

	#TODO: find out if java stuff need something

	# Installs to wrong doc dir for some reason
	# Also happens with USE="-doc"
	mv "${D}/usr/share/doc/${MY_PN}" "${D}/usr/share/doc/${P}" || die
}