%define ruby	/usr/bin/ruby
%define rlibdir	%(%{ruby} -r rbconfig -e 'print Config::CONFIG["rubylibdir"]')
%define over	current-snap20010625
%define xver	20010625

Summary: Message Harmonized Calendaring system
Name: mhc
Version: 0.25+%{xver}
Release: 0vl7
Copyright: GPL
Group: Applications/Text
Source: http://www.quickhack.net/mhc/arc/%{name}-%{over}.tar.gz
Source1: %{name}-install.sh
Source2: %{name}-remove.sh
Patch1: mhc-0.25-mhcml.1547.patch
URL: http://www.quickhack.net/%{name}/
Prefix: /usr
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildPreReq: ruby, ruby-devel, pilot-link-devel
PreReq: emacsen, emacsen-common >= 0.1, semi
Requires: ruby, ruby-gtk, openssh-clients, pilot-link

%description
MHC is designed to help those who receive most appointments via email.
Using MHC, you can easily import schedule articles from emails.

You can get the latest version from:

  http://www.quickhack.net/mhc/

MHC has following features:

  + Simple data structure allows you to manipulate stored data in many ways.
  + Both UNIX and Windows9x support.
  + Appointments can be made to repeat in flexible ways.
  + powerful but simple expression of appointments.
  + Multiple User Interface such as commandline/emacs/GUI/Web.

MHC currently has following interfaces:

  + Elisp package cooperative with  Mew, Wanderlust or Gnus (popular MUA in
    the Emacs world) (emacs/mhc.el)
  + GUI (Ruby/Gtk based) desktop calendar application. (gemcal)
  + Command line schedule lister like the scan of MH. (mscan)

%prep

%setup -q -c

cd %{name}-%{over}
cd emacs
%patch1 -p0
cd ..
cd ..

%build
cd %{name}-%{over}

ruby ./configure.rb --with-icondir=%{_datadir}/pixmaps/%{name}
make -C ruby-ext

cd ..

%install
cd %{name}-%{over}

[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
[ "${RPM_BUILD_ROOT}" != "/" ] && mkdir -p ${RPM_BUILD_ROOT}

mkdir -p ${RPM_BUILD_ROOT}/%{_bindir}
mkdir -p ${RPM_BUILD_ROOT}/%{_datadir}/pixmaps/%{name}
mkdir -p ${RPM_BUILD_ROOT}/%{_datadir}/bitmaps/%{name}
mkdir -p ${RPM_BUILD_ROOT}/%{_datadir}/emacs/site-lisp/%{name}
mkdir -p ${RPM_BUILD_ROOT}/%{_libdir}/emacsen-common/packages/install
mkdir -p ${RPM_BUILD_ROOT}/%{_libdir}/emacsen-common/packages/remove

cp emacs/*.el ${RPM_BUILD_ROOT}/%{_datadir}/emacs/site-lisp/%{name}
cp emacs/Makefile ${RPM_BUILD_ROOT}/%{_datadir}/emacs/site-lisp/%{name}
cp emacs/MHC-MK ${RPM_BUILD_ROOT}/%{_datadir}/emacs/site-lisp/%{name}
cp xpm/*.xpm ${RPM_BUILD_ROOT}/%{_datadir}/pixmaps/%{name}

for s in adb2mhc gemcal mhc-sync mhc2palm palm2mhc today
do
  install -m 755 $s ${RPM_BUILD_ROOT}/%{_bindir}
done

make -C ruby-ext install DESTDIR=${RPM_BUILD_ROOT}

cp icons/*.xbm ${RPM_BUILD_ROOT}/%{_datadir}/pixmaps/%{name}
cp icons/*.xpm ${RPM_BUILD_ROOT}/%{_datadir}/bitmaps/%{name}


%_installemacsenscript %{name} %{SOURCE1} 

%_removeemacsenscript  %{name} %{SOURCE2}

cd ..

%triggerin -- wl-el
if [ "$1" = 2 ]; then
  %_emacsenPackageRemove mhc

fi

%_addemacsenlist mhc

%_emacsenPackageInstall mhc

%triggerun -- wl-el
if [ "$1" = 2 ]; then
  %_emacsenPackageRemove mhc

fi

%_addemacsenlist mhc

%_emacsenPackageInstall mhc

%triggerin -- mew-el
if [ "$1" = 2 ]; then
  %_emacsenPackageRemove mhc

fi

%_addemacsenlist mhc

%_emacsenPackageInstall mhc

%triggerun -- mew-el
if [ "$1" = 2 ]; then
  %_emacsenPackageRemove mhc

fi

%_addemacsenlist mhc

%_emacsenPackageInstall mhc


%triggerin -- t-gnus
if [ "$1" = 2 ]; then
  %_emacsenPackageRemove mhc

fi

%_addemacsenlist mhc

%_emacsenPackageInstall mhc

%triggerun -- t-gnus
if [ "$1" = 2 ]; then
  %_emacsenPackageRemove mhc

fi

%_addemacsenlist mhc

%_emacsenPackageInstall mhc

%post
if [ "$1" = 2 ]; then
  %_emacsenPackageRemove mhc

fi

%_addemacsenlist mhc

%_emacsenPackageInstall mhc

%preun
if [ "$1" = 0 ]; then
  %_emacsenPackageRemove mhc

  %_removeemacsenlist mhc

fi

%clean
[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}

%files
%defattr(-, root, root)
%{_bindir}
%{rlibdir}
%{_datadir}/pixmaps/%{name}
%{_datadir}/bitmaps/%{name}
%{_libdir}/emacsen-common/packages/install/%{name}
%{_libdir}/emacsen-common/packages/remove/%{name}
%{_datadir}/emacs/site-lisp/%{name}/
%doc %{name}-%{over}/00changes.jis
%doc %{name}-%{over}/00copyright
%doc %{name}-%{over}/00readme
%doc %{name}-%{over}/00readme.jis
%doc %{name}-%{over}/00readme.w32.jis
%doc %{name}-%{over}/00todo.jis
%doc %{name}-%{over}/00usage.jis
%doc %{name}-%{over}/ChangeLog
%doc %{name}-%{over}/NEWS
%doc %{name}-%{over}/NEWS.jis
%doc %{name}-%{over}/samples/

%changelog
* Fri Feb 08 2002 akira yamada <akira@vinelinux.org> 0.25+20010625-0vl7
- applied [mhc:01547] Re: message display error with wl-2.9.6.

* Mon Feb 04 2002 akira yamada <akira@vinelinux.org> 0.25+20010625-0vl6
- moved emacsen-common to PreReq.
- added semi to PreReq.

* Sun Dec 16 2001 akira yamada <akira@vinelinux.org> 0.25+20010625-0vl5
- requires: pilot-link

* Sun Dec 16 2001 akira yamada <akira@vinelinux.org> 0.25+20010625-0vl4
- added %%triggureun.

* Sat Dec 15 2001 akira yamada <akira@vinelinux.org> 0.25+20010625-0vl3
- requires: ruby-gtk, openssh-clients

* Sat Dec 15 2001 akira yamada <akira@vinelinux.org> 0.25+20010625-0vl2
- Initial packaging.
