%define	name	jbigkit
%define	version	2.0
%define	release	1%{?_dist_release}
%define sover %(echo %version |cut -d. -f1)

Name:		%{name}
Summary:	The JBIG Kit
Version:	%{version}
Release:	%{release}
License:	GPL
Source0:	http://www.cl.cam.ac.uk/~mgk25/download/jbigkit-%{version}.tar.gz
URL:		http://www.cl.cam.ac.uk/~mgk25
Group:		Applications/Graphics
BuildRoot:	%{_tmppath}/%{name}-%{version}-buildroot
Requires:       libjbig = %{version}


%description
JBIG is a highly effective lossless compression algorithm for bi-level
images (one bit per pixel), which is particularly suitable for scanned
document pages.

%package -n libjbig
Summary: Shared library for JBIG
Group: System Environment/Libraries

%description -n libjbig
JBIG is a highly effective lossless compression algorithm for bi-level
images (one bit per pixel), which is particularly suitable for scanned
document pages.


%package -n libjbig-devel
Summary: Header files and static library for development with JBIG
Group: Development/Libraries
Requires: libjbig = %{version}

%description -n libjbig-devel
This package is only needed if you plan to develop or compile
applications which requires the libjbig library.

%prep
%setup -q -n %{name}

%build
# First, build shared library.
pushd libjbig
%ifarch x86_64 ppc ppc64
make libjbig.a CFLAGS="$RPM_OPT_FLAGS -fPIC"
%else
make libjbig.a CFLAGS="$RPM_OPT_FLAGS"
%endif
gcc -shared -o libjbig.so.%version -Wl,-soname=libjbig.so.%sover `ar t libjbig.a`
ln -sf libjbig.so.%version libjbig.so.%sover
ln -sf libjbig.so.%version libjbig.so
make clean
popd

# Second, build all the rest.
make CCFLAGS="$RPM_OPT_FLAGS -fPIC -DPIC"
#make test
LD_LIBRARY_PATH=../libjbig make test
#mv -f libjbig/jbig.doc libjbig/jbig.txt

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_bindir} \
    $RPM_BUILD_ROOT%{_includedir} \
    $RPM_BUILD_ROOT%{_libdir} \
    $RPM_BUILD_ROOT%{_mandir}/man1

install -m 755 pbmtools/jbgtopbm $RPM_BUILD_ROOT%{_bindir}
install -m 755 pbmtools/pbmtojbg $RPM_BUILD_ROOT%{_bindir}
install -m 644 pbmtools/jbgtopbm.1 $RPM_BUILD_ROOT%{_mandir}/man1
install -m 644 pbmtools/pbmtojbg.1 $RPM_BUILD_ROOT%{_mandir}/man1
install -m 755 libjbig/libjbig.a $RPM_BUILD_ROOT%{_libdir}
install -m 755 libjbig/libjbig.so.%{version} $RPM_BUILD_ROOT%{_libdir}
install -m 644 libjbig/jbig.h $RPM_BUILD_ROOT%{_includedir}

# symbolic link
cd $RPM_BUILD_ROOT%{_libdir}
ln -sf libjbig.so.%version libjbig.so.%sover
ln -sf libjbig.so.%version libjbig.so

%post -n libjbig -p /sbin/ldconfig

%postun -n libjbig -p /sbin/ldconfig

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc ANNOUNCE COPYING INSTALL TODO
%attr(755,root,root) %{_bindir}/*
%attr(644,root,root) %{_mandir}/man1/*

%files -n libjbig
%defattr(-,root,root)
%{_libdir}/*.so.*

%files -n libjbig-devel
%defattr(-,root,root)
%doc ANNOUNCE COPYING INSTALL TODO libjbig/jbig.txt
%attr(644,root,root) %{_includedir}/*.h
%{_libdir}/*.so
%{_libdir}/*.a

%changelog
* Sat Oct 04 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.0-1
- new upstream release

* Sun Sep 28 2008 Shu KONNO <owa@bg.wakwak.com> 1.6-1vl5
- applied new versioning policy

* Thu Dec 20 2007 Shu KONNO <owa@bg.wakwak.com> 1.6-0vl2
- added gcc option -fPIC in make

* Sun Sep 26 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.6-0vl1
- updated 1.6
- changed Group:
- added Requires: libjbig to jbig, libjbig-devel packages

* Thu May 13 2004 Satoshi MACHINO <machino@vinelinux.org> 1.5-0vl2
- fixed dynamic link of libjbig.so

* Thu May 13 2004 Satoshi MACHINO <machino@vinelinux.org> 1.5-0vl1
- initial release

