%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}
%define name   expat
%define version 2.0.1
%define release 8%{?_dist_release}

Summary:	Expat is an XML 1.0 parser written in C
Summary(ja):	C で書かれた XML 1.0 パーサ
Name:		%{name}
Version:	%{version}
Release:	%{release}
License:	MIT/X
Group:		Applications/Text
URL:            http://www.libexpat.org/
Source:         http://download.sourceforge.net/expat/%{name}-%{version}.tar.gz
Patch100:	expat-2.0.1-CVE-2009-3560-revised.patch
Patch110:	expat-2.0.1_CVE-2009-3720.patch

BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root
Requires:	lib%{name} = %{version}-%{release}
BuildRequires:	libtool

Vendor: Project Vine
Distribution: Vine Linux

%description
This is Expat, a C library for parsing XML, written by James Clark.
Expat is a stream-oriented XML parser.  This means that you register
handlers with the parser before starting the parse.  These handlers
are called when the parser discovers the associated structures in the
document being parsed.  A start tag is an example of the kind of
structures for which you may register handlers.

%package -n lib%{name}
Summary:	Runtime library of expat
Summary(ja):	Expat のための実行ライブラリ
Group:		System Environment/Libraries


%description -n lib%{name}
This package contains the runtime, shared library of expat, the C
library for parsing XML.

%description -n lib%{name} -l ja
Expat を動作させるために必用となるライブラリです．

%package devel
Summary:	Development environment for the expat XML parser
Summary(ja):	expat XML パーサ用開発環境
Group:		Development/Libraries
Requires:	lib%{name} = %{version}-%{release}

%description devel
Development environment for the expat XML parser

%description devel -l ja
expat XML パーサ用開発環境です．

## to build compat32 for x86_64 architecture support
%package -n compat32-lib%{name}
Summary:	Runtime library of expat
Summary(ja):	Expat のための実行ライブラリ
Group:		System Environment/Libraries
Requires:	lib%{name} = %{version}-%{release}

%description -n compat32-lib%{name}
This package contains the runtime, shared library of expat, the C
library for parsing XML.

%description -n compat32-lib%{name} -l ja
Expat を動作させるために必用となるライブラリです．

%package -n compat32-%{name}-devel
Summary:	Development environment for the expat XML parser
Summary(ja):	expat XML パーサ用開発環境
Group:		Development/Libraries
Requires:	%{name}-devel = %{version}-%{release}
Requires:	compat32-lib%{name} = %{version}-%{release}

%description -n compat32-%{name}-devel
Development environment for the expat XML parser

%description -n compat32-%{name}-devel -l ja
expat XML パーサ用開発環境です．

%prep
%setup -q
%patch100 -p1 -b .CVE-2009-3560
%patch110 -p1 -b .CVE-2009-3720

%build
export CFLAGS="$RPM_OPT_FLAGS -fPIC"
%configure --enable-shared
make %{?_smp_mflags}

%install
rm -rf $RPM_BUILD_ROOT

