%define _noVersionedDependencies        1
%define _libdir %{_prefix}/lib

%define	      cvs	    1

# from (emacs-w3m-version) in w3m.el
%define       origver       1.4.437
%define       origname      w3m
%define	      rel	    1
%define	      cvsdate	    20110421

Summary:      an simple interface program of w3m, which works on Emacsen
Summary(ja):  Emacsen 用の w3m インタフェースプログラム
Name:         %{origname}-el
Version:      %{origver}
%if %{cvs}
Release:      %{rel}.cvs%{cvsdate}%{?_dist_release}
%else
Release:      %{rel}%{?_dist_release}
%endif
URL:	      http://emacs-w3m.namazu.org/
%if %{cvs}
Source0:      emacs-%{origname}-%{origver}cvs%{cvsdate}.tar.gz
%else
Source0:      http://emacs-w3m.namazu.org/emacs-%{origname}-%{origver}.tar.gz
%endif
Source1:      %{origname}-install.sh
Source2:      %{origname}-remove.sh
Source3:      %{origname}-init.el

%define w3m_info_list \\\
   emacs-w3m-ja.info \\\
   emacs-w3m.info

Patch10:      %{origname}-icon-directory.diff

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

Requires(post): emacsen emacsen-common
Requires(post): autoconf
Requires(post): apel flim w3m
##Requires(post): texinfo tetex
BuildRequires:  w3m
BuildRequires:  emacs
BuildRequires: texinfo
BuildRequires: texlive

Vendor:       Project Vine
Distribution: Vine Linux
Packager:     shaolin


%description
a simple Emacs interface of w3m
This package contains a interface program of w3m, which is a pager
with WWW capability.  It can be used as lightweight WWW browser on emacsen.
This is also known as emacs-w3m. http://emacs-w3m.namazu.org/

%description -l ja
w3m を Emacsen 上で動作させるインターフェースです。
このパッケージは、w3m のインターフェースと WWW ページャを含みます。
Emacsen 上で WWW ブラウザとして動作します。
emacs-w3m の名称で知られています。http://emacs-w3m.namazu.org/
を参照下さい。

Emacs/XEmacs 起動時に以下の設定ファイルを読み込みます。
M-x w3m で起動します。

/etc/emacs-??.?/site-start.d/53w3m-init.el
/etc/xemacs-??.?.??/site-start.d/53w3m-init.el

ユーザー単位で設定ファイルに変更を加えたい場合は、上記設定ファイルを
~/ へコピーして ~/.emacs.my.el から読み込む等してください。

%prep
%if %{cvs}
%setup  -n emacs-%{origname}-%{origver}cvs%{cvsdate}
%else
%setup  -n emacs-%{origname}-%{origver}
%endif

%patch10 -p1

%build

autoconf
chmod 755 ./configure*
./configure --prefix=%{_prefix} --infodir=%{_infodir}
rm -f config.cache

# create info files
make info

%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}%{_datadir}/emacs/site-lisp/%{origname}/attic
%__mkdir_p ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{origname}/shimbun
%__mkdir_p ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{origname}/doc
%__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}%{_datadir}/pixmaps/%{origname}-el
%__mkdir_p ${RPM_BUILD_ROOT}%{_infodir}


#
# install el files et al
# 

