%define	_noVersionedDependencies        1
%define	prereq_ge()  %(LC_ALL="C" rpm -q --queryformat 'PreReq:%%{NAME} >= %%{VERSION}' %1| grep -v "is not")
%define emacsen_pkgdir /usr/lib/emacsen-common/packages
Summary:      Rolodex-like database program for GNU Emacs
Summary(ja):  Emacs 用のローロデックス風データベースプログラム
Name:         bbdb
Version:      2.32
Release:      1%{?_dist_release}

Source0:      ftp://ftp.win.or.jp/pub/word/elisp/%{name}-%{version}.tar.gz
Source1:      %{name}-install.sh
Source2:      %{name}-remove.sh
Source3:      emacs-wl-bbdb.sample
Patch0:       bbdb-2.32-misc.patch
Patch1:       bbdb-2.32-emacsen.patch

License:      GPL
Group:        Applications/Editors/Emacs
BuildRoot:    %{_tmppath}/%{name}-%{version}-root
BuildArch:    noarch

PreReq:        emacsen, make, install-info
%prereq_ge     emacsen-common
BuildRequires: emacsen-common

Vendor:       Project Vine
Distribution: Vine Linux
Packager:     MATUBARA Kazuyuki <matubara@mb.asmnet.ne.jp>

%description
BBDB is a rolodex-like database program for GNU Emacs.  BBDB stands
for Insidious Big Brother Database, and is not, repeat, *not* an
obscure reference to the Buck Rogers TV series.


%prep
%setup -q
%patch0 -p1
%patch1 -p1

cp %{SOURCE3} .

find . -type f -name .cvsignore -print | xargs rm -f
find . -type f -name *.orig -print | xargs rm -f

%build
./configure --with-package-dir=""

chmod -x utils/*.pl

%install

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

mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{name}
#mkdir -p ${RPM_BUILD_ROOT}%{_libdir}/emacsen-common/packages/{install,remove}
mkdir -p ${RPM_BUILD_ROOT}%{emacsen_pkgdir}/{install,remove}
mkdir -p ${RPM_BUILD_ROOT}%{_infodir}

#
# install el files
# 

cp -af Makefile lisp tex utils \
	${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{name}

rm -f ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{name}/*/Makefile.in

#
#  install info
#

install -m 644 texinfo/bbdb.info* ${RPM_BUILD_ROOT}%{_infodir}
gzip -9 ${RPM_BUILD_ROOT}%{_infodir}/bbdb.info*

#
# install  script( bytecompile el and install elc , remove )   
#

%_installemacsenscript %{name} %{SOURCE1} 

%_removeemacsenscript  %{name} %{SOURCE2}

%post 

#
# bytecompile and install 
#

if [ "$1" = 2 ]; then

%_emacsenPackageRemove %{name}

fi

%_addemacsenlist %{name}

%_emacsenPackageInstall %{name}

/sbin/install-info --info-file=%{_infodir}/bbdb.info.gz --info-dir=%{_infodir} --section="Emacs"

%preun

if [ "$1" = 0 ]; then

%_emacsenPackageRemove %{name}

%_removeemacsenlist %{name}

/sbin/install-info --delete %{_infodir}/bbdb.info.gz %{_infodir}/dir

fi

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


%files
%defattr(-,root,root)
%doc ChangeLog INSTALL emacs-wl-bbdb.sample
%{_datadir}/emacs/site-lisp/%{name}/
%{emacsen_pkgdir}/install/%{name}
%{emacsen_pkgdir}/remove/%{name}
%{_infodir}/*


%changelog
* Fri Sep 19 2008 Shu KONNO <owa@bg.wakwak.com> 2.32-1vl5
- applied new versioning policy, spec in utf-8
- added macro %%emacsen_pkgdir


* Tue Sep 12 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.32-0vl3
- changed Group to Appliations/Editors/Emacs <BTS:VineLinux:163>
- s/Copyright/License/

* Sun May 26 2002 MATUBARA Kazuyuki <matubara@kamome.or.jp> 2.32-0vl2
- delete xemacs message to ddskk-install.sh

* Sun Mar 03 2002 MATUBARA Kazuyuki <matubara@mb.asmnet.ne.jp> 2.32-0vl1
- 1st packageing