%define ver 2.2.9
%define docver 2.2.0
%define rel 2%{?_dist_release}
%define __libtoolize /bin/true
%define schemas /etc/gconf/schemas/apps_gnucash_dialog_business_common.schemas /etc/gconf/schemas/apps_gnucash_dialog_commodities.schemas /etc/gconf/schemas/apps_gnucash_dialog_common.schemas /etc/gconf/schemas/apps_gnucash_dialog_hbci.schemas /etc/gconf/schemas/apps_gnucash_dialog_prices.schemas /etc/gconf/schemas/apps_gnucash_dialog_print_checks.schemas /etc/gconf/schemas/apps_gnucash_dialog_reconcile.schemas /etc/gconf/schemas/apps_gnucash_dialog_scheduled_transctions.schemas /etc/gconf/schemas/apps_gnucash_dialog_totd.schemas /etc/gconf/schemas/apps_gnucash_general.schemas /etc/gconf/schemas/apps_gnucash_history.schemas /etc/gconf/schemas/apps_gnucash_import_generic_matcher.schemas /etc/gconf/schemas/apps_gnucash_import_qif.schemas /etc/gconf/schemas/apps_gnucash_warnings.schemas /etc/gconf/schemas/apps_gnucash_window_pages_account_tree.schemas /etc/gconf/schemas/apps_gnucash_window_pages_register.schemas

Name:      	gnucash
Summary:   	GnuCash is an application to keep track of your finances.
Summary(ja):	GnuCash -- 個人用財務管理アプリケーション
Version:   	%{ver}
Release:  	%{rel}
License: 	GPL/LGPL/GFDL
Group:     	Applications/Productivity
URL:            http://www.gnucash.org/
Packager:       kenta, inagaki
Source:    	%{name}-%{version}.tar.bz2
Source1:        %{name}-docs-%{docver}.tar.gz
Patch0:         gnucash-2.2.3-quiet.patch
BuildRoot: 	%{_tmppath}/%{name}-%{version}-root

BuildRequires: aqbanking-devel >= 3.7.2
BuildRequires: GConf2-devel
BuildRequires: bzip2-devel
BuildRequires: expat-devel
BuildRequires: gettext
BuildRequires: goffice-devel >= 0.4.3
BuildRequires: gtk2-devel
BuildRequires: gtkhtml3-devel
BuildRequires: guile-devel
BuildRequires: libofx-devel
BuildRequires: libgnomeui-devel
BuildRequires: libjpeg-devel
BuildRequires: pcre-devel
BuildRequires: swig
BuildRequires: slib
BuildRequires: gwenhywfar-devel

BuildPrereq:   desktop-file-utils
Prereq:        GConf2
Prereq:        scrollkeeper >= 0.3.4
Prereq:        /sbin/ldconfig
Prereq:        /sbin/install-info
# for HBCI setup wizard
Requires:      qbanking
Requires:      slib
Requires:      perl-DateManip
Requires:      yelp
Obsoletes:     gnucash-backend-postgres

%description
GnuCash is a personal finance manager. A check-book like
register GUI allows you to enter and track bank accounts,
stocks, income and even currency trades. The interface is
designed to be simple and easy to use, but is backed with
double-entry accounting principles to ensure balanced books.

%description -l ja
GnuCashは 個人用財務管理をするアプリケーションです．
預金, 株式, 所得そして通貨取引さえ入力し、追跡することができる
グラフィカルな小切手帖です．インターフェスはシンプルかつ簡単に
使用できるようにデザインされています．

%prep
%setup -q -a 1
%patch0 -p1 -b .quiet

%build
msgfmt -v po/ja.po -o po/ja.gmo

#autoconf -f
#cp %{_datadir}/libtool/config.{sub,guess} .
%configure --enable-error-on-warning=no \
           --disable-sql \
           --enable-ofx  \
           --enable-hbci \
           --disable-schemas-install \
           --disable-static \
            --with-slibdir=/%{_lib}

