Name:    ming
Summary: A library for generating Macromedia Flash files
Summary(ja): Macromedia Flash ファイル生成ライブラリ
Version: 0.4.5
Release: 1%{?_dist_release}

Group:   System Environment/Libraries
License: LGPLv2+
URL:     http://www.libming.org/FrontPage

Source0: http://downloads.sourceforge.net/project/ming/Releases/ming-%{version}.tar.bz2
# make ming-config multilib-compatible
Patch0: ming-multilib.patch
# install perl modules to vendorarch dir and link dynamically with libming.so
Patch1: ming-perl.patch

# To build with giflib-4.2.x
Patch100: ming-0.4.5-gif-error.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: bison
BuildRequires: flex
BuildRequires: freetype2-devel
BuildRequires: giflib-devel
BuildRequires: libpng-devel
BuildRequires: perl
BuildRequires: php5-devel
BuildRequires: python-devel
BuildRequires: swig
BuildRequires: tcl
BuildRequires: zlib-devel

%description
Ming is a library for generating Macromedia Flash files (.swf), written in C,
and includes useful utilities for working with .swf files. 

%package devel
Summary:    A library for generating Macromedia Flash files - development files
Summary(ja): %{name} の開発用ファイル
Group:      Development/Libraries
Requires:   %{name} = %{version}-%{release}

%description devel
The ming-devel package includes the static libraries,
header files, and developer docs for the ming package.

%package python
Summary:    Ming Python wrapper
Group:      Development/Libraries
Requires:   %{name} = %{version}-%{release}

%description python
%{summary}

%package tcl
Summary:    Ming Tcl wrapper
Group:      Development/Libraries
Requires:   %{name} = %{version}-%{release}
Requires:   tcl

%description tcl
%{summary}

%package perl
Summary:    Ming Perl wrapper
Group:      Development/Libraries
Requires:   perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
Provides:   perl-SWF = %{version}-%{release}

%description perl
%{summary}

%package php
Summary:    Ming PHP wrapper
Group:      Development/Libraries
Requires:   %{name} = %{version}-%{release}
Requires:   php5

%description php
%{summary}

%prep
%setup -q
%patch0 -p1 -b .multilib
%patch1 -p1 -b .p
%patch100 -p2 -b .p

pushd src
chmod -x actioncompiler/{compile,listaction}.* blocks/{matrix,outputblock}.* \
         displaylist.* position.*
popd
iconv -f iso8859-1 -t utf8 -o ChangeLog.utf8 ChangeLog && \
touch -r ChangeLog ChangeLog.utf8 && \
mv ChangeLog.utf8 ChangeLog

# force rebuild of python bindings
rm py_ext/ming_wrap.c

%build
%configure \
    --disable-static \
    --enable-python \
    --enable-tcl \
    --enable-php \
    --enable-perl \
    --with-pic \

sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
make V=1 %{?_smp_mflags}

%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT \
	pkgconfigdir=%{_libdir}/pkgconfig \
	docdir=$RPM_BUILD_ROOT%{_docdir}/%{name}