install -m 644 *.el ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{origname}
install -m 644 attic/*.el \
    ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{origname}/attic
install -m 644 shimbun/*.el \
    ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{origname}/shimbun

install -m 644 icons30/*.xpm ${RPM_BUILD_ROOT}%{_datadir}/pixmaps/w3m-el

install -m 644 Makefile* aclocal.m4 config* install-sh mkinstalldirs %{SOURCE3} \
    ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{origname}
install -m 755 config.status configure \
    ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{origname}

install -m 755 doc/* \
    ${RPM_BUILD_ROOT}%{_datadir}/emacs/site-lisp/%{origname}/doc


#
# install info files
#

make install-info infodir=%{buildroot}%{_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}

for i in %{w3m_info_list}; do
    if [ -f %{_infodir}/${i}.gz ]; then
	/sbin/install-info %{_infodir}/${i}.gz %{_infodir}/dir \
	    --section="Emacs"
    fi
done


%preun

if [ "$1" = 0 ]; then

%_emacsenPackageRemove %{origname}

%_removeemacsenlist %{origname}

for i in %{w3m_info_list}; do
    if [ -f %{_infodir}/${i}.gz ]; then
	/sbin/install-info --delete %{_infodir}/${i}.gz %{_infodir}/dir \
	    --section="Emacs"
    fi
done

fi


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


%files
%defattr(-,root,root)
#%doc COPYING ChangeLog FAQ* README* TIPS*
%doc COPYING ChangeLog README*

%{_datadir}/pixmaps/w3m-el
%{_datadir}/emacs/site-lisp/%{origname}/
%{_libdir}/emacsen-common/packages/install/%{origname}
%{_libdir}/emacsen-common/packages/remove/%{origname}
%{_infodir}/*.info*
 

%changelog
* Thu Apr 21 2011 IWAI, Masaharu <iwai@alib.jp> 1.4.437-1.cvs20110421
- new upstream cvs head
- add Requires: apel: <BTS:VineLinux:1014>
- replace BuildRequires: tetex to texlive
- drop defining prereq_ge macro: using Requires(post) tag
- update Packager syntax

* Fri Feb 19 2010 IWAI, Masaharu <iwai@alib.jp> 1.4.148-7.cvs20100124
- update %%files: politely for info files

* Thu Feb  4 2010 IWAI, Masaharu <iwai@alib.jp> 1.4.148-6.cvs20100124
- drop info files: Source20-26
- create info files in %%build section
- update %%install section: using "install-info" target for Makefile
- add BuildRequires: texinfo tetex

* Mon Jan 25 2010 IWAI, Masaharu <iwai@alib.jp> 1.4.148-5.cvs20100124
- update from CVS
- update w3m-install.sh
  - change target for Makefile: 'make lisp' and 'make install-lisp'
- drop no-make-info patch (Patch20)
- copying doc directory

* Sat Jan 23 2010 Munehiro Yamamoto <munepi@vinelinux.org> 1.4.148-4
- added %%patch20 -p1 -b .info in %%setup
  - In fact, for 1.4.148-3, emacs-w3m-1.4.148-no-make-info.patch was NOT applied
- updated emacs-w3m-1.4.148-no-make-info.patch
  - dropped doc/Makefile from AC_OUTPUT in configure.in
  - do not copy doc/* files (info)
- updated w3m-install.sh
  - removed autom4te.cache directory

* Fri Dec 04 2009 Munehiro Yamamoto <munepi@vinelinux.org> 1.4.148-3
- dropped Requires(post): texinfo tetex
  - applied emacs-w3m-1.4.148-no-make-info.patch
  - contained info files
  - modified w3m-install.el

* Sun Jul 19 2009 Munehiro Yamamoto <munepi@vinelinux.org> 1.4.148-2
- s/BuildPreReq/BuildRequires/
- added Requires(post): texinfo
- added Requires(post): tetex
- added BuildRequires: emacs

* Sat Aug 16 2008 Shu KONNO <owa@bg.wakwak.com> 1.4.148-1vl5
- applied new versioning policy, spec in utf-8
- added %%define _libdir %%{_prefix}/lib

* Sun Jan 14 2007 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.4.148-0vl2
- update(CVS)
- Modded w3m-install.sh(mv w3m-bitmap.el w3m-bitmap.el.BAK)

* Wed Jan 10 2007 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.4.148-0vl1
- update(CVS)
- use autoconf
- Modded w3m-install.sh(rm -rm %%{ELDIR}/*.elc, and exec autoconf)
- w3m-bitmap.el is rename on compile(oldfile)

* Mon Sep 11 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.4.4-0vl3
- changed Group to Appliations/Editors/Emacs <BTS:VineLinux:163>

* Tue Sep 20 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 1.4.4-0vl2
- modified w3m-{install,remove}.sh

* Tue Sep 20 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 1.4.4-0vl1
- new upstream release

* Mon Dec 13 2004 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.4.3-0vl2
- rebuilt for flim-1.14.7

* Wed Sep  1 2004 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.4.3-0vl1
- updated to new upstream version
- patch for Vinelinux Errata3x

* Thu Jul 15 2004 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.4.2-0vl1
- updated to new upstream version

* Thu Jul  8 2004 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.4.1-0vl1
- updated to new upstream version
- add %{description} -l ja

* Tue Jun 29 2004 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.4.1-0vl0.rc1
- updated to new upstream version(1.4.1rc1)
- Modded w3m-install.sh for XEmacs(add --with-addpath=${APELPATH})
- Use icons30

* Sat Jul 19 2003 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.3.6-0vl1
- updated to new upstream version

* Sun Jul 13 2003 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.3.5-0vl2
- Modified w3m-remove.sh

* Wed Jul  9 2003 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 1.3.5-0vl1
- updated to new upstream version
- Add %{SOURCE3}

* Tue Dec 10 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.3.3-0vl1
- updated to new upstream version

* Fri Sep 13 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.3.1-0vl1
- updated to new upstream version

* Mon Mar 18 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.2.6-0vl1
- updated to new upstream version

* Sat Jan 19 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.2.4-0vl1
- updated to new upstream version

* Wed Jan 02 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.2.3-0vl2
- installing shimbun directory under w3m directory is no good,
  especially for xemacs. Now w3m-{install,remove}.sh rewritten to
  conventional style.

* Sun Dec 30 2001 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.2.3-0vl1
- updated to new upstream release

* Sun Dec 30 2001 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.2.2-0vl3
- w3m-install.sh modified a little (echo messages, emu directory et al)
- added Patch10 to set default icon directory (if null)

* Sun Dec 30 2001 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.2.2-0vl2
- PreReq flim-el -> flim
- spec file cleaned up

* Sun Dec  9 2001 Kazuhisa TAKEI<takei@vinelinux.org> 1.2.2-0vl1
- add %doc
- upstream upgrade 

* Sun Dec  9 2001 Kazuhisa TAKEI<takei@vinelinux.org>
- initial package
