%define pkg_name    octave
%define pkg_version 4.0.2
%define pkg_release 1%{?_dist_release}

%define gui   1
%define sound 1

%if %{?_dist_release} == "vl6"
%define openjdk_ver 1.6.0
%endif
%if %{?_dist_release} == "vl7"
%define openjdk_ver 1.7.0
%endif


Summary:     GNU Octave -- a high-level language for numerical computations
Summary(ja): 数値計算のための高級言語
Name:        %{pkg_name}
Version:     %{pkg_version}
Release:     %{pkg_release}

License: GPL
Group:   Applications/Edutainment
URL:     http://www.gnu.org/software/octave/
Source0: ftp://ftp.octave.org/gnu/octave/%{name}-%{version}.tar.gz

Buildroot: %{_tmppath}/%{name}-%{version}-root

BuildRequires: gcc-gfortran
BuildRequires: bison flex gperf texinfo less
BuildRequires: gnuplot
BuildRequires: ghostscript-devel
BuildRequires: mesa-libOSMesa-devel
BuildRequires: blas-devel lapack-devel
BuildRequires: pcre-devel
BuildRequires: readline-devel
BuildRequires: arpack
BuildRequires: curl-devel
BuildRequires: fftw3-devel
BuildRequires: fontconfig-devel
BuildRequires: freetype-devel
BuildRequires: glpk-devel
BuildRequires: GraphicsMagick-c++-devel
BuildRequires: hdf5-devel
BuildRequires: java-%{openjdk_ver}-openjdk-devel
BuildRequires: qhull-devel
BuildRequires: qrupdate
BuildRequires: suitesparse-devel
BuildRequires: zlib-devel
BuildRequires: xz-devel
BuildRequires: libtool-ltdl-devel
BuildRequires: libXext-devel
BuildRequires: openssl-devel
%if %{gui}
BuildRequires: desktop-file-utils
BuildRequires: freeglut-devel
BuildRequires: fltk-devel
BuildRequires: gl2ps-devel
BuildRequires: qt4-devel
BuildRequires: qscintilla-devel
%endif
%if %{sound}
BuildRequires: portaudio-devel
BuildRequires: libsndfile-devel
%endif

Requires: ghostscript
Requires: blas lapack
Requires: pcre
Requires: readline
Requires: mesa-libOSMesa
Requires: gnuplot
Requires: arpack
Requires: curl
Requires: fftw3
Requires: fontconfig
Requires: freetype
Requires: glpk
Requires: GraphicsMagick-c++
Requires: hdf5
Requires: qhull
Requires: qrupdate
Requires: suitesparse
Requires: zlib
Requires: openssl
Requires: pstoedit epstool transfig
%if %{gui}
Requires: freeglut
Requires: fltk
Requires: gl2ps
Requires: qt4
Requires: qscintilla
%endif
%if %{sound}
Requires: portaudio
Requires: libsndfile
%endif

Requires(post):   /sbin/install-info
Requires(postun): /sbin/ldconfig
Requires(post):   /sbin/ldconfig
Requires(preun):  /sbin/install-info

Vendor: Project Vine
Distribution: Vine Linux
Packager: ara_t


%description
GNU Octave is a high-level language, primarily intended for numerical
computations. It provides a convenient command line interface for
solving linear and nonlinear problems numerically, and for performing
other numerical experiments using a language that is mostly compatible
with Matlab. It may also be used as a batch-oriented language.

Octave has extensive tools for solving common numerical linear algebra
problems, finding the roots of nonlinear equations, integrating
ordinary functions, manipulating polynomials, and integrating ordinary
differential and differential-algebraic equations. It is easily
extensible and customizable via user-defined functions written in
Octave's own language, or using dynamically loaded modules written in
C++, C, Fortran, or other languages.
# '

%description -l ja
GNU Octave は数値計算用に開発の始められた高級言語です。線形問題や非線形
問題を数値的に解いたり、その他のMatlab と互換性の高い言語を用いた数値計算
を行うための使いやすいコマンドライン・インタフェースを備えています。
バッチ指向言語としても使うこともできます。Octave は多機能なツールで、
一般的な線形幾何の問題の数値解や、通常の関数の積分・微分、多項式の操作等を
行うことができます。
Octave の言語でユーザが関数を定義したり、C++, C, Fortran その他の言語で
書いた動的ライブラリを用いて容易に拡張やカスタマイズを行うことができます。

