%define name	TiMidity++
%define ver     2.13.1
%define release	0vl1
%define debug   off
%define tarball %{name}-%{ver}

# if 'make install' can install jman automatically
%define jman_install manual

Summary:	A Realtime MIDI Player
Group:		Applications/Multimedia
License:	GPL
URL:		http://timidity.sourceforge.net/
Source:		%{tarball}.tar.bz2
Patch:		TiMidity++-iro.diff
Name:		%{name}
Version:	%{ver}
Release:	%{release}
Packager:	Hiroaki Irokawa <irorin@terra.dti.ne.jp>
BuildRoot:	%{_tmppath}/%{name}-%{version}-root
Requires:	esound, libvorbis, libogg, XOrg-libs, audiofile
Requires:	Xaw3d, gtk+, glib, tcl, tk, openMotif, slang
BuildPreReq:	esound-devel, libogg-devel, libvorbis-devel
BuildPreReq:	Xaw3d-devel, gtk+-devel, tcl, tk, openMotif-devel
BuildPreReq:	ncurses-devel


%description

  TiMidity has originally been a converter that converts MIDI files to WAV
  audio file. But now TiMidity++ is not only a converter but also the
  real-time player that can play a MIDI file in real time. TiMidity does
  not requires external MIDI instrument module to play MIDI file, performs
  with software power.

  -Od8M -s11025 options will help you if bothered with noisy replay.

  TiMidity++ uses GUS/patch (Glavis Ultrasound) as the voice data to
  play.  You must get GUS/patch files, and make the configuration file.
  You must make the configuration file (*.cfg).  By default,
  timidity.cfg is %{_datadir}/timidity/timidity.cfg.
  Take care if you wanna upgrade from older version.

See %{_defaultdocdir}/%{name}-%{ver}/INSTALL for futher information.

#Now this package is beta version, so take care!

%description -l ja

TiMidity++ は、もともとは MIDI -> WAV コンバータでしたが、
今ではソフトウェア MIDI プレーヤとしての機能を持っています。
MIDI 演奏用のハードウェアは必要ありません。

CPU パワーの少ないマシンでは、-Od8M -s11025 オプションを
付けると音飛びが防げるでしょう。

このパッケージの TiMidity をインストールしただけでは、音がなりません。
演奏するには、GUS の音源ファイルを入手し、設定ファイルである timidity.cfg
を作成しなければなりません。デフォルトでは、
%{_datadir}/timidity/timidity.cfg になります。
アップグレードされる方は気をつけて下さい。

詳細は %{_defaultdocdir}/%{name}-%{ver}/INSTALL.jp を読んで下さい。

#なお、このパッケージはベータ版です。取り扱いに注意しましょう。


%prep
%setup -q -n %{tarball}
%ifnarch sparc
%patch -p1
%endif

%build
if [ %{debug} = "on" ] ; then
  export CFLAGS="$RPM_OPT_FLAGS -g"
else
  export CFLAGS="$RPM_OPT_FLAGS"
fi

# detect whether alsa library is installed
if [ -f /usr/include/linux/asound.h ] ; then
   SOUND="--enable-audio=esd,alsa,oss,vorbis --enable-alsaseq"
else
   SOUND="--enable-audio=esd,oss,vorbis"
fi

./configure --prefix=%{_prefix} --with-elf --with-x --x-includes=/usr/include --x-libraries=/usr/X11R6/%{_lib} \
  $SOUND \
  --with-default-output=default \
  --enable-dynamic=gtk,ncurses,slang,motif,tcltk,emacs,vt100,xaw,xskin \
  --enable-network --enable-server --enable-spectrogram

make


%install

rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_libdir}
#make prefix=$RPM_BUILD_ROOT%{_prefix} install-strip
make prefix=$RPM_BUILD_ROOT%{_prefix} install

