summaryrefslogtreecommitdiff
blob: d3149dc959a54bc52c6b9a26cdd71dabf8d5592c (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
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=6

PYTHON_COMPAT=( python2_7 )

inherit eutils toolchain-funcs python-single-r1

MYP=${PN}.net-${PV}

DESCRIPTION="Automated astrometric calibration programs and service"
HOMEPAGE="http://astrometry.net/"
SRC_URI="https://github.com/dstndstn/astrometry.net/releases/download/${PV}/${MYP}.tar.gz"

LICENSE="BSD GPL-2 GPL-3"
SLOT="0"
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
IUSE="examples"

RDEPEND="
	dev-python/astropy[${PYTHON_USEDEP}]
	dev-python/numpy[${PYTHON_USEDEP}]
	media-libs/libpng:0
	media-libs/netpbm
	sci-astronomy/wcslib:0=
	sci-libs/cfitsio:0=
	sci-libs/gsl:0=
	sys-libs/zlib:0=
	virtual/jpeg:0
	x11-libs/cairo"
DEPEND="${RDEPEND}
	dev-lang/swig:0
	virtual/pkgconfig"

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

PATCHES=(
	"${FILESDIR}"/${P}-soname.patch
	"${FILESDIR}"/${P}-dynlink.patch
	"${FILESDIR}"/${P}-qsortr.patch
)

src_prepare() {
	default
	# fix python scripts
	python_fix_shebang "${S}"
	sed -e "s|python setup-util.py|${EPYTHON} setup-util.py|" -i util/Makefile || die
	sed -e "s|python setup.py|${EPYTHON} setup.py|" -i {libkd,sdss,blind}/Makefile || die
	sed -e "s|python -c|${EPYTHON} -c|" -i blind/Makefile || die
	sed -e "s|python <<EOF|${EPYTHON} <<EOF|" -i util/simplexy.c || die
	sed -e "s|python -V|${EPYTHON} -V|" -i Makefile || die
	# respect use compilation flags
	sed -e '/-O3/d' -e '/-fomit-frame-pointer/d' -i util/makefile.common || die
	# as-needed
	sed -e "s|-lm|-lm $($(tc-getPKG_CONFIG) --libs wcslib gsl)|" -i util/Makefile || die
	export SYSTEM_GSL=yes
}

src_compile() {
	tc-export CC RANLIB AR
	# fragile makefiles, build targets sequentially
	emake
	emake py
	emake extra
	emake report.txt
}

src_test() {
	emake test
	local d
	for d in util blind libkd; do
		pushd ${d} > /dev/null
		./test || die "failed tests in ${d}"
		popd ${d} > /dev/null
	done
}

ap_make() {
	emake \
		INSTALL_DIR="${ED%/}/usr" \
		DATA_INSTALL_DIR="${ED%/}/usr/share/astrometry" \
		LIB_INSTALL_DIR="${ED%/}/usr/$(get_libdir)" \
		ETC_INSTALL_DIR="${ED%/}/etc" \
		MAN1_INSTALL_DIR="${ED%/}/usr/share/man/man1" \
		DOC_INSTALL_DIR="${ED%/}/usr/share/doc/${PF}" \
		EXAMPLE_INSTALL_DIR="${ED%/}/usr/share/doc/${PF}/examples" \
		PY_BASE_INSTALL_DIR="${ED%/}$(python_get_sitedir)/astrometry" \
		PY_BASE_LINK_DIR="../$(python_get_sitedir | sed -e 's|/usr/||')/astrometry" \
		FINAL_DIR="${EPREFIX%/}/usr" \
		DATA_FINAL_DIR="${EPREFIX%/}/usr/share/astrometry" \
		$@
}

src_install() {
	ap_make install-core
	ap_make -C util install
	ap_make -C blind install-extra

	# remove duplicates and non installable libraries
	rm "${ED}"/usr/bin/{fitscopy,imcopy,listhead} || die
	rm "${ED}"/usr/$(get_libdir)/lib*.a || die
	rm "${ED}"/usr/share/doc/${PF}/LICENSE || die

	use examples || rm -r "${ED}"/usr/share/doc/${PF}/examples
}