dev-util/rebar: version bump to 2.5.1
[gentoo.git] / sci-mathematics / axiom / axiom-200805.ebuild
1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=4
6
7 inherit eutils multilib flag-o-matic
8
9 DESCRIPTION="Axiom is a general purpose Computer Algebra system"
10 HOMEPAGE="http://axiom.axiom-developer.org/"
11 SRC_URI="http://www.axiom-developer.org/axiom-website/downloads/${PN}-may2008-src.tgz"
12
13 LICENSE="BSD-2"
14 SLOT="0"
15 KEYWORDS="~amd64 ~x86"
16 IUSE=""
17
18 # NOTE: Do not strip since this seems to remove some crucial
19 # runtime paths as well, thereby, breaking axiom
20 RESTRICT="strip"
21
22 DEPEND="virtual/latex-base
23         x11-libs/libXaw
24         sys-apps/debianutils
25         sys-process/procps"
26 RDEPEND=""
27
28 S="${WORKDIR}"/${PN}
29
30 pkg_setup() {
31         # for 2.6.25 kernels and higher we need to have
32         # /proc/sys/kernel/randomize_va_space set to somthing other
33         # than 2, otherwise gcl fails to compile (see bug #186926).
34         local current_setting=$(/sbin/sysctl kernel.randomize_va_space 2>/dev/null | cut -d' ' -f3)
35         if [[ ${current_setting} == 2 ]]; then
36                 echo
37                 eerror "Your kernel has brk randomization enabled. This will"
38                 eerror "cause axiom to fail to compile *and* run (see bug #186926)."
39                 eerror "You can issue:"
40                 eerror
41                 eerror "   /sbin/sysctl -w kernel.randomize_va_space=1"
42                 eerror
43                 eerror "as root to turn brk randomization off temporarily."
44                 eerror "However, when not using axiom you may want to turn"
45                 eerror "brk randomization back on via"
46                 eerror
47                 eerror "   /sbin/sysctl -w kernel.randomize_va_space=2"
48                 eerror
49                 eerror "since it results in a less secure kernel."
50                 die "Kernel brk randomization detected"
51         fi
52 }
53
54 src_prepare() {
55         cp "${FILESDIR}"/noweb-2.9-insecure-tmp-file.patch.input \
56                 "${S}"/zips/noweb-2.9-insecure-tmp-file.patch \
57                 || die "Failed to fix noweb"
58         cp "${FILESDIR}"/${PN}-200711-gcl-configure.patch \
59                 "${S}"/zips/gcl-2.6.7.configure.in.patch \
60                 || die "Failed to fix gcl-2.6.7 configure"
61         epatch "${FILESDIR}"/noweb-2.9-insecure-tmp-file.Makefile.patch
62
63         # lots of strict-aliasing badness
64         append-flags -fno-strict-aliasing
65 }
66
67 src_compile() {
68         # use gcl 2.6.7
69         sed -e "s:GCLVERSION=gcl-2.6.8pre$:GCLVERSION=gcl-2.6.7:" \
70                 -i Makefile.pamphlet Makefile \
71                 || die "Failed to select proper gcl"
72
73         # fix libXpm.a location
74         sed -e "s:X11R6/lib:$(get_libdir):g" -i Makefile.pamphlet \
75                 || die "Failed to fix libXpm lib paths"
76
77         # Let the fun begin...
78         AXIOM="${S}"/mnt/linux emake -j1
79 }
80
81 src_install() {
82         emake DESTDIR="${D}"/opt/axiom COMMAND="${D}"/opt/axiom/mnt/linux/bin/axiom install
83
84         mv "${D}"/opt/axiom/mnt/linux/* "${D}"/opt/axiom \
85                 || die "Failed to mv axiom into its final destination path."
86         rm -fr "${D}"/opt/axiom/mnt \
87                 || die "Failed to remove old directory."
88
89         dodir /usr/bin
90         dosym /opt/axiom/bin/axiom /usr/bin/axiom
91
92         sed -e "2d;3i AXIOM=/opt/axiom" \
93                 -i "${D}"/opt/axiom/bin/axiom \
94                 || die "Failed to patch axiom runscript!"
95
96         dodoc changelog readme faq
97 }