if [ %{jman_install} = "manual" ]; then

  # install Japanese manual
  mkdir -p $RPM_BUILD_ROOT%{_mandir}/ja/{man1,man5}
  install -m644 doc/ja_JP.eucJP/timidity.1 $RPM_BUILD_ROOT%{_mandir}/ja/man1/
  install -m644 doc/ja_JP.eucJP/timidity.cfg.5 $RPM_BUILD_ROOT%{_mandir}/ja/man5/
  mkdir -p $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}-%{version}/ja/
  install -m644 doc/ja_JP.eucJP/* $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}-%{version}/ja/

  # install English manual
  mkdir -p $RPM_BUILD_ROOT%{_mandir}/{man1,man5}
  install -m644 doc/C/timidity.1 $RPM_BUILD_ROOT%{_mandir}/man1/
  install -m644 doc/C/timidity.cfg.5 $RPM_BUILD_ROOT%{_mandir}/man5/
  mkdir -p $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}-%{version}/C/
  install -m644 doc/C/* $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}-%{version}/C/
  install -m644 interface/timidity.el $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}-%{version}

fi

# 補足ドキュメント
install -m644 doc/ja_JP.eucJP/* $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}-%{version}/ja/
install -m644 doc/C/* $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}-%{version}/C/
#install -m644 interface/timidity.el $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}-%{version}
#mkdir -p $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}-%{version}
#cp -p interface/timidity.el $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}-%{version}
cp -p interface/interface*.txt interface/timidity.el $RPM_BUILD_ROOT%{_libdir}/timidity

# install cool icon.
mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/pixmaps/timidity/
cp -p interface/pixmaps/*.xpm $RPM_BUILD_ROOT%{_sharedstatedir}/pixmaps/timidity/

# make symlink for Window Maker
cd $RPM_BUILD_ROOT%{_sharedstatedir}/pixmaps/
ln -s timidity/timidity.xpm .


%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root)
%{_mandir}/ja/man1/timidity.1*
%{_mandir}/ja/man5/timidity.cfg.5*
%{_mandir}/man1/timidity.1*
%{_mandir}/man5/timidity.cfg.5*
%doc doc/*
%{_bindir}/timidity
%{_datadir}/pixmaps/timidity.xpm
%{_datadir}/pixmaps/timidity/*.xpm

## if you faced on an error to rebuild or run, please uncomment below.
## maybe for Tcl/Tk, xaw, xskin and gtk...

%{_libdir}/timidity/*


%changelog
* Tue Mar 27 2007 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 2.13.1-0vl1
- update to 2.13.1

* Sun Mar 11 2007 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 2.13.0-0vl3
- rebuild with Xaw3d-1.5E
- add BuildPreReq: ncurses-devel
- change --x-libraries's value from /usr/X11R6/lib to /usr/X11R6/%%{_lib}

* Thu Jul 27 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.13.0-0vl2
- rebuilt with Xaw3d-1.5-17vl3
- s/Copyright/License/
- changed Group to Applications/Multimedia 
- updated build dependancy

* Fri Apr 30 2004 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
- update

* Fri Aug 16 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp> 2.11.3-0vl4
- fix typo (ncurces -> ncurses) thanks Mr. Mickey_U

* Fri Jul 26 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 2.11.3-0vl3
- rebuilt with libvorbis-1.0

* Thu Feb 14 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
- [TiMidity++-2.11.3-0vl2]
- fix %defattr
- Add Requires: XFree86-libs, audiofile, Xaw3d, gtk+, glib, tcl, tk, lesstif, slang

* Fri Jan 18 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
- [TiMidity++-2.11.3-0vl1]
- update.

* Mon Jan 14 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
- [TiMidity++-2.11.2-0vl2]
- Add Requires:	libvorbis, libogg
- Add BuildPreReq: libogg-devel, libvorbis-devel

* Sat Jan 12 2002 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
- [TiMidity++-2.11.2-0vl1]
- update.

* Mon Dec 31 2001 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
- [TiMidity++-2.11.1-0vl1]
- update.

* Thu Dec 27 2001 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
- [TiMidity++-2.11.0-0vl1]
- update.

* Thu Nov 22 2001 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
- [TiMidity++-2.10.4-0vl2]
- Rebuilt(About Tcl/Tk).

* Mon Mar 19 2001 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
  [TiMidity++-2.10.4-0vl1]
- Updated to 2.10.4.

* Sun Mar 11 2001 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
  [TiMidity++-2.10.3-0vl1]
- Updated to 2.10.3.

* Sat Mar 03 2001 MATSUBAYASHI 'Shaolin' Kohji <shaolin@vinelinux.org>
- 2.10.2-0vl3
- always require esound
- disable alsa in case alsa driver/library is not installed

* Thu Jan 13 2001 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
  [TiMidity++-2.10.2-0vl2]
- Use some rpmmacros, Modified Compile Option & man5 data, tcl path.

* Thu Nov  2 2000 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
  [TiMidity++-2.10.2-0vl1]
- Updated to 2.10.2.

* Sat Oct 18 2000 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
  [TiMidity++-2.10.1-0vl1]
- Updated to 2.10.1.

* Sat Sep 16 2000 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
  [TiMidity++-2.10.0-0vl3]
- Updated to 2.10.0.(rebuild without alsa-lib)

* Sat Sep  9 2000 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
  [TiMidity++-2.10.0-0vl2]
- Updated to 2.10.0.(ja_JP.ujis -> ja)

* Wed Sep  6 2000 Hiroaki Irokawa <irorin@terra.dti.ne.jp>
  [TiMidity++-2.10.0-0vl1]
- Updated to 2.10.0.

* Wed Oct  6 1999 Yasuhide OOMORI <dasen@typhoon.co.jp>
  [TiMidity++-2.6.1-1]
- Updated to 2.6.1.

* Fri Sep 23 1999 Yasuhide OOMORI <dasen@typhoon.co.jp>
  [TiMidity++-2.6.0-1]
- Updated to the full release of version 2.6.0.
- Include pixmaps.
- Make symlink for Window Maker.

* Fri Sep 11 1999 Yasuhide OOMORI <dasen@typhoon.co.jp>
  [TiMidity++-2.6.0-0.4.0]
- Updated to the 4th (maybe last?) beta release of version 2.6.0.

* Fri Sep 11 1999 Yasuhide OOMORI <dasen@typhoon.co.jp>
  [TiMidity++-2.6.0-0.3.1]
- Enabled all the interfaces.

* Fri Sep 11 1999 Yasuhide OOMORI <dasen@typhoon.co.jp>
  [TiMidity++-2.6.0-0.3.0]
- Updated to the 3rd beta release of version 2.6.0.
- Added TiMidity.ad, TiMidity-uj.ad to install documents.

* Fri Sep 03 1999 Yasuhide OOMORI <dasen@typhoon.co.jp>
  [TiMidity++-2.6.0-0.2.2]
- Updated to the 2nd beta release of version 2.6.0.

* Mon Aug 23 1999 Yasuhide OOMORI <dasen@typhoon.co.jp>
  [TiMidity++-2.5.0-1]
- Updated to full release of version 2.5.0.
- Modified to install Japanese manuals.

* Mon Aug 23 1999 Yasuhide OOMORI <dasen@typhoon.co.jp>
  [TiMidity++-2.4.1-1]
- First attempt.
