%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      php-mode
%define       origver       1.5.0
%define       release       1%{?_dist_release}

Summary: PHP-mode for Emacsen
Name: %{origname}
Version: %{origver}
Release: %{release}
URL: http://sourceforge.net/projects/php-mode/
Source0: http://prdownloads.sourceforge.net/php-mode/php-mode-%{version}.tar.gz
Source1: %{origname}-install.sh
Source2: %{origname}-remove.sh
Source3: vine-default-php-mode.el
Source4: php-mode-init.el
License: GPL
Group: Applications/Editors/Emacs
Buildroot: %{_tmppath}/%{name}-%{version}-root
BuildArchitectures: noarch
PreReq:       emacsen
Requires:     emacsen texinfo
#Requires:     speedbar
%prereq_ge emacsen-common

%description
An Emacs major mode for editing PHP code. Features: Syntax coloring 
and indenting; Documentation browse and search functions; Support for 
Imenu and SpeedBar; Customization options

%prep
%setup -q
makeinfo php-mode.texi

%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/%{origname}
mkdir -p $RPM_BUILD_ROOT/%{emacsen_pkgdir}/install
mkdir -p $RPM_BUILD_ROOT/%{emacsen_pkgdir}/remove
mkdir -p $RPM_BUILD_ROOT/%{_infodir}

install -m 0644 php-mode.info $RPM_BUILD_ROOT/%{_infodir}

###
# install el files
cp -a *.el %{SOURCE3} %{SOURCE4} ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{origname}

###
# 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}

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

%_emacsenPackageRemove %{origname}

%_removeemacsenlist %{origname}

fi

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

%files
%defattr(-,root,root)
%doc fdl.texi ChangeLog
%{_infodir}/php-mode.info*
%{_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}

%changelog
* Mon Dec 21 2009 IWAI, Masaharu <iwai@alib.jp> 1.5.0-1
- new upstream release
- apply vine-default
  - add vine-default-php-mode.el (Source3)
  - add php-mode-init.el (Source4)
  - update php-mode-{install,remove}.sh
- add documents

* Thu Oct 09 2008 Shu KONNO <owa@bg.wakwak.com> 1.2.0-1vl5
- applied new versioning policy, spec in utf-8
- added macro %%emacsen_pkgdir

* Tue Sep 12 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.2.0-0vl1
- new upstream release
- changed ruby-mode Group to Appliations/Editors/Emacs <BTS:VineLinux:163>

* Mon Jul 22 2002 IWAI Masaharu <iwai@alib.jp> 1.0.2-0vl1
- first build for Vine Linux

