app-editors/kakoune: drop old 0_pre20160620
[gentoo.git] / sci-libs / fftw / fftw-3.3.6_p2.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 FORTRAN_NEEDED=fortran
7
8 inherit flag-o-matic fortran-2 toolchain-funcs versionator multibuild multilib-minimal
9
10 DESCRIPTION="Fast C library for the Discrete Fourier Transform"
11 HOMEPAGE="http://www.fftw.org/"
12
13 MY_P=${PN}-${PV/_p/-pl}
14
15 if [[ ${PV} = *9999 ]]; then
16         inherit autotools git-r3
17         EGIT_REPO_URI="https://github.com/FFTW/fftw3.git"
18 else
19         SRC_URI="http://www.fftw.org/${PN}-${PV/_p/-pl}.tar.gz"
20         KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~mips ppc ppc64 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
21 fi
22
23 LICENSE="GPL-2+"
24 SLOT="3.0/3"
25 IUSE="altivec cpu_flags_x86_avx cpu_flags_x86_avx2 cpu_flags_x86_fma3 cpu_flags_x86_fma4 cpu_flags_x86_sse cpu_flags_x86_sse2 doc fortran mpi neon openmp quad static-libs test threads zbus"
26
27 RDEPEND="
28         mpi? ( >=virtual/mpi-2.0-r4[${MULTILIB_USEDEP}] )"
29 DEPEND="${RDEPEND}
30         test? ( dev-lang/perl )"
31
32 S=${WORKDIR}/${MY_P}
33 HTML_DOCS=( doc/html/. )
34
35 pkg_pretend() {
36         [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
37 }
38
39 pkg_setup() {
40         if [[ ${MERGE_TYPE} != binary ]] && use openmp; then
41                 tc-check-openmp
42                 FORTRAN_NEED_OPENMP=1
43         fi
44
45         fortran-2_pkg_setup
46
47         MULTIBUILD_VARIANTS=( single double longdouble )
48         if use quad; then
49                 if ! tc-is-gcc; then
50                         ewarn "quad precision only available for gcc >= 4.6"
51                         die "need quad precision capable gcc"
52                 fi
53                 MULTIBUILD_VARIANTS+=( quad )
54         fi
55 }
56
57 src_prepare() {
58         default
59
60         # fix info file for category directory
61         if [[ ${PV} = *9999 ]]; then
62                 sed -i -e
63                         's/Texinfo documentation system/Libraries/' \
64                         doc/fftw3."info" || die "failed to fix info file"
65
66                 eautoreconf
67         fi
68 }
69
70 multilib_src_configure() {
71         # jlec reported USE=quad on abi_x86_32 has too few registers
72         # stub Makefiles
73         if [[ ${MULTILIB_ABI_FLAG} == abi_x86_32 && ${MULTIBUILD_ID} == quad-* ]]; then
74                 mkdir -p "${BUILD_DIR}/tests" || die
75                 echo "all: ;" > "${BUILD_DIR}/Makefile" || die
76                 echo "install: ;" >> "${BUILD_DIR}/Makefile" || die
77                 echo "smallcheck: ;" > "${BUILD_DIR}/tests/Makefile" || die
78                 return 0
79         fi
80
81         local myconf=(
82                 --enable-shared
83                 $(use_enable static-libs static)
84                 $(use_enable "cpu_flags_x86_fma$(usex cpu_flags_x86_fma3 3 4)" fma)
85                 $(use_enable fortran)
86                 $(use_enable zbus mips-zbus-timer)
87                 $(use_enable threads)
88                 $(use_enable openmp)
89         )
90         case "${MULTIBUILD_ID}" in
91                 single-*)
92                         # altivec, sse, single-paired only work for single
93                         myconf+=(
94                                 --enable-single
95                                 $(use_enable altivec)
96                                 $(use_enable cpu_flags_x86_avx avx)
97                                 $(use_enable cpu_flags_x86_avx2 avx2)
98                                 $(use_enable cpu_flags_x86_sse sse)
99                                 $(use_enable cpu_flags_x86_sse2 sse2)
100                                 $(use_enable neon)
101                                 $(use_enable mpi)
102                         )
103                         ;;
104
105                 double-*)
106                         myconf+=(
107                                 $(use_enable cpu_flags_x86_avx avx)
108                                 $(use_enable cpu_flags_x86_avx2 avx2)
109                                 $(use_enable cpu_flags_x86_sse2 sse2)
110                                 $(use_enable mpi)
111                         )
112                         ;;
113
114                 longdouble-*)
115                         myconf+=(
116                                 --enable-long-double
117                                 $(use_enable mpi)
118                         )
119                         ;;
120
121                 quad-*)
122                         # quad does not support mpi
123                         myconf+=(
124                                 --enable-quad-precision
125                         )
126                         ;;
127
128                 *)
129                         die "${MULTIBUILD_ID%-*} precision not implemented in this ebuild"
130                         ;;
131         esac
132
133         ECONF_SOURCE="${S}" econf "${myconf[@]}" MPICC="$(tc-getCC -lmpi)"
134 }
135
136 src_configure() {
137         multibuild_foreach_variant multilib-minimal_src_configure
138 }
139
140 src_compile() {
141         multibuild_foreach_variant multilib-minimal_src_compile
142 }
143
144 multilib_src_test() {
145         emake -C tests smallcheck
146 }
147
148 src_test() {
149         # We want this to be a reasonably quick test, but that is still hard...
150         ewarn "This test series will take 30 minutes on a modern 2.5Ghz machine"
151         # Do not increase the number of threads, it will not help your performance
152         # local testbase="perl check.pl --nthreads=1 --estimate"
153         #     ${testbase} -${p}d || die "Failure: $n"
154
155         multibuild_foreach_variant multilib-minimal_src_test
156 }
157
158 src_install() {
159         multibuild_foreach_variant multilib-minimal_src_install
160         dodoc CONVENTIONS
161
162         if use doc; then
163                 dodoc doc/*.pdf
164                 docinto faq
165                 dodoc -r doc/FAQ/fftw-faq.html/.
166         else
167                 rm -r "${ED%/}"/usr/share/doc/${PF}/html || die
168         fi
169
170         local x
171         for x in "${ED%/}"/usr/lib*/pkgconfig/*.pc; do
172                 local u
173                 for u in $(usev mpi) $(usev threads) $(usex openmp omp ""); do
174                         sed -e "s|-lfftw3[flq]\?|&_${u} &|" "$x" > "${x%.pc}_${u}.pc" || die
175                 done
176         done
177
178         # fftw uses pkg-config to record its private dependencies
179         find "${D}" -name '*.la' -delete || die
180 }