%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}
%define LIBVER 62.0.0

Summary: A library for manipulating JPEG image format files.
Summary(ja): JPEG 形式画像ファイルを扱う為のライブラリ
Name: libjpeg
Version: 6b
Release: 40%{?_dist_release}
License: distributable
Group: System Environment/Libraries
Source0: ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.bz2
Patch0: libjpeg-6b-arm.patch
Patch1: jpeg-c++.patch
Patch2: libjpeg-shared.patch
Patch3: libjpeg-rpath.patch
Patch4: libjpeg-x86_64.patch
URL: http://www.ijg.org/
Buildroot: %{_tmppath}/%{name}-%{version}-root

%package devel
Summary: Development tools for programs which will use the libjpeg library.
Summary(ja): libjpeg ライブラリを使うプログラム向け開発ツール
Group: Development/Libraries
Requires: libjpeg = %{version}-%{release}

%package static
Summary: Static library of libjpeg
Summary(ja): libjpeg のスタティックライブラリ
Group: Development/Libraries
Requires: libjpeg-devel = %{version}-%{release}

%description
The libjpeg package contains a library of functions for manipulating
JPEG images, as well as simple client programs for accessing the
libjpeg functions.  Libjpeg client programs include cjpeg, djpeg,
jpegtran, rdjpgcom and wrjpgcom.  Cjpeg compresses an image file into
JPEG format.  Djpeg decompresses a JPEG file into a regular image
file.  Jpegtran can perform various useful transformations on JPEG
files.  Rdjpgcom displays any text comments included in a JPEG file.
Wrjpgcom inserts text comments into a JPEG file.

%description -l ja
libjpeg パッケージには JPEG 画像を扱う為に必要なライブラリと，
libjpeg 関数にアクセスする為の簡単なクライアントプログラムが
収められています．libjpeg クライアントプログラムには cjpeg, djpeg,
jpegtran, rdjpgcom, wrjpgcom があります．cjpeg は画像ファイルを
JPEG 形式に圧縮します．djpeg は JPEG ファイルを通常の画像ファイルに
展開します．jpegtran は JPEG ファイルに様々な変換を施すことが出来ます．
rdjpgcom は JPEG ファイルに含まれているテキスト形式のコメントを表示し，
wrjpgcom は JPEG ファイルにテキスト形式のコメントを追加します．

%description devel
The libjpeg-devel package includes the header files and static libraries
necessary for developing programs which will manipulate JPEG files using
the libjpeg library.

If you are going to develop programs which will manipulate JPEG images,
you should install libjpeg-devel.  You'll also need to have the libjpeg
package installed.

%description devel -l ja
libjpeg-devel パッケージには，libjpeg ライブラリを使って JPEG ファイルを
扱うプログラムを開発するのに必要なヘッダファイルとスタティックライブラリが
収められています．

JPEG 画像を扱うプログラムを開発する際には，libjpeg-devel を
インストールして下さい．同時に libjpeg パッケージもインストールする
必要があります．

%description static
The libjpeg-static package contains the statically linkable version of libjpeg.
Linking to static libraries is discouraged for most applications, but it is 
necessary for some boot packages.


## to build compat32 for x86_64 architecture support
%package -n compat32-%{name}
Summary: A library for manipulating JPEG image format files.
Summary(ja): JPEG 形式画像ファイルを扱う為のライブラリ
Group: Development/Libraries
Requires: libjpeg = %{version}-%{release}
%description -n compat32-%{name}
The libjpeg package contains a library of functions for manipulating
JPEG images, as well as simple client programs for accessing the
libjpeg functions.  Libjpeg client programs include cjpeg, djpeg,
jpegtran, rdjpgcom and wrjpgcom.  Cjpeg compresses an image file into
JPEG format.  Djpeg decompresses a JPEG file into a regular image
file.  Jpegtran can perform various useful transformations on JPEG
files.  Rdjpgcom displays any text comments included in a JPEG file.
Wrjpgcom inserts text comments into a JPEG file.

%package -n compat32-%{name}-devel
Summary: Development tools for programs which will use the libjpeg library.
Summary(ja): libjpeg ライブラリを使うプログラム向け開発ツール
Group: Development/Libraries
Requires: compat32-libjpeg = %{version}-%{release}
Requires: libjpeg-devel = %{version}-%{release}

%description -n compat32-%{name}-devel
The libjpeg-devel package includes the header files and static libraries
necessary for developing programs which will manipulate JPEG files using
the libjpeg library.

If you are going to develop programs which will manipulate JPEG images,
you should install libjpeg-devel.  You'll also need to have the libjpeg
package installed.

%prep
%setup -q -n jpeg-6b
%patch0 -p1 -b .arm
%patch1 -p1 -b .c++
%patch2 -p1 -b .ppcshared
%patch3 -p1
%patch4 -p1

