maxima: add a subpkg maxima-ecl needed for sagemath

- Added a build option 'ecl' (enabled by default)
 - The ecl binary and library will be in a subpkg maxima-ecl so this
   should not affect current users of maxima
 - new patches:
   - a0d7a43...: build a FASL library for ECL (this is merged upstream)
   - handle-multiple-ldflags.patch: otherwise compilation with multiple
     options in LDFLAGS fails (taken from debian)
   - matrixexp.patch: fixes an error in matrix exponentiation (taken
     from debian, this originates in sagemath)

A weak point is that the library maxima.fas is installed in
/usr/lib/ecl-${ecl_version} which is where ecl looks for them, but this
doesn't seem right.

Maybe an alternative would be to have the ecl package ship a symlink at
/usr/lib/ecl pointing to the versioned directory, then have the
maxima-ecl package place its library in the non-versioned directory.
This commit is contained in:
Gonzalo Tornaría 2021-11-27 19:38:48 -03:00 committed by Leah Neukirchen
parent 36248670a9
commit ab0d3102b5
5 changed files with 120 additions and 5 deletions

1
srcpkgs/maxima-ecl Symbolic link
View file

@ -0,0 +1 @@
maxima

View file

@ -0,0 +1,24 @@
commit a0d7a43e5234305bd6f1de5909d4ce5d7e1ea864
Author: Robert Dodier <robert_dodier@users.sourceforge.net>
Date: Mon Oct 11 22:40:13 2021 -0700
Apply patch #80: "Build a FASL library, needed by SageMath"
This modifies maxima.system for ECL only.
diff --git a/src/maxima.system b/src/maxima.system
index d954bc2b9..525fb778e 100644
--- a/src/maxima.system
+++ b/src/maxima.system
@@ -75,6 +75,11 @@
;; Convert dir/foo.fas to dir/foo.o
(make-pathname :type "o" :defaults p))
files)))
+ (c::build-fasl "binary-ecl/maxima" :lisp-files obj
+ :ld-flags
+ (let ((x (symbol-value (find-symbol "*AUTOCONF-LD-FLAGS*"
+ (find-package "MAXIMA")))))
+ (if (and x (not (string= x ""))) (list x))))
(c::build-program "binary-ecl/maxima" :lisp-files obj
:ld-flags
(let ((x (symbol-value (find-symbol "*AUTOCONF-LD-FLAGS*"

View file

@ -0,0 +1,43 @@
Description: Handle multiple LDFLAGS
Without this patch, building with LDFLAGS containing more than one flag results
in flags being dropped.
Author: Graham Inggs <ginggs@debian.org>
Bug-Debian: http://bugs.debian.org/847925
--- a/src/maxima.system
+++ b/src/maxima.system
@@ -58,6 +58,19 @@
(and (apply #'compile-file file :output-file object-output args)
(c:build-fasl output :lisp-files (list object-output)))))
+(defun split-string (string &key (item #\space) (test #'char=))
+ ;; Splits the string into substrings at spaces.
+ (let ((len (length string))
+ (index 0) result)
+ (dotimes (i len
+ (progn (unless (= index len)
+ (push (subseq string index) result))
+ (reverse result)))
+ (when (funcall test (char string i) item)
+ (unless (= index i);; two spaces in a row
+ (push (subseq string index i) result))
+ (setf index (1+ i))))))
+
#+ecl
(defun build-maxima-lib ()
(labels ((list-all-objects (module)
@@ -79,12 +92,12 @@
:ld-flags
(let ((x (symbol-value (find-symbol "*AUTOCONF-LD-FLAGS*"
(find-package "MAXIMA")))))
- (if (and x (not (string= x ""))) (list x))))
+ (if (and x (not (string= x ""))) (split-string x))))
(c::build-program "binary-ecl/maxima" :lisp-files obj
:ld-flags
(let ((x (symbol-value (find-symbol "*AUTOCONF-LD-FLAGS*"
(find-package "MAXIMA")))))
- (if (and x (not (string= x ""))) (list x)))
+ (if (and x (not (string= x ""))) (split-string x)))
:epilogue-code '(progn (cl-user::run)))))))
(defun maxima-binary-pathname ()

View file

@ -0,0 +1,23 @@
Description: Fix error in matrix exponentiation
This patch was written by SageMath but not yet committed into Maxima releases.
However, it is needed for SageMath to work correctly:
.
https://git.sagemath.org/sage.git/tree/build/pkgs/maxima/patches/matrixexp.patch
Author: Peter Bruin <P.J.Bruin@math.leidenuniv.nl>
Bug-Sage: http://trac.sagemath.org/ticket/13973
Bug: https://sourceforge.net/p/maxima/bugs/2596/
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/share/linearalgebra/matrixexp.lisp
+++ b/share/linearalgebra/matrixexp.lisp
@@ -138,8 +138,8 @@
(print `(ratvars = ,$ratvars gcd = '$gcd algebraic = ,$algebraic))
(print `(ratfac = ,$ratfac))
(merror "Unable to find the spectrum")))
-
- (setq res ($fullratsimp (ncpower (sub (mult z ($ident n)) mat) -1) z))
+
+ (setq res ($fullratsimp ($invert_by_lu (sub (mult z ($ident n)) mat) '$crering) z))
(setq m (length sp))
(dotimes (i m)
(setq zi (nth i sp))

View file

@ -1,11 +1,11 @@
# Template file for 'maxima'
pkgname=maxima
version=5.45.1
revision=1
revision=2
build_style=gnu-configure
configure_args="$(vopt_enable clisp) $(vopt_enable sbcl sbcl-exec)"
configure_args="$(vopt_enable clisp) $(vopt_enable sbcl sbcl-exec) $(vopt_enable ecl)"
hostmakedepends="python3 perl emacs texinfo"
makedepends="$(vopt_if clisp clisp) $(vopt_if sbcl sbcl)"
makedepends="$(vopt_if clisp clisp) $(vopt_if sbcl sbcl) $(vopt_if ecl ecl)"
depends="$(vopt_if clisp clisp) rlwrap"
checkdepends="gnuplot"
short_desc="Computer Algebra System"
@ -17,10 +17,11 @@ checksum=fe9016276970bef214a1a244348558644514d7fdfaa4fc8b9d0e87afcbb4e7dc
nostrip=yes
nopie=yes
build_options="clisp sbcl"
build_options="clisp sbcl ecl"
desc_option_clisp="Build with CLISP"
desc_option_sbcl="Build with SBCL"
build_options_default="sbcl"
desc_option_ecl="Build with ECL"
build_options_default="sbcl ecl"
vopt_conflict clisp sbcl
post_install() {
@ -66,3 +67,26 @@ xmaxima_package() {
${PKGDESTDIR}/usr/share/pixmaps/maxima
}
}
subpackages="maxima-src maxima-emacs xmaxima"
if [ "$build_option_ecl" ]; then
subpackages+=" maxima-ecl"
fi
maxima-ecl_package() {
short_desc+=" - compiled with ECL"
depends="${sourcepkg}-${version}_${revision}"
pkg_install() {
# this is /usr/lib/ecl-${ecl_version}
# ideally we would just place it in /usr/lib/ecl but this
# doesn't just work
# Maybe we can have the ecl package ship a symlink:
# /usr/lib/ecl -> /usr/lib/ecl-${ecl_version}
# and have this package just install in /usr/lib/ecl
ECLDIR=$(ecl -eval "(princ (SI:GET-LIBRARY-PATHNAME))" -eval "(quit)")
vmkdir $ECLDIR
vinstall src/binary-ecl/maxima.fas 755 $ECLDIR
vmove usr/lib/maxima/${version}/binary-ecl
}
}