%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
%define       origname      speedbar
%define       origver       0.14beta4
%define       release       1%{?_dist_release}

Summary: Speedbar for Emacs
name: %{origname}
Version: %{origver}
Release: %{release}
Source0: http://prdownloads.sourceforge.net/cedet/%{name}-%{version}.tar.gz
Source1: %{origname}-install.sh
Source2: %{origname}-remove.sh
License: GPL
Group: Applications/Editors/Emacs
URL: http://cedet.sourceforge.net/speedbar.shtml
Vendor: Project Vine
Packager: yoneda kenji <yoneda@n.isl.titech.ac.jp>
Buildroot: %{_tmppath}/%{name}-%{version}-root
BuildArchitectures: noarch
PreReq: emacsen
Requires: emacsen
%prereq_ge emacsen-common

%description
Speedbar is an Emacs Lisp program which allows you to create a special 
skinny frame with a specialized directory listing in it. This listing 
will have both directories and filtered files in it. You can then load 
files into your emacs frame, or expand the files to display all the tags 
that are in them and jump to those tags. You can also expand multiple 
directories into your speedbar frame.

%prep
rm -rf $RPM_BUILD_ROOT
%setup -q -n %{name}-%{version}

%build
[ "${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/%{origname}
#mkdir -p $RPM_BUILD_ROOT/%{_libdir}/emacsen-common/packages/install
#mkdir -p $RPM_BUILD_ROOT/%{_libdir}/emacsen-common/packages/remove
mkdir -p $RPM_BUILD_ROOT/%{emacsen_pkgdir}/install
mkdir -p $RPM_BUILD_ROOT/%{emacsen_pkgdir}/remove
mkdir -p $RPM_BUILD_ROOT%{_infodir}
#touch $RPM_BUILD_ROOT%{_infodir}/dir

###
# install el files
cp -a Makefile *.el *.texi *.xpm Project.ede \
          ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{origname}

###
#  install info
install -m0644 speedbar.info* ${RPM_BUILD_ROOT}%{_infodir}

###
# install  script( bytecompile el and install elc , remove )   
%_installemacsenscript %{origname} %{SOURCE1} 

%_removeemacsenscript  %{origname} %{SOURCE2}

%post
###
# bytecompile and install 
if [ "$1" = 2 ]; then

%_emacsenPackageRemove %{origname}

fi

%_addemacsenlist %{origname}

%_emacsenPackageInstall %{origname}

/sbin/install-info %{_infodir}/speedbar.info* %{_infodir}/dir \
        --section="Emacs"

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

%_emacsenPackageRemove %{origname}

%_removeemacsenlist %{origname}

/sbin/install-info --delete %{_infodir}/speedbar.info* %{_infodir}/dir \
        --section="Emacs"

fi

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

%files
%defattr(-,root,root)
%{_datadir}/emacs/site-lisp/%{origname}/
#%{_libdir}/emacsen-common/packages/install/%{origname}
#%{_libdir}/emacsen-common/packages/remove/%{origname}
%{emacsen_pkgdir}/install/%{origname}
%{emacsen_pkgdir}/remove/%{origname}
%{_infodir}/speedbar.info*


%changeLog
* Sat Oct 11 2008 Shu KONNO <owa@bg.wakwak.com> 0.14beta4-1vl5
- applied new versioning policy
- added macro %%emacsen_pkgdir

* Tue Sep 12 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.14beta4-0vl2
- changed Group to Appliations/Editors/Emacs <BTS:VineLinux:163>

* Mon Jul 22 2002 IWAI Masaharu <iwai@alib.jp> 0.14beta4-0vl1
- emacsenize
- update speedbar to version 0.14bera4

* Tue Feb 20 2001 yoneda kenji <yoneda@n.isl.titech.ac.jp>
- (0.13a-0s)
- 1st Release for Vine Linux 2.1

* Fri Dec 15 2000 Shinya Ohnuma <a61051@cit.nihon-u.ac.jp>
- (0.13a-0s)
- 1st Release for Nishi Lab users.