%if %{gui}
（注意）
デフォルトではグラフの描画にOpenGL/fltkを使用してます。
もし不安定な場合には、
gnuplotをデフォルトとするために ~/.octaverc に
graphics_toolkit("gnuplot");
を追加してから起動して下さい。
%endif


%prep
%{__rm} -rf ${RPM_BUILD_ROOT}
%setup -q

%build
%{configure} \
 CPPFLAGS="-I%{_includedir}/pcre" \
 --with-x \
 --with-magick=GraphicsMagick \
 --with-curl-includedir=%{_includedir}/curl \
 --with-glpk-includedir=%{_includedir}/glpk \
 --with-qhull-includedir=%{_includedir}/qhull \
 --with-amd-includedir=%{_includedir}/suitesparse \
 --with-camd-includedir=%{_includedir}/suitesparse \
 --with-colamd-includedir=%{_includedir}/suitesparse \
 --with-ccolamd-includedir=%{_includedir}/suitesparse \
 --with-cholmod-includedir=%{_includedir}/suitesparse \
 --with-cxsparse-includedir=%{_includedir}/suitesparse \
 --with-umfpack-includedir=%{_includedir}/suitesparse \
 --enable-java \
%if !%{gui}
 --disable-gui \
 --without-opengl \
 --without-fltk \
%endif
%if !%{sound}
 --without-sndfile --without-portaudio \
%endif

%{__make} %{?_smp_mflags}
# %{__make} check

%install
%{make_install}
%{__rm} -f ${RPM_BUILD_ROOT}%{_infodir}/dir

find %{buildroot} -name "*.oct" | xargs strip

# Make library links
%{__mkdir_p} ${RPM_BUILD_ROOT}/etc/ld.so.conf.d
echo "%{_libdir}/octave-%{version}" > \
     ${RPM_BUILD_ROOT}/etc/ld.so.conf.d/octave-%{_arch}.conf

%if %{gui}
# Create desktop file
%{__mv} \
 ${RPM_BUILD_ROOT}%{_datadir}/applications/www.octave.org-octave.desktop \
 ${RPM_BUILD_ROOT}%{_datadir}/applications/octave.desktop
%{__perl} -pi -e s/"Education;Science;Math;"/"Education;Science;"/g \
 ${RPM_BUILD_ROOT}%{_datadir}/applications/octave.desktop
%endif

# rename %{_datadir}/appdata/*
%{__mv} \
 ${RPM_BUILD_ROOT}%{_datadir}/appdata/www.octave.org-octave.appdata.xml \
 ${RPM_BUILD_ROOT}%{_datadir}/appdata/octave.appdata.xml

%clean
%{__rm} -rf ${RPM_BUILD_ROOT}

%post
%{_syssbindir}/ldconfig
/sbin/install-info --info-dir=%{_infodir} --section="Programming" \
                   %{_infodir}/octave.info.gz || :

%preun
if [ "$1" = "0" ]; then
    /sbin/install-info --delete --info-dir=%{_infodir} \
                       %{_infodir}/octave.info.gz || :
fi

%postun -p %{_syssbindir}/ldconfig


