*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / sci-astronomy / casacore / casacore-2.3.0-r1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 python3_6 )
7
8 inherit cmake-utils eutils toolchain-funcs fortran-2 python-r1
9
10 DESCRIPTION="Core libraries for the Common Astronomy Software Applications"
11 HOMEPAGE="https://github.com/casacore/casacore"
12 SRC_URI="https://github.com/${PN}/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
13
14 LICENSE="GPL-2"
15 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
16 SLOT="0"
17 IUSE="+c++11 +data doc fftw hdf5 openmp python threads test"
18 RESTRICT="!test? ( test )"
19 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
20
21 RDEPEND="
22         sci-astronomy/wcslib:0=
23         sci-libs/cfitsio:0=
24         sys-libs/readline:0=
25         virtual/blas:=
26         virtual/lapack:=
27         data? ( sci-astronomy/casa-data )
28         fftw? ( sci-libs/fftw:3.0= )
29         hdf5? ( sci-libs/hdf5:0= )
30         python? (
31                 ${PYTHON_DEPS}
32                 dev-libs/boost:0=[python,${PYTHON_USEDEP}]
33                 dev-python/numpy[${PYTHON_USEDEP}]
34         )
35 "
36 DEPEND="${RDEPEND}
37         virtual/pkgconfig
38         doc? ( app-doc/doxygen )
39         test? ( sci-astronomy/casa-data )
40 "
41
42 PATCHES=(
43         "${FILESDIR}"/${PN}-2.3.0-disable-class-and-collaboration-graph-generation.patch
44         "${FILESDIR}"/${PN}-2.3.0-disable-known-test-failures.patch
45         "${FILESDIR}"/${PN}-2.3.0-disable-tests-that-require-data-tables.patch
46         "${FILESDIR}"/${PN}-2.3.0-do-not-install-test-and-demonstration-executables.patch
47         "${FILESDIR}"/${PN}-2.3.0-fix-FTBFS-tStatisticsUtilities-tLatticeStatistics-and-tLC.patch
48         "${FILESDIR}"/${PN}-2.3.0-fix-too-small-int-type-for-memory-on-32-bit-machines.patch
49         "${FILESDIR}"/${PN}-2.3.0-loose-some-tests-tFFTServer-tests.patch
50         "${FILESDIR}"/${PN}-2.3.0-make-the-check-for-NFS-a-bit-more-portable-BSD.patch
51         "${FILESDIR}"/${PN}-2.3.0-use-the-correct-symbol-to-detect-Linux-OS.patch
52 )
53
54 pkg_pretend() {
55         if [[ $(tc-getCC)$ == *gcc* ]] && [[ ${MERGE_TYPE} != binary ]]; then
56                 use c++11 && [[ $(gcc-major-version) -lt 4 ]] || \
57                         ( [[ $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt 7 ]] ) && \
58                                 die "You are using gcc but gcc-4.7 or higher is required for C++11"
59         fi
60         use openmp && tc-check-openmp
61 }
62
63 src_prepare() {
64         cmake-utils_src_prepare
65         sed -e '/python-py/s/^.*$/find_package(Boost REQUIRED COMPONENTS python)/' \
66                 -i python3/CMakeLists.txt || die
67 }
68
69 src_configure() {
70         has_version sci-libs/hdf5[mpi] && export CXX=mpicxx
71         local mycmakeargs=(
72                 -DENABLE_SHARED=ON
73                 -DBUILD_PYTHON=OFF
74                 -DDATA_DIR="${EPREFIX}/usr/share/casa/data"
75                 -DBUILD_TESTING="$(usex test)"
76                 -DCXX11="$(usex c++11)"
77                 -DUSE_FFTW3="$(usex fftw)"
78                 -DUSE_HDF5="$(usex hdf5)"
79                 -DUSE_OPENMP="$(usex openmp)"
80                 -DUSE_THREADS="$(usex threads)"
81         )
82         python_set_options() {
83                 if python_is_python3; then
84                         mycmakeargs+=(
85                                 -DPYTHON3_EXECUTABLE="${PYTHON}"
86                                 -DBUILD_PYTHON3=ON
87                         )
88                 else
89                         mycmakeargs+=(
90                                 -DPYTHON2_EXECUTABLE="${PYTHON}"
91                                 -DBUILD_PYTHON=ON
92                         )
93                 fi
94         }
95         use python && python_foreach_impl python_set_options
96         cmake-utils_src_configure
97 }
98
99 src_compile() {
100         cmake-utils_src_compile
101         if use doc; then
102                 doxygen doxygen.cfg || die
103         fi
104 }
105
106 src_install(){
107         cmake-utils_src_install
108         if use doc; then
109                 insinto /usr/share/doc/${PF}
110                 doins -r doc/html
111                 docompress -x /usr/share/doc/${PF}/html
112         fi
113 }