find $RPM_BUILD_ROOT -type f -name perllocal.pod -exec rm -f {} ';'
find $RPM_BUILD_ROOT -type d -depth -exec rmdir {} 2>/dev/null ';'
chmod 755 $RPM_BUILD_ROOT%{perl_vendorarch}/auto/SWF/*.so
make -C ./docs/man mandir=$RPM_BUILD_ROOT%{_mandir} install-man1
make -C ./docs/man mandir=$RPM_BUILD_ROOT%{_mandir} install-man3

%post -p /sbin/ldconfig
%post python -p /sbin/ldconfig
%post tcl -p /sbin/ldconfig
%post perl -p /sbin/ldconfig
%post php -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%postun python -p /sbin/ldconfig
%postun tcl -p /sbin/ldconfig
%postun perl -p /sbin/ldconfig
%postun php -p /sbin/ldconfig

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

%files
%defattr(-,root,root)
%doc README AUTHORS COPYING ChangeLog
%{_bindir}/*
%{_libdir}/libming*.so.*
%{_mandir}/man1/*

%files devel
%defattr(-, root, root)
%{_includedir}/*
%{_libdir}/libming.so
%{_libdir}/pkgconfig/*.pc
%{_mandir}/man3/*
%exclude %{_mandir}/man3/SWF*.3pm*
%exclude %{_libdir}/*.la

%files python
%defattr(-, root, root)
%{python_sitearch}/*.so
%{python_sitearch}/*.py*
%{python_sitearch}/mingc-%{version}-py%{pyver}.egg-info

%files tcl
%defattr(-, root, root)
%{_libdir}/%{name}/tcl/*.so
%exclude %{_libdir}/%{name}/tcl/*.la

%files perl
%defattr(-, root, root)
%{_libdir}/perl5/*
%{_mandir}/man3/SWF*.3pm*

%files php
%defattr(-, root, root)
%{_libdir}/php5/*

%changelog
* Fri Dec 12 2014 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 0.4.5-1
- updated to 0.4.5
- added Patch0, 1 and 100
- built with libpng 1.6.12, giflib 4.2.3 and perl 5.16.3
- updated URL

* Sun Sep 26 2010 Shu KONNO <owa@bg.wakwak.com> 0.4.3-2
- rebuilt with rpm-4.8.1 for pkg-config

* Tue Feb 16 2010 Shu KONNO <owa@bg.wakwak.com> 0.4.3-1
- updated ming to 0.4.3
- added %{name}-python, -tcl, -perl, -php sub packages
- added BR: swig python-devel php-devel

* Sat Oct 04 2008 Shu KONNO <owa@bg.wakwak.com> 0.4.2-1vl5
- updated ming to 0.4.2
- added tags: BuildRequires Requires
- added sub package: ming-devel
- added script at %%clean 
- applied new versioning policy, spec in utf-8

* Wed Sep 22 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 0.2a-4vl3
- fixed args type of addString function (Patch1)
- added Japanese Summary

* Sat May 15 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 0.2a-4vl2
- removed Vendor: tag
- fixed post and postun section

* Sat May 15 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 0.2a-4vl1
- rebuild for Vine Linux
- based on TLD 10, but removed Serial:

* Thu Apr 24 2003 Noriyuki Suzuki <noriyuki@turbolinux.co.jp>
- modified spec file for x86_64.

* Thu Feb 28 2002 Kiichiro NAKA <knaka@turbolinux.co.jp>
- I have gotten SRPM from http://rpms.arvin.dk/ming/source/

* Tue Aug 21 2001 Troels Arvin <troels@arvin.dk>
  [0.2a-2.arvin]
- Add Hansuck Jo's listmp3.c patch.
- Build and include some of the utils.

* Mon Aug 20 2001 Troels Arvin <troels@arvin.dk>
  [0.2a-1.arvin]
- Uses new source version.

* Sat Apr 14 2001 Troels Arvin <troels@arvin.dk>
  [0.1.1-3.arvin]
- Added distribution to release-tag.

* Sat Apr 14 2001 Troels Arvin <troels@arvin.dk>
  [0.1.1-2.arvin]
- Fixed a permission problem for the documentation 
  area.
* Sat Apr 14 2001 Troels Arvin <troels@arvin.dk>
  [0.1.1-1.arvin]
- Rebuilt with new source version.
* Mon Mar 19 2001 Troels Arvin <troels@arvin.dk>
  [0.1.0-1.arvin]
- Rebuilt with new source version. Patches shouldn't be need
  any more.
* Mon Jan 29 2001 Troels Arvin <troels@arvin.dk>
  [0.0.9c-1.arvin]
- First Ming RPM package. Currently, the RPM doesn't include
  anyting but the shared library and the C-oriented include
  file. None of the wrappers for other languages are handled by this
  RPM, currently. Also, none of the utilities are included in the
  package yet.