make LIBTOOL=%{_bindir}/libtool

# doc build
cd gnucash-docs-%{docver}
#autoconf
%configure
make


%install
[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf $RPM_BUILD_ROOT

make install DESTDIR=$RPM_BUILD_ROOT LIBTOOL=/usr/bin/libtool

%find_lang %name

cd gnucash-docs-%{docver}
make install DESTDIR=$RPM_BUILD_ROOT || :


# vfolder desktop file install stuff
mkdir -p $RPM_BUILD_ROOT/%{_datadir}/applications/
desktop-file-install --vendor gnome --delete-original \
  --dir $RPM_BUILD_ROOT%{_datadir}/applications       \
  --add-category X-Red-Hat-Extra                      \
  --add-category Application                          \
  --add-category Office                               \
  $RPM_BUILD_ROOT%{_datadir}/applications/gnucash.desktop 
echo "StartupWMClass=GnuCash" >> $RPM_BUILD_ROOT%{_datadir}/applications/gnome-gnucash.desktop

rm -rf $RPM_BUILD_ROOT/%{_infodir} \
       $RPM_BUILD_ROOT/%{_includedir} \
       $RPM_BUILD_ROOT/%{_libdir}/lib*.a \
       $RPM_BUILD_ROOT/%{_libdir}/gnucash/lib*.a

%clean
[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf $RPM_BUILD_ROOT


%pre
if [ "$1" -gt 1 ]; then
    export GCONF_CONFIG_SOURCE=$(gconftool-2 --get-default-source)
    for S in %{schemas}; do
      gconftool-2 --makefile-uninstall-rule ${S} >/dev/null
    done
fi

%post
/sbin/ldconfig
%{_bindir}/scrollkeeper-update -o %{_datadir}/omf/gnucash-docs

export GCONF_CONFIG_SOURCE=$(gconftool-2 --get-default-source)
for S in %{schemas}; do
  gconftool-2 --makefile-install-rule ${S} >/dev/null
done

%preun
if [ "$1" -gt 0 ]; then
    export GCONF_CONFIG_SOURCE=$(gconftool-2 --get-default-source)
    for S in %{schemas}; do
      gconftool-2 --makefile-uninstall-rule ${S} >/dev/null
    done
fi

%postun 
/sbin/ldconfig
%{_bindir}/scrollkeeper-update

%files -f %{name}.lang
%defattr(-,root,root,755)
%{_sysconfdir}/gconf/schemas/*
%config %{_sysconfdir}/gnucash
%{_bindir}/*
%{_libexecdir}/gnucash
%{_libdir}/*
%{_datadir}/omf/gnucash-docs
%{_datadir}/gnucash
%{_datadir}/gnome/help/gnucash
%{_datadir}/xml/gnucash
%{_datadir}/applications/*
%{_datadir}/icons/hicolor/*/apps/*
%{_mandir}/man*/*
%doc AUTHORS COPYING ChangeLog* DOCUMENTERS HACKING NEWS README README.patches
%doc doc/README.german doc/README.francais doc/guile-hackers.txt
%doc doc/README.OFX

%changelog
* Fri Jul 24 2009 NAKAMURA Kenta <kenta@vinelinux.org> 2.2.9-2
- added slib to BuildRequires: and Requires:

* Sat May 30 2009 NAKAMURA Kenta <kenta@vinelinux.org> 2.2.9-1
- new upstream release

* Wed Jan 14 2009 NAKAMURA Kenta <kenta@vinelinux.org> 2.2.8-1
- new upstream release

* Mon Jan 12 2009 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 2.2.7-2
- rebuild with guile-1.8.6
- add BuildRequires: gwenhywfar-devel

* Sun Oct 12 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.2.7-1
- new upstream release
- applied new versioning policy
- built with aqbanking-3.7.2, gwenheyfar-3.4.1, libofx-0.9.0 

* Tue Mar 11 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.2.4-0vl1
- new upstream release
- rebuilt with goffice-0.6.0

* Tue Jan 22 2008 NAKAMURA Kenta <kenta@vinelinux.org> 2.2.3-0vl1
- new upstream release

* Sun Jan 20 2008 NAKAMURA Kenta <kenta@vinelinux.org> 2.2.2-0vl1
- new upstream release
- enable HBCI (Home Banking Computer Interface)

* Tue Jan 08 2008 NAKAMURA Kenta <kenta@vinelinux.org> 2.2.0-0vl2
- rebuild with libofx-0.8.3 (libofx.so.3)

* Sun Dec 30 2007 NAKAMURA Kenta <kenta@vinelinux.org> 2.2.0-0vl1
- new upstream release
- disable postgresql backend, as it is unmaintained upstream
- added Patch0: gnucash-2.2.0-quiet.patch

* Sun Oct 23 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.8.12-0vl1
- new upstream release
- remove BuildRequiers: autoconf213
- update ja.po

* Fri Jan  2 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.8.8-0vl2
- new upstream release
- added BuildPrereq: libtool-ltdl-devel

* Fri Jan  2 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.8.8-0vl2
- rebuild with new toolchains
- update ja.po

* Sun Nov 23 2003 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.8.8-0vl1
- new upstream release

* Sun Oct 19 2003 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.8.7-1vl1
- merged gnucash-docs-1.8.3
- added patch from Redhat Rawhide 1.8.7-1
- changed Group, License

* Mon Oct  6 2003 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.8.7-0vl1
- updated to 1.8.7
- updated print.patch
- overwrite prefs.scm
- s/Copyright/License/

* Tue May 13 2003 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.8.3-0vl1
- updated to 1.8.3
- added datelength.patch
- separated devel packages
  (and ofx, hbci, backend-postgres. But default is off)

* Wed Jan 16 2002 Akira TAGOH <tagoh@gnome.gr.jp> 1.6.5-0vl3
- Build against with new gal.

* Fri Dec 28 2001 Akira TAGOH <tagoh@gnome.gr.jp> 1.6.5-0vl2
- Fixed printing issue.

* Tue Dec 25 2001 Akira TAGOH <tagoh@gnome.gr.jp> 1.6.5-0vl1
- New upstream release.

* Thu Jul 26 2001 <sagami@vinelinux.org>
- 1.6.0-0vl3: fix to not to own mandir itself, use %%{find_lang}

* Tue Jun 12 2001 MATSUBAYASHI 'Shaolin' Kohji <shaolin@vinelinux.org>
- %%make line is now commented out (bash2 complains it)
  (BTW, what the hell is the macro %%make anyway? I don't even know...)

* Tue Jun 12 2001 Daisuke SUZUKI <daisuke@linux.or.jp> 1.6.0-0vl1
- update to 1.6.0 (stable release version)

* Thu May 24 2001 Daisuke SUZUKI <daisuke@linux.or.jp> 1.5.96-0vl1
- update to 1.5.96 ( pre beta for 1.6.0 )

* Mon Apr 23 2001 Daisuke SUZUKI <daisuke@linux.or.jp> 1.5.6-1vl2
- added japanese patch for reporting and printing (thanx tagoh-san)

* Mon Apr 23 2001 Daisuke SUZUKI <daisuke@linux.or.jp> 1.5.6-1vl1
- updated to 1.5.6

* Thu Apr 05 2001 Daisuke SUZUKI <daisuke@linux.or.jp> 1.5.4-1vl2
- added translation messages to ja.po
- enable guppi

* Mon Apr  2 2001 Kazuhisa TAKEI <takei@vinelinux.org> 1.5.4-1vl1
- upstream update
- fixed broken ja.po 

* Wed Mar 28 2001 Kazuhisa TAKEI <takei@vinelinux.org> 1.5.2-1vl2
- fixed registor window cursor position problem(gnucash-cursor_pos.patch) 

* Mon Mar 26 2001 Kazuhisa TAKEI <takei@vinelinux.org> 1.5.2-1vl1
- initial relese package
