# Contributor: Daniel Sabogal <dsabogalcc@gmail.com>
# Maintainer:
pkgname=octave
pkgver=4.2.0
pkgrel=1
pkgdesc="A high-level language, primarily intended for numerical computations"
url="https://www.gnu.org/software/octave/"
arch="all !s390x"
license="GPL-3.0"
depends=""
subpackages="$pkgname-doc"
makedepends="autoconf automake bison curl fftw-dev fltk-dev fontconfig-dev
	freetype-dev gfortran glu-dev gnuplot imagemagick-dev hdf5-dev
	lapack-dev libsm-dev libltdl lcms2-dev pcre-dev perl pkgconf qt-dev
	readline-dev texinfo zlib-dev"
source="ftp://ftp.gnu.org/gnu/octave/$pkgname-$pkgver.tar.gz
	less-docs.patch
	libinterp-deps.patch
	abs.patch
	gnulib.patch"
builddir="$srcdir/$pkgname-$pkgver"

prepare() {
	default_prepare || return 1

	cd "$builddir"
	find -name \*.cc -o -name \*.h -o -name \*.yy | xargs sed -i -e 's/#include <c\(math\|stdlib\)>/#include <\1.h>/'
	find -name \*.h -o -name \*.cc | xargs sed -i -e 's/<config.h>/"config.h"/' -e 's/<base-list.h>/"base-list.h"/'
}

build() {
	cd "$builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--infodir=/usr/share/info \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-shared \
		--disable-static \
		|| return 1
	make || return 1
}

package() {
	make DESTDIR="$pkgdir/" \
		-C "$builddir" install || return 1
	rm -rf "$pkgdir"/usr/lib/charset.alias
}

md5sums="4423db4dd6c2b43cacf9e9dcfa95473d  octave-4.2.0.tar.gz
1b8f1f97aa4acc3777c8760759ef3bb0  less-docs.patch
cf78869bd53964b339578c054614de38  libinterp-deps.patch
bb971c157909841c1ccbe17ae0c6244c  abs.patch
e22f7385ef92fab75191c8925455c097  gnulib.patch"
sha256sums="443ba73782f3531c94bcf016f2f0362a58e186ddb8269af7dcce973562795567  octave-4.2.0.tar.gz
827aae1d7ca615a855733d031aa77aedc076b4db01bb70add4e5631f9084a326  less-docs.patch
978280090f7e490c5e5b92785854b6dbe2971e1c7ed9c1f3c087a6e6f61a40e8  libinterp-deps.patch
fe0683d91d36805a7787fb5b70ccc052a6aaf08594b95b97a904504f5227986d  abs.patch
75562bd81b6cb44e9e5bacf8b1ba556df565001f9dea7960a4346073ed997c33  gnulib.patch"
sha512sums="5d16665d4ef8f218320f471704f8702f3a2911cc4a083cae318c1df0f787d50dddbc511dc91e11379314d65cecac6d521abac026860feca19d11ffdb52d3e678  octave-4.2.0.tar.gz
eb2b754c15eda423bf59061728052993a2ee9611d474e7fa6026f2961561764e6fc56fbb8128ec266bb569e99d7fecb5b68b5ed3f02ae33dd27709a89426f204  less-docs.patch
093b13ad457e290d746908a5de1855071b2cd27b4c08101826d32fcf63398e863c3b72bb81f19255a04a880a2bf49e3ced1141bf7d0044db1328c6f2c9492f66  libinterp-deps.patch
bcd111f35baf2681da2b1ad1edbe956ee359c5fb0114797b27747fa78e6f118406bb7fb325c1fa03c18e29815d2d4b8d9a28faf72c1fbbec526e8fbaed0cb820  abs.patch
50d9a7cefc0d39b666b646abe26148d7640ed2c4505244e3b5d4ba4348f80fc5d0d08465a575682fcae88d245bf72e7ba13df580003a2c5de6b7b222131a5392  gnulib.patch"