rm -f examples/*.dsp
chmod 644 README COPYING Changes doc/* examples/*

make DESTDIR=$RPM_BUILD_ROOT install
rm -f $RPM_BUILD_ROOT/%{_libdir}/libexpat.la

%clean
rm -rf $RPM_BUILD_ROOT

%post -n lib%{name} -p /sbin/ldconfig

%postun -n lib%{name} -p /sbin/ldconfig

%post -n compat32-lib%{name} -p /sbin/ldconfig

%postun -n compat32-lib%{name} -p /sbin/ldconfig

%files
%defattr(-,root,root) 
%doc COPYING Changes README
%{_bindir}/xmlwf
%{_mandir}/man1/xmlwf.1*

%files -n lib%{name}
%defattr(-,root,root)
%doc COPYING Changes README
%{_libdir}/libexpat.so.*

%files devel
%defattr(-,root,root)
%doc COPYING Changes README doc/* examples
%{_includedir}/*
%{_libdir}/libexpat.a
%{_libdir}/libexpat.so

## to build compat32 for x86_64 architecture support
%if %{build_compat32}
%files -n compat32-lib%{name}
%defattr(-,root,root)
%{_libdir}/libexpat.so.*

%files -n compat32-%{name}-devel
%defattr(-,root,root)
%{_libdir}/libexpat.a
%{_libdir}/libexpat.so
%endif

%changelog
* Tue Apr 26 2011 IWAI, Masaharu <iwai@alib.jp> 2.0.1-8
- update patch100 to regrassion fix (same as debian bug #561658)
- add Vendor and Distribution tags

* Sun Apr 17 2011 Shu KONNO <owa@bg.wakwak.com> - 2.0.1-7
- rebuilt with rpm-4.8.1-3

* Fri Feb 12 2010 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.0.1-6
- rebuilt with gcc-4.4.3-3 on ppc

* Mon Feb  1 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.0.1-5
- rebuilt with new toolchains (for VineSeed)

* Tue Dec 15 2009 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.0.1-4
- add patch110 for fix CVE-2009-3720 (xml parser)

* Sat Dec 12 2009 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.0.1-3
- add Patch100 for fix CVE-2009-3560 (xml parser)

* Sat Jul 11 2009 NAKAMURA Kenta <kenta@vinelinux.org> 2.0.1-2
- added Requires: tag to compat32-* sub-packages.
- removed unnecessary %%configure CC='gcc -m32' option

* Sat Jul 26 2008 Shu KONNO <owa@bg.wakwak.com> 2.0.1-1vl5
- applied new versioning policy and spec in utf-8

* Mon Feb 25 2008 NAKAMURA Kenta <kenta@vinelinux.org> 2.0.1-0vl2
- removed %%if !%%{build_compat32} case condition

* Mon Feb 18 2008 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 2.0.1-0vl1
- new upstream release
- drop Patch0
- drop .la
- chmod 644 the documentation
- strip DSP files from examples
- update description and drop description-ja
- add -fPIC

* Fri Sep 07 2007 Shu KONNO <owa@bg.wakwak.com> 1.95.8-0vl6
- rebuilt

* Mon Feb 06 2006 Shu KONNO <owa@bg.wakwak.com> 1.95.8-0vl5
- moved macros _lib to /usr/lib/rpm/rpmrc or macros files

* Thu Feb 02 2006 Shu KONNO <owa@bg.wakwak.com> 1.95.8-0vl4
- added compat32* packages for x86_64 architecture support

* Tue Feb 15 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 1.95.8-0vl3
- add missing header file (expat_external.h) to %%files.

* Tue Feb 08 2005 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.95.8-0vl2
- updated/revised Patch1 (%%install will fail without this patch)

* Tue Feb 08 2005 Satoshi MACHINO <machino@vinelinux.org> 1.95.8-0vl1
- new upstream release
	-- dropped patch1

* Fri Jan 30 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.95.7-1vl1
- updated to 1.95.7 
- changed URL and Group
- fixed License to MIT/X (based on rpm package at sourceforge)

* Thu Apr 17 2003 IWAI Masaharu <iwai@alib.jp> 1.95.6-0vl1
- version up to 1.95.6
- drop expat-xmlwf-dynamiclink.patch (Patch0)
- add expat-1.95.6-mandir.patch for installing manpage (Patch0)
- add manpage (xmlwf.1)

* Mon Mar 18 2002 IWAI Masaharu <iwaim@cc.mbn.or.jp> 1.95.2-0vl3
- fixed license ( s/MPL or GPL/distributable/ )
- use License tag

* Sun Oct 07 2001 akira yamada <akira@vinelinux.org> 1.95.2-0vl2
- new sub-package libexpat.
- added BuildPreReq: libtool

* Sat Oct 06 2001 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.95.2-0vl1
- updated to 1.95.2 release

* Sun Jun 17 2001 MATSUBAYASHI 'Shaolin' Kohji <shaolin@vinelinux.org>
- 1.95.1-3vl1
- based on 1.95.1-3mdk from Mandrake 8.0
- added Japanese summary and description
- modified spec macros for Vine

* Thu Feb 15 2001  Daouda Lo <daouda@mandrakesoft.com> 1.95.1-3mdk
- real version is 1.95.1 
- reenable optimisations 

* Thu Feb 15 2001  Daouda Lo <daouda@mandrakesoft.com> 1.95-1mdk
- release .

* Sun Jan 07 2001 David BAUDENS <baudens@mandrakesoft.com> 1.1-2mdk
- Don't try to use optimizations
- Bzip2 sources

* Mon Nov 20 2000 Frederic Lepied <flepied@mandrakesoft.com> 1.1-1mdk
- first version
