076c2cdc55f9a8f160697f0991d64ea655085d8b
[gentoo.git] / sci-mathematics / pari / pari-2.11.4.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit flag-o-matic toolchain-funcs
7
8 DESCRIPTION="Computer-aided number theory C library and tools"
9 HOMEPAGE="https://pari.math.u-bordeaux.fr/"
10 SRC_URI="https://pari.math.u-bordeaux.fr/pub/${PN}/unix/${P}.tar.gz"
11
12 LICENSE="GPL-2"
13 SLOT="0/6"
14 KEYWORDS="~alpha ~amd64 ~hppa ~mips ~ppc ~ppc64 ~sparc ~x86 ~amd64-linux ~x86-linux ~x86-macos ~x86-solaris"
15 IUSE="data doc fltk gmp test threads X"
16 RESTRICT="!test? ( test )"
17
18 BDEPEND="doc? ( virtual/latex-base )"
19 DEPEND="
20         sys-libs/readline:0=
21         data? ( sci-mathematics/pari-data )
22         doc? ( X? ( x11-misc/xdg-utils ) )
23         fltk? ( x11-libs/fltk:1= )
24         gmp? ( dev-libs/gmp:0= )
25         X? ( x11-libs/libX11:0= )"
26 RDEPEND="${DEPEND}"
27
28 PATCHES=(
29         "${FILESDIR}/${PN}"-2.9.4-strip.patch
30         "${FILESDIR}/${PN}"-2.9.4-ppc.patch
31         "${FILESDIR}/${PN}"-2.11.2-no-automagic.patch
32         "${FILESDIR}/${PN}"-2.9.4-fltk-detection.patch
33         "${FILESDIR}/${PN}"-2.11.2-Makefile-LDFLAGS.patch
34         "${FILESDIR}/${PN}"-2.11.2-Makefile-docinstall.patch
35 )
36
37 src_prepare() {
38         default
39
40         # move doc dir to a gentoo doc dir and replace acroread by xdg-open
41         sed -i \
42                 -e "s:\$d = \$0:\$d = '${EPREFIX}/usr/share/doc/${PF}':" \
43                 -e 's:"acroread":"xdg-open":' \
44                 doc/gphelp.in || die "Failed to fix doc dir"
45 }
46
47 src_configure() {
48         tc-export CC CXX
49
50         # Workaraound to "asm operand has impossible constraints" as
51         # suggested in bug #499996.
52         use x86 && append-cflags $(test-flags-CC -fno-stack-check)
53
54         # need to force optimization here, as it breaks without
55         if is-flag -O0; then
56                 replace-flags -O0 -O2
57         elif ! is-flag -O?; then
58                 append-flags -O2
59         fi
60
61         # sysdatadir installs a pari.cfg stuff which is informative only.
62         # It is supposed to be for "architecture-dependent" data.
63         # It needs to be easily discoverable for downstream packages such as gp2c.
64         ./Configure \
65                 --prefix="${EPREFIX}"/usr \
66                 --datadir="${EPREFIX}/usr/share/${PN}" \
67                 --libdir="${EPREFIX}/usr/$(get_libdir)" \
68                 --sysdatadir="${EPREFIX}"/usr/share/pari \
69                 --mandir="${EPREFIX}"/usr/share/man/man1 \
70                 --with-readline="${EPREFIX}"/usr \
71                 --with-readline-lib="${EPREFIX}/usr/$(get_libdir)" \
72                 --with-ncurses-lib="${EPREFIX}/usr/$(get_libdir)" \
73                 $(use_with fltk) \
74                 $(use_with gmp) \
75                 --without-qt \
76                 $(usex threads "--mt=pthread" "" "" "") \
77                 || die "./Configure failed"
78 }
79
80 src_compile() {
81         local mymake=""
82         use hppa && \
83                 mymake=DLLD\="${EPREFIX}"/usr/bin/gcc\ DLLDFLAGS\=-shared\ -Wl,-soname=\$\(LIBPARI_SONAME\)\ -lm
84
85         emake ${mymake} gp
86
87         if use doc; then
88                 # To prevent sandbox violations by metafont
89                 VARTEXFONTS="${T}/fonts" emake docpdf
90         fi
91 }
92
93 src_test() {
94         # Welcome to the jungle, where the tests fail if you make your
95         # terminal bigger.
96         emake COLUMNS=80 test-all
97 }
98
99 src_install() {
100         default
101
102         if use doc; then
103                 docompress -x "/usr/share/doc/${PF}"
104                 emake \
105                         DESTDIR="${D}" \
106                         EXDIR="${ED}/usr/share/doc/${PF}/examples" \
107                         DOCDIR="${ED}/usr/share/doc/${PF}" \
108                         install-doc
109         fi
110 }