sci-astronomy/kstars: 3.1.0 version bump
[gentoo.git] / sci-astronomy / astrometry / astrometry-0.67-r2.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 )
7
8 inherit eutils toolchain-funcs python-single-r1
9
10 MYP=${PN}.net-${PV}
11
12 DESCRIPTION="Automated astrometric calibration programs and service"
13 HOMEPAGE="http://astrometry.net/"
14 SRC_URI="https://github.com/dstndstn/astrometry.net/releases/download/${PV}/${MYP}.tar.gz"
15
16 LICENSE="BSD GPL-2 GPL-3"
17 SLOT="0"
18 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
19 IUSE="examples"
20 REQUIRED_USE="${PYTHON_REQUIRED_USE}"
21
22 RDEPEND="
23         dev-python/astropy[${PYTHON_USEDEP}]
24         dev-python/numpy[${PYTHON_USEDEP}]
25         media-libs/libpng:0
26         media-libs/netpbm
27         sci-astronomy/wcslib:0=
28         sci-libs/cfitsio:0=
29         sci-libs/gsl:0=
30         sys-libs/zlib:0=
31         virtual/jpeg:0
32         x11-libs/cairo
33         ${PYTHON_DEPS}"
34 DEPEND="${RDEPEND}
35         dev-lang/swig:0
36         virtual/pkgconfig"
37
38 S="${WORKDIR}/${MYP}"
39
40 PATCHES=(
41         "${FILESDIR}"/${P}-soname.patch
42         "${FILESDIR}"/${P}-dynlink.patch
43         "${FILESDIR}"/${P}-qsortr.patch
44 )
45
46 src_prepare() {
47         default
48         # fix python scripts
49         python_fix_shebang "${S}"
50         sed -e "s|python setup-util.py|${EPYTHON} setup-util.py|" -i util/Makefile || die
51         sed -e "s|python setup.py|${EPYTHON} setup.py|" -i {libkd,sdss,blind}/Makefile || die
52         sed -e "s|python -c|${EPYTHON} -c|" -i blind/Makefile || die
53         sed -e "s|python <<EOF|${EPYTHON} <<EOF|" -i util/simplexy.c || die
54         sed -e "s|python -V|${EPYTHON} -V|" -i Makefile || die
55         # respect use compilation flags
56         sed -e '/-O3/d' -e '/-fomit-frame-pointer/d' -i util/makefile.common || die
57         # as-needed
58         sed -e "s|-lm|-lm $($(tc-getPKG_CONFIG) --libs wcslib gsl)|" -i util/Makefile || die
59         export SYSTEM_GSL=yes
60 }
61
62 src_compile() {
63         tc-export CC RANLIB AR
64         # fragile makefiles, build targets sequentially
65         emake
66         emake py
67         emake extra
68         emake report.txt
69 }
70
71 src_test() {
72         emake test
73         local d
74         for d in util blind libkd; do
75                 pushd ${d} > /dev/null
76                 ./test || die "failed tests in ${d}"
77                 popd ${d} > /dev/null
78         done
79 }
80
81 ap_make() {
82         emake \
83                 INSTALL_DIR="${ED%/}/usr" \
84                 DATA_INSTALL_DIR="${ED%/}/usr/share/astrometry" \
85                 LIB_INSTALL_DIR="${ED%/}/usr/$(get_libdir)" \
86                 ETC_INSTALL_DIR="${ED%/}/etc" \
87                 MAN1_INSTALL_DIR="${ED%/}/usr/share/man/man1" \
88                 DOC_INSTALL_DIR="${ED%/}/usr/share/doc/${PF}" \
89                 EXAMPLE_INSTALL_DIR="${ED%/}/usr/share/doc/${PF}/examples" \
90                 PY_BASE_INSTALL_DIR="${ED%/}$(python_get_sitedir)/astrometry" \
91                 PY_BASE_LINK_DIR="../$(python_get_sitedir | sed -e 's|/usr/||')/astrometry" \
92                 FINAL_DIR="${EPREFIX%/}/usr" \
93                 DATA_FINAL_DIR="${EPREFIX%/}/usr/share/astrometry" \
94                 $@
95 }
96
97 src_install() {
98         ap_make install-core
99         ap_make -C util install
100         ap_make -C blind install-extra
101
102         # remove duplicates and non installable libraries
103         rm "${ED}"/usr/bin/{fitscopy,imcopy,listhead} || die
104         rm "${ED}"/usr/$(get_libdir)/lib*.a || die
105         rm "${ED}"/usr/share/doc/${PF}/LICENSE || die
106
107         use examples || rm -r "${ED}"/usr/share/doc/${PF}/examples
108 }