%build
%configure --enable-shared --enable-static
make libdir=%{_libdir} %{?_smp_mflags}
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD make test

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_bindir}
mkdir -p $RPM_BUILD_ROOT%{_libdir}
mkdir -p $RPM_BUILD_ROOT%{_includedir}
mkdir -p $RPM_BUILD_ROOT%{_mandir}/man1
%makeinstall
# Work around the broken makefiles...
mv $RPM_BUILD_ROOT%{_mandir}/*.1 $RPM_BUILD_ROOT%{_mandir}/man1
strip -R .comment $RPM_BUILD_ROOT%{_bindir}/* || :

rm -f $RPM_BUILD_ROOT%{_libdir}/*.la

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

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

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


%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc usage.doc README
%{_bindir}/*
%{_libdir}/libjpeg.so.*
%{_mandir}/*/*

%files devel
%defattr(-,root,root)
%doc libjpeg.doc coderules.doc structure.doc wizard.doc example.c
%{_libdir}/*.so
%{_includedir}/*

%files static
%defattr(-,root,root)
%{_libdir}/*.a
%{_includedir}/*

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

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

%changelog
* Sat Feb 13 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 6b-40
- rebuild with new environment

* Mon May 04 2009 NAKAMURA Kenta <kenta@vinelinux.org> 6b-39
- do not remove libjpeg.a even if %%{build_compat32} is defined

* Fri Mar 27 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 6b-38
- split static library to -static subpackge
  - libjpeg-static is needed by tuxonice-userui

* Mon Dec 29 2008 Shu KONNO <owa@bg.wakwak.com> 6b-37
- spec in utf-8

* Thu May 01 2008 NAKAMURA Kenta <kenta@vinelinux.org> 6b-36
- updated %%if %%{build_compat32} case related statements

* Mon Apr 28 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 6b-35
- applied new versioning policy
- removed *.la files from devel package

* Sat Aug 26 2006 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 6b-34vl4
- add Requires: compat32-libjpeg instead of libjpeg (compat32)
- fix typo in changelog

* Sun Feb 12 2006 Shu KONNO <owa@bg.wakwak.com> 6b-34vl3
- fixed %postun (missing to build as scriptlet by invalid comment)

* Sun Feb 05 2006 Shu KONNO <owa@bg.wakwak.com> 6b-34vl2
- added compat32-* packages for x86_64 architecture support
- added libjpeg-x86_64.patch by nakamura
- added script for compat32-* before configuring

* Sun Sep 18 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 6b-34vl1
- added Pacth2 and 3 from Fedora
  * Tue Sep 23 2003 Florian La Roche <Florian.LaRoche@redhat.de>
  - do not set rpath
  * Thu Feb 13 2003 Elliot Lee <sopwith@redhat.com> 6b-27
  - Add libjpeg-shared.patch to fix shlibs on powerpc
- added URL

* Mon Apr  7 2003 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 6b-21vl2
- rebuild

* Fri Dec 06 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 6b-20vl1
- based on 6b-20 from Rawhide and built for Vine Linux
- added Japanese summary and description

* Fri Jun 21 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Thu May 23 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Thu Jan 31 2002 Bernhard Rosenkraenzer <bero@redhat.com> 6b-19
- Fix bug #59011

* Mon Jan 28 2002 Bernhard Rosenkraenzer <bero@redhat.com> 6b-18
- Fix bug #58982

* Wed Jan 09 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Tue Jul 24 2001 Bill Nottingham <notting@redhat.com>
- require libjpeg = %%{version}

* Sun Jun 24 2001 Elliot Lee <sopwith@redhat.com>
- Bump release + rebuild.

* Mon Dec 11 2000 Than Ngo <than@redhat.com>
- rebuilt with the fixed fileutils
- use %%{_tmppath}

* Wed Nov  8 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- fix a typo (strip -R .comment, not .comments)

* Thu Jul 13 2000 Prospector <bugzilla@redhat.com>
- automatic rebuild

* Sat Jun 17 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- FHSify
- add some C++ tweaks to the headers as suggested by bug #9822)

* Wed May  5 2000 Bill Nottingham <notting@redhat.com>
- configure tweaks for ia64; remove alpha patch (it's pointless)

* Sat Feb  5 2000 Bernhard Rosenkr舅zer <bero@redhat.com>
- rebuild to get compressed man pages
- fix description
- some minor tweaks to the spec file
- add docs
- fix build on alpha (alphaev6 stuff)

* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> 
- auto rebuild in the new build environment (release 9)

* Wed Jan 13 1999 Cristian Gafton <gafton@redhat.com>
- patch to build on arm
- build for glibc 2.1

* Mon Oct 12 1998 Cristian Gafton <gafton@redhat.com>
- strip binaries

* Mon Aug  3 1998 Jeff Johnson <jbj@redhat.com>
- fix buildroot problem.

* Tue Jun 09 1998 Prospector System <bugs@redhat.com>
- translations modified for de

* Thu Jun 04 1998 Marc Ewing <marc@redhat.com>
- up to release 4
- remove patch that set (improper) soname - libjpeg now does it itself

* Thu May 07 1998 Prospector System <bugs@redhat.com>
- translations modified for de, fr, tr

* Fri May 01 1998 Cristian Gafton <gafton@redhat.com>
- fixed build on manhattan

* Wed Apr 08 1998 Cristian Gafton <gafton@redhat.com>
- upgraded to version 6b

* Wed Oct 08 1997 Donnie Barnes <djb@redhat.com>
- new package to remove jpeg stuff from libgr and put in it's own package