%files
%defattr(-,root,root)
%doc AUTHORS BUGS CITATION COPYING ChangeLog NEWS README
%doc examples doc/interpreter/octave.p* doc/refcard
%config(noreplace) /etc/ld.so.conf.d/
%{_bindir}/
%{_libdir}/octave
%{_includedir}/octave-%{version}
%{_datadir}/appdata/
%if %{gui}
%{_datadir}/applications/
%endif
%{_datadir}/icons/
%{_datadir}/octave
%{_libexecdir}/octave
%{_mandir}/man*/*
%{_infodir}/octave*
%{_infodir}/liboctave.info*


%changelog
* Wed May 11 2016 Toshiaki Ara <ara_t@384.jp> 4.0.2-1
- update to 4.0.2
- add BuildRequires: openssl-devel
- add Requires: openssl

* Wed Apr 13 2016 Toshiaki Ara <ara_t@384.jp> 4.0.1-1
- update to 4.0.1
- change dependencies

* Sun Oct 05 2014 Toshiaki Ara <ara_t@384.jp> 3.6.4-2
- [BTS:0002801] add configure option --with-magick=Magick
- delete BuildRequires: texlive-collection-texinfo
- add BuildRequires: texlive-collection-plainextra
- add BuildRequires: texlive-collection-latexextra
- add BuildRequires: texlive-collection-fontsrecommended
-   for VineSeed

* Wed Mar 06 2013 Toshiaki Ara <ara_t@384.jp> 3.6.4-1
- update to 3.6.4
- add BuildRequires: freeglut-devel and Requires: freeglut for VineSeed

* Tue Sep 11 2012 Toshiaki Ara <ara_t@384.jp> 3.6.2-2
- delete octave from menu (programming)

* Tue Aug 28 2012 Toshiaki Ara <ara_t@384.jp> 3.6.2-1
- update to 3.6.2
- correct spec file for version 3.6.2
- add BuildRequires: pcre-devel fltk-devel
- add BuildRequires: ImageMagick-devel ImageMagick-c++-devel
- add BuildRequires: gcc-gfortran
- add BuildRequires: texlive texlive-common texlive-collection-basic
- add BuildRequires: texlive-collection-texinfo texlive-collection-genericrecommended
- chanfe Group to Applications/Edutainment

* Sat Aug 23 2008 Shu KONNO <owa@bg.wakwak.com> 3.0.2-1vl5
- update to 3.0.2
- applied new versioning policy, spec in utf-8

* Sun Feb 03 2008 NAKAMURA Kenta <kenta@vinelinux.org> 3.0.0-0vl1
- update to 3.0.0

* Sat Aug 18 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.9.13-0vl2
- rebuilt for VineSeed

* Fri Aug 17 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.9.13-0vl1
- update to 2.9.13
- rebuilt with new toolchain and environment

* Sun Apr 20 2003 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.0.17-0vl1
- update to 2.0.17
- rebuild with new toolchains
- add BuildRequires: gcc295, gcc295-c++

* Sun Mar  3 2002 Jun Nishii <jun@vinelinux.org> 2.1.35-0vl1
- ver.up

* Tue Sep 26 2000 Jun Nishii <jun@vinelinux.org> 2.0.16-0vl1
- build for Vine Linux 2.1

* Mon Aug 07 2000 Frederic Lepied <flepied@mandrakesoft.com> 2.0.16-5mdk
- automatically added BuildRequires

* Wed Jul 26 2000 Vincent Saugey <vince@mandrakesoft.com> 2.0.16-4mdk
- Macros, BM, add multiple icons sizes

* Wed Apr 12 2000 Vincent Saugey <vince@mandrakesoft.com> 2.0.16-3mdk
- strip oct file
- add menu entry
 
* Tue Mar 21 2000 Vincent Saugey <vince@mandrakesoft.com> 2.0.16-2mdk
- corrected for new groups

* Thu Mar 09 2000 Lenny Cartier <lenny@mandrakesoft.com>
- mandrake build
- v2.0.16

* Fri Oct 23 1998 Jeff Johnson <jbj@redhat.com>
- update to 2.0.13.90

* Thu Jul  9 1998 Jeff Johnson <jbj@redhat.com>
- repackage in powertools.

* Thu Jun 11 1998 Andrew Veliath <andrewtv@usa.net>
- Add %attr, build as user.

* Mon Jun 1 1998 Andrew Veliath <andrewtv@usa.net>
- Add BuildRoot, installinfo, require gnuplot, description from
  Octave's web page, update to Octave 2.0.13.
- Adapt from existing spec file.

* Tue Dec  2 1997 Otto Hammersmith <otto@redhat.com>
- removed libreadline stuff from the file list

* Mon Nov 24 1997 Otto Hammersmith <otto@redhat.com>
- changed configure command to put things in $RPM_ARCH-rehat-linux, 
  rather than genereated one... was causing problems between building 
  on i686 build machine.

* Mon Nov 17 1997 Otto Hammersmith <otto@redhat.com>
- moved buildroot from /tmp to /var/tmp

* Mon Sep 22 1997 Mike Wangsmo <wanger@redhat.com>
- Upgraded to version 2.0.9 and built for glibc system

* Thu May 01 1997 Michael Fulbright <msf@redhat.com>
- Updated to version 2.0.5 and changed to build using a BuildRoot
