app-editors/kakoune: drop old 0_pre20160620
[gentoo.git] / sci-libs / fftw / fftw-9999.ebuild
1 # Copyright 1999-2016 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 if [[ ${PV} = *9999 ]]; then
14         inherit autotools git-r3
15         EGIT_REPO_URI="https://github.com/FFTW/fftw3.git"
16 else
17         SRC_URI="http://www.fftw.org/${P}.tar.gz"
18         KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
19 fi
20
21 LICENSE="GPL-2+"
22 SLOT="3.0/3"
23 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"
24
25 RDEPEND="
26         mpi? ( virtual/mpi )"
27 DEPEND="${RDEPEND}
28         test? ( dev-lang/perl )"
29
30 pkg_setup() {
31         if [[ ${MERGE_TYPE} != binary ]] && use openmp; then
32                 if ! tc-has-openmp; then
33                         ewarn "OpenMP is not available in your current selected compiler"
34
35                         if tc-is-clang; then
36                                 ewarn "OpenMP support in sys-devel/clang is provided by sys-libs/libomp,"
37                                 ewarn "which you will need to build ${CATEGORY}/${PN} with USE=\"openmp\""
38                         fi
39
40                         die "need openmp capable compiler"
41                 fi
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 && ! version_is_at_least 4.6 $(gcc-version); 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         # there is no abi_x86_32 port of virtual/mpi right now, bug 519700
72         local enable_mpi=$(multilib_native_use_enable mpi)
73
74         # jlec reported USE=quad on abi_x86_32 has too few registers
75         # stub Makefiles
76         if [[ ${MULTILIB_ABI_FLAG} == abi_x86_32 && ${MULTIBUILD_ID} == quad-* ]]; then
77                 mkdir -p "${BUILD_DIR}/tests" || die
78                 echo "all: ;" > "${BUILD_DIR}/Makefile" || die
79                 echo "install: ;" >> "${BUILD_DIR}/Makefile" || die
80                 echo "smallcheck: ;" > "${BUILD_DIR}/tests/Makefile" || die
81                 return 0
82         fi
83
84         local myconf=(
85                 --enable-shared
86                 $(use_enable static-libs static)
87                 $(use_enable "cpu_flags_x86_fma$(usex cpu_flags_x86_fma3 3 4)" fma)
88                 $(use_enable fortran)
89                 $(use_enable zbus mips-zbus-timer)
90                 $(use_enable threads)
91                 $(use_enable openmp)
92         )
93         case "${MULTIBUILD_ID}" in
94                 single-*)
95                         #altivec, sse, single-paired only work for single
96                         myconf+=(
97                                 --enable-single
98                                 $(use_enable altivec)
99                                 $(use_enable cpu_flags_x86_avx avx)
100                                 $(use_enable cpu_flags_x86_avx2 avx2)
101                                 $(use_enable cpu_flags_x86_sse sse)
102                                 $(use_enable cpu_flags_x86_sse2 sse2)
103                                 $(use_enable neon)
104                                 ${enable_mpi}
105                         )
106                         ;;
107
108                 double-*)
109                         myconf+=(
110                                 $(use_enable cpu_flags_x86_avx avx)
111                                 $(use_enable cpu_flags_x86_avx2 avx2)
112                                 $(use_enable cpu_flags_x86_sse2 sse2)
113                                 ${enable_mpi}
114                         )
115                         ;;
116
117                 longdouble-*)
118                         myconf+=(
119                                 --enable-long-double
120                                 ${enable_mpi}
121                         )
122                         ;;
123
124                 quad-*)
125                         #quad does not support mpi
126                         myconf+=(
127                                 --enable-quad-precision
128                         )
129                         ;;
130
131                 *)
132                         die "${MULTIBUILD_ID%-*} precision not implemented in this ebuild"
133                         ;;
134         esac
135
136         ECONF_SOURCE="${S}" econf "${myconf[@]}"
137 }
138
139 src_configure() {
140         multibuild_foreach_variant multilib-minimal_src_configure
141 }
142
143 src_compile() {
144         multibuild_foreach_variant multilib-minimal_src_compile
145 }
146
147 multilib_src_test() {
148         emake -C tests smallcheck
149 }
150
151 src_test() {
152         # We want this to be a reasonably quick test, but that is still hard...
153         ewarn "This test series will take 30 minutes on a modern 2.5Ghz machine"
154         # Do not increase the number of threads, it will not help your performance
155         # local testbase="perl check.pl --nthreads=1 --estimate"
156         #     ${testbase} -${p}d || die "Failure: $n"
157
158         multibuild_foreach_variant multilib-minimal_src_test
159 }
160
161 src_install() {
162         DOCS=( AUTHORS ChangeLog NEWS README TODO COPYRIGHT CONVENTIONS )
163         HTML_DOCS=( doc/html/ )
164
165         multibuild_foreach_variant multilib-minimal_src_install
166
167         if use doc; then
168                 dodoc doc/*.pdf
169                 docinto faq
170                 dodoc -r doc/FAQ/fftw-faq.html/.
171         else
172                 rm -r "${ED}"/usr/share/doc/${PF}/html || die
173         fi
174
175         local x
176         for x in "${ED}"/usr/lib*/pkgconfig/*.pc; do
177                 local u
178                 for u in $(usev mpi) $(usev threads) $(usex openmp omp ""); do
179                         sed -e "s|-lfftw3[flq]\?|&_${u} &|" "$x" > "${x%.pc}_${u}.pc" || die
180                 done
181         done
182
183         # fftw uses pkg-config to record its private dependencies
184         find "${ED}" -name '*.la' -delete || die
185 }