# From src/version.h:#define OCTAVE_API_VERSION
%define octave_api api-v32

%define vine4 0

%define version 3.0.2
%define release 1%{?_dist_release}
%define name octave

Summary: GNU Octave -- a high-level language for numerical computations
Summary(ja): 数値計算のための高級言語
Name: %{name}
Version: %{version}
Release: %{release}
License: GPL
Group: Applications/Engineering

Source: ftp://ftp.octave.org/pub/octave/%{name}-%{version}.tar.bz2
URL: http://www.octave.org
BuildRequires:  bison flex less tetex lapack-devel blas-devel
BuildRequires:  ncurses-devel zlib-devel curl-devel texinfo
BuildRequires:  readline-devel glibc-devel fftw3-devel gperf ghostscript
BuildRequires:  glpk-devel gnuplot desktop-file-utils
BuildRequires:  hdf5-devel qhull-devel suitesparse-devel 
%if !%{vine4}
BuildRequires:  gcc-gfortran
%else
BuildRequires:  gcc-g77
%endif

Requires: gnuplot 
Requires(post): /sbin/install-info
Requires(postun): /sbin/ldconfig
Requires(post): /sbin/ldconfig
Requires(preun): /sbin/install-info
Buildroot: %{_tmppath}/%{name}-%{version}-root

Vendor: Project Vine
Distribution: Vine Linux

%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 その他の言語で書いた動的ライブラリを用いて容易に拡張やカスタ
マイズを行うことができます。

%prep
%setup -q 
# Check that octave_api is set correctly
if ! grep -q '^#define OCTAVE_API_VERSION "%{octave_api}"' src/version.h
then
  echo "octave_api variable in spec does not match src/version.h"
  exit 1
fi

%build
%define enable64 no
%if !%{vine4}
%define f77 gfortran
%else
%define f77 g77
%endif
export CPPFLAGS=-I%{_includedir}/glpk
%configure --enable-shared --disable-static --enable-64=%enable64 --with-f77=%{f77} --with-curl
make %{?_smp_mflags} OCTAVE_RELEASE="VinePlus %{version}-%{release}"

#CXXFLAGS="$RPM_OPT_FLAGS"
#export CXXFLAGS
#configure --enable-dl --enable-shared --enable-lite-kernel --enable-picky-flags --disable-rpath --with-g77 --without-mpi

%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
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

# Remove RPM_BUILD_ROOT from ls-R files
perl -pi -e "s,$RPM_BUILD_ROOT,," $RPM_BUILD_ROOT%{_libexecdir}/%{name}/ls-R
perl -pi -e "s,$RPM_BUILD_ROOT,," $RPM_BUILD_ROOT%{_datadir}/%{name}/ls-R

# Clean doc directory
pushd doc
  make distclean
  rm -f *.in */*.in */*.cc refcard/*.tex
popd

# Create desktop file
rm $RPM_BUILD_ROOT%{_datadir}/applications/www.octave.org-octave.desktop
desktop-file-install --vendor vine --add-category X-Fedora \
	--dir $RPM_BUILD_ROOT%{_datadir}/applications examples/octave.desktop

# Create directories for add-on packages
HOST_TYPE=`$RPM_BUILD_ROOT%{_bindir}/octave-config -p CANONICAL_HOST_TYPE`
mkdir -p $RPM_BUILD_ROOT%{_libexecdir}/%{name}/site/oct/%{octave_api}/$HOST_TYPE
mkdir -p $RPM_BUILD_ROOT%{_libexecdir}/%{name}/site/oct/$HOST_TYPE

%clean
rm -rf $RPM_BUILD_ROOT

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

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

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root)
%doc COPYING NEWS* PROJECTS README README.Linux README.kpathsea ROADMAP
%doc SENDING-PATCHES THANKS emacs examples doc/interpreter/octave.p*
%doc doc/faq doc/interpreter/HTML doc/refcard

%{_bindir}/*
%config(noreplace) /etc/ld.so.conf.d/*
%{_libdir}/octave-%{version}
%{_includedir}/octave-%{version}
%{_datadir}/applications/*
%{_datadir}/octave
%{_libexecdir}/octave
%{_mandir}/man*/*
%{_infodir}/octave*
#{_menudir}/%{name}
#{_iconsdir}/%{name}.xpm
#{_miconsdir}/%{name}.xpm
#{_liconsdir}/%{name}.xpm

%changelog
* 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