#Maintainer: Dimitris Tzemos <djemos~at~slackel~dot~gr>

pkgname=mathomatic
pkgver=16.0.5
pkgrel=1dj
source=("http://mathomatic.org/$pkgname-$pkgver.tar.bz2")
sourcetemplate=http://people.salixos.org/djemos/salix/$pkgname
docs=()
url=http://mathomatic.org/math/

slackdesc=\
(
 #|-----handy-ruler------------------------------------------------------|
"Mathomatic (a small, portable Computer Algebra System)"
"This is a console mode application that does symbolic math and"
"quick calculations in a standard and generalized way."
"Mathomatic is designed to be as general an easy to use as general."
"It implements most of the rules of algebra for addition, subtraction,"
"multiplication, division, modulo division, and all forms of"
"exponentiation. All arithmetic is double precision floating point"
"with up to 14 decimal digits accuracy."
"Homepage: http://mathomatic.org/math/"

)

build() {
cd $SRC/$pkgname-$pkgver || return 1
# python2 fix
  for file in primes/{primorial,matho-sum,matho-mult} examples/factorial; do
    sed -i 's_#!.*/usr/bin/python_#!/usr/bin/python2_' $file || return 1
    sed -i 's_#!.*/usr/bin/env.*python_#!/usr/bin/env python2_' $file || return 1
  done
CFLAGS="$SLKCFLAGS" \
LDLIBS=-lncurses \
  make READLINE=1  || return 1

# We do want to make sure it works. This is math, afterall.
make test || return 1

# Make the m4 package
make m4install \
  prefix=/usr \
  mandir=/usr/man \
  mathdocdir=/usr/doc/$pkgname-$pkgver DESTDIR=$PKG || return 1

# make the prime number additions
CFLAGS="$SLKCFLAGS" \
LDLIBS=-lncurses \
  make READLINE=1 -C primes

make test -C primes

make install -C primes \
  prefix=/usr \
  mandir=/usr/man \
  mathdocdir=/usr/doc/$pkgname-$pkgver  DESTDIR=$PKG || return 1

mkdir -p $PKG/usr/share/icons/hicolor/48x48/apps || return 1
cp $PKG/usr/share/pixmaps/mathomatic.png $PKG/usr/share/icons/hicolor/48x48/apps ||return 1

          
}
