%define buildinfo yes
%define name lilypond
%define iconsdir /usr/share/pixmaps
%define infodir %{_infodir}/%{name}
Summary:	A typesetting system for music notation
Summary(ja):楽譜作成プログラム
Group:		Applications/Publishing
Name:		%{name}
#Version:	2.4.5
Version:	2.12.3
Release:	1%{?_dist_release}
License:	GPLv2
URL:		http://www.lilypond.org/
Source0:	http://download.linuxaudio.org/lilypond/sources/v2.12/%{name}-%{version}.tar.gz
Patch0:		lilypond-platex-2.4.5.patch
BuildRoot:	%{_tmppath}/%{name}-%{version}-root

## from fc11
Patch10:	lilypond-2.11.65-python26.patch
Patch12:	lilypond-2.21.2-gcc44-relocate.patch
Patch13:	lilypond-consts.patch

BuildRequires: t1utils ImageMagick-devel gettext tetex
BuildRequires: gcc-c++
BuildRequires: bison flex m4
BuildRequires: python-devel >= 2.4.0
BuildRequires: mftrace >= 1.1.19
Buildrequires: texinfo >= 4.8
BuildRequires: guile-devel >= 1.8
BuildRequires: ghostscript >= 8.15
BuildRequires: pango-devel >= 1.12.0

BuildRequires: potrace >= 1.3
BuildRequires: netpbm-progs
BuildRequires: xdvik
BuildRequires: ec-fonts-mftraced
Buildrequires: which
BuildRequires: glibc-devel groff
BuildRequires: fontforge

Requires: chkfontpath

%description
LilyPond is a music typesetter.  It produces beautiful sheet music using a
high level description file as input.  Lilypond is part of the GNU project.
 
LilyPond is split into two packages.  The package "lilypond" provides the
core package, containing the utilities for converting the music source
(.ly) files into printable output.  The package "lilypond-documentation" 
provides the full documentation, example .ly files for various features and 
the Mutopia project files (musical equivalent of the Gutenberg project - see
http://www.mutopiaproject.org for details).
 
If you are new to lilypond, you will almost certainly want to install the
"lilypond-documentation" package in addition to the "lilypond" package.

%description -l ja
LilyPond は GNU プロジェクトで開発されている楽譜作成ソフトです。高解像度の
とてもきれいな楽譜を作ることができます。

LiLyPond は2つのパッケージにわかれています。"lilypond"パッケージがメインパッ
ケージ"で、楽譜ソースファイル(.ly)を印刷可能な形式に変換するプログラムが入っ
てます。tex, html等に簡単に楽譜を挿入するための lilypond-book コマンドもあり
ます．(Vine用パッケージでは，platexでの利用も可能に変更してあります．)

"lilypond-documentation" にはマニュアルやいろいろなサンプルファイル(.ly)、
Mutopiaプロジェクトによるいつくかのファイルが入ってます。Mutopia プロジェクト
(musical equivalent of the Gutenberg project)については
http://www.mutopiaproject.orgを見てください。

%package -n liblilypond
Summary: Lilypond libraries
Summary(ja): Lilypond ライブラリ
Group: System Environment/Libraries
Requires: lilypond >= %{version}

%description -n liblilypond
Lilypond libs

%package documentation
Summary: LilyPond documentation, examples and Mutopia files.
Summary(ja): LilyPond のマニュアル, サンプル，Mutopiaファイル
Group: Applications/Documentation
Requires: %{name}

%description documentation
The documentation of LilyPond, both in HTML and PostScript, along with
example input files and the files from the Mutopia project.

%description documentation -l ja
LiLyPond のマニュアルです．HTML ,PostScript, PDF の形式のものがあります．
サンプルや Mutopiaプロジェクトによるファイルも入ってます．

%prep
rm -rf $RPM_BUILD_ROOT

%setup -q
#%patch -p1

# from fc11
%patch10 -p0
%patch12 -p0
#%patch13 -p1

%build
##@ # DO NOT use % { configure } , it hardcodes all paths, runs libtool,
##@ # so we can't do make prefixix=/tmp/ install.
##@ 
##@ # In fact, do not take out the spaces between % and { in the above comment,
##@ # because RPM will gladly do a substitution anyway.
##@ ./configure \
##@ 	--disable-checking \
##@ 	--prefix=%{_prefix} \
##@ 	--libdir=%{_libdir} \
##@ 	--includedir=%{_includedir} \
##@ 	--enable-optimising \
##@ 	;
##@ 
##@ %{__make} all
##@ %{__make} web
##@ %{__make} -C Documentation/user omf

%configure --without-kpathsea --disable-checking --with-ncsb-dir=%{_datadir}/fonts/default/Type1
%{__make}


%install
%{__rm} -rf %{buildroot}
make install DESTDIR=$RPM_BUILD_ROOT package_infodir=%{_infodir} vimdir=%{_datadir}/vim/vim72
chmod +x $RPM_BUILD_ROOT%{_libdir}/%{name}/%{version}/python/midi.so

# Symlink lilypond-init.el in emacs' site-start.d directory
pushd $RPM_BUILD_ROOT%{_datadir}/emacs/site-lisp
mkdir site-start.d
ln -s ../lilypond-init.el site-start.d
popd

# Change encoding to UTF8
pushd $RPM_BUILD_ROOT%{_infodir}
iconv -f iso-8859-1 -t utf-8 music-glossary.info > music-glossary.info.utf8
mv music-glossary.info.utf8 music-glossary.info
sed -e s,lilypond/,, -i *.info
popd


##@ %{makeinstall} MAKE_PFA_FILES=1 local_lilypond_libdir=%{buildroot}/%{_libdir}/%{name}/%{version}
##@ ########## install emacs els
##@ %{__mkdir} -p %{buildroot}%{_datadir}/emacs/site-lisp/site-start.d
##@ %{__install} -m 644 elisp/lilypond-init.el %{buildroot}%{_datadir}/emacs/site-lisp/site-start.d
##@ 
##@ ######### gzip mans
##@ %{__gzip} -9fn %{buildroot}%{_mandir}/man1/*
##@ 
##@ ########## install profiles
##@ #mkdir -p $RPM_BUILD_ROOT%{_prefix}/../etc/profile.d
##@ #cp buildscripts/out/lilypond-profile $RPM_BUILD_ROOT%{_prefix}/../etc/profile.d/lilypond.sh
##@ #cp buildscripts/out/lilypond-login $RPM_BUILD_ROOT%{_prefix}/../etc/profile.d/lilypond.csh
##@ 
##@ ########## move items to texmf dir
##@ %define texmfdir %{buildroot}/usr/share/texmf/
##@ mkdir -p %{texmfdir}/{tex,dvips,fonts}
##@ 
##@ pushd %{buildroot}%{_datadir}/%{name}/%{version}/
##@ for d in dvips tex; do
##@ 	mv $d %{texmfdir}/$d/lilypond
##@ done
##@ 
##@ for d in afm source tfm; do
##@ 	mkdir %{texmfdir}/fonts/$d
##@ 	mv fonts/$d %{texmfdir}/fonts/$d/lilypond
##@ done
##@ popd
##@ 
##@ ########## install docs
##@ %{__make} prefix="%{buildroot}%{_prefix}" \
##@           infodir="%{buildroot}%{_infodir}" \
##@           webdir="%{buildroot}%{_docdir}/lilypond-documentation-%{version}/" web-install
##@ 
##@ %{__rm} -f %{buildroot}/%{_infodir}/dir
##@ %{__gzip} -9fn `find %{buildroot}%{_infodir}/ -name '*.info'`
##@ 
##@ ########## install icons
##@ install -d $RPM_BUILD_ROOT/%{iconsdir}
##@ install -m 644 Documentation/pictures/out-www/lelie-logo.png $RPM_BUILD_ROOT/%{iconsdir}/%{name}.png


%clean
%{__rm} -rf %{buildroot}


%post
##@ touch /tmp/.lilypond-install
##@ %{__rm} `find /var/lib/texmf -name 'feta*pk' -or -name 'feta*tfm' -or -name 'parmesan*pk' -or -name 'parmesan*tfm' -print` /tmp/.lilypond-install
##@ /sbin/install-info %{_infodir}/lilypond/lilypond.info.gz %{_infodir}/dir 
##@ /sbin/install-info %{_infodir}/lilypond/music-glossary.info.gz %{_infodir}/dir 
##@ if [ -x /usr/bin/texhash ]; then /usr/bin/env - /usr/bin/texhash 2> /dev/null ;fi
##@ if [ -x /usr/bin/updmap ]; then /usr/bin/env - /usr/bin/updmap 2> /dev/null;fi
##@ /usr/X11R6/bin/mkfontdir %{_datadir}/lilypond/%{version}/fonts/type1/
##@ /usr/sbin/chkfontpath -q --add=%{_datadir}/lilypond/%{version}/fonts/type1/
/sbin/install-info --info-dir=%{_infodir} %{_infodir}/lilypond.info || :
/sbin/install-info --info-dir=%{_infodir} %{_infodir}/music-glossary.info || :


%preun
##@ if [ $1 = 0 ] ; then
##@   if [ -f /usr/share/lilypond/%{version}/ls-R ]; then
##@     %{__rm} -f /usr/share/lilypond/%{version}/ls-R
##@   fi
##@ fi
##@ if [ $1 = 0 ]; then
##@     /sbin/install-info --delete %{_infodir}/lilypond/lilypond.info.gz %{_infodir}/dir 
##@     /sbin/install-info --delete %{_infodir}/lilypond/music-glossary.info.gz %{_infodir}/dir 
##@ fi
##@ if [ -x /usr/bin/chkfontpath ] ; then
##@     chkfontpath --remove=%{_datadir}/lilypond/%{version}/fonts/type1/
##@ fi
if [ "$1" = "0" ]; then
  /sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/lilypond.info || :
  /sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/music-glossary.info || :
fi


##@ %postun
##@ # %{clean_menus}
##@ if [ -x /usr/bin/texhash ] ;then /usr/bin/env - /usr/bin/texhash 2> /dev/null;fi
##@ if [ -x /usr/bin/updmap ] ;then /usr/bin/env - /usr/bin/updmap 2> /dev/null;fi
##@ if [ -x /usr/bin/scrollkeeper-update ] ;then /usr/bin/env - /usr/bin/scrollkeeper-update 2> /dev/null;fi
##@ 
##@ %post documentation
##@ if [ -x /usr/bin/scrollkeeper-update ] ; then
##@     scrollkeeper-update
##@ fi
##@ 
##@ %postun documentation
##@ if [ -x /usr/bin/scrollkeeper-update ] ; then
##@     scrollkeeper-update
##@ fi


%files
%defattr(-, root, root)
%doc AUTHORS.txt COPYING DEDICATION INSTALL.txt NEWS.txt README.txt 
%doc ROADMAP THANKS 
%{_datadir}/emacs/site-lisp/site-start.d/%{name}-init.el
%{_datadir}/emacs/site-lisp/lilypond*
%{_bindir}/*
%{_infodir}/*
%{_mandir}/man1/*
%{_datadir}/%{name}/%{version}/
%{_datadir}/locale/*/LC_MESSAGES/lilypond.mo
%{_datadir}/vim/vim*

%files -n liblilypond
%defattr(-,root,root)
%{_libdir}/%{name}/%{version}/python/*.so

%files documentation
%defattr(-, root, root)
%{_docdir}/*
%{_datadir}/omf/lilypond/%{version}


%changelog
* Thu Apr 22 2010 Shu KONNO <owa@bg.wakwak.com> 2.12.3-1
- updated LilyPond to 2.12.3
- applied new versioning policy, spec in utf-8
- dropt Patch0: lilypond-platex-2.4.5.patch
- imported patch from fc11
	Patch10: lilypond-2.11.65-python26.patch
	Patch12: lilypond-2.21.2-gcc44-relocate.patch
	Patch13: lilypond-consts.patch
- replaced build, install, pre/post scripts (from fc11)

* Sun Jul  9 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.4.5-0vl2
- rebuilt for VineSeed

* Sat Mar 12 2005 Jun NISHII <jun@vinelinux.org> 2.4.5-0vl1
- build on Vine 3.1

* Wed Mar 24 2004 Jun Nishii <jun@vinelinux.org> 2.0.3-0vl1
- build for Vine Linux
- many fixes in post/postun scripts

* Fri Mar 12 2004 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.30-1thac
- Updated to latest devel release

* Wed Mar 10 2004 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.29-1thac
- Updated to latest devel release

* Wed Feb 25 2004 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.27-1thac
- Updated to latest devel release

* Thu Feb 19 2004 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.25-1thac
- Updated to latest devel release

* Tue Feb 17 2004 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.24-1thac
- Updated to latest devel release

* Fri Feb 13 2004 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.21-1thac
- Updated to latest devel release
- Built against latest pfaedit-040211 and mftrace-1.0.27
- Added requirement for potrace

* Mon Feb 09 2004 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.20-1thac
- Updated to latest devel release

* Tue Jan 27 2004 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.15-1thac
- Updated to latest devel release

* Sat Jan 24 2004 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.14-1thac
- Updated to latest devel release

* Mon Jan 19 2004 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.12-1thac
- Updated to latest devel release

* Sun Jan 18 2004 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.11-1thac
- Updated to latest devel release

* Sat Jan 17 2004 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.10-1thac
- Updated to latest devel release

* Thu Jan 15 2004 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.9-1thac
- Updated to latest devel release

* Fri Jan 09 2004 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.8-1thac
- Updated to latest devel release

* Tue Jan 06 2004 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.7-1thac
- Updated to latest devel release

* Mon Jan 05 2004 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.6-1thac
- Updated to latest devel release

* Fri Jan 02 2004 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.4-1thac
- Updated to latest devel release

* Sun Dec 28 2003 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.3-1thac
- Updated to latest devel release

* Sun Dec 21 2003 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.2-1thac
- Updated to latest devel release

* Thu Dec 17 2003 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.1-1thac
- Updated to latest devel release

* Thu Oct 30 2003 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.0-2thac
- Rebuilt for Mandrake 9.2

* Fri Oct 17 2003 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.1.0-1thac
- Updated to latest devel release

* Mon Oct 06 2003 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.0.1-1thac
- Updated to latest devel release

* Thu Sep 25 2003 Torbjorn Turpeinen <tobbe@nyvalls.se> 2.0.0-1thac
- Updated to latest devel release
- removed lilypond-words

* Tue Sep 23 2003 Torbjorn Turpeinen <tobbe@nyvalls.se> 1.9.9-1thac
- Updated to latest devel release
- fixed lilypond.word install

* Wed Sep 17 2003 Torbjorn Turpeinen <tobbe@nyvalls.se> 1.9.6-1thac
- Updated to latest devel release

* Thu Sep 11 2003 Torbjorn Turpeinen <tobbe@nyvalls.se> 1.9.5-1thac
- Updated to latest devel release
- Built against pyton2.3

* Sun Sep 01 2003 Torbjorn Turpeinen <tobbe@nyvalls.se> 1.9.4-1thac
- Updated to latest devel release

* Sun Aug 31 2003 Torbjorn Turpeinen <tobbe@nyvalls.se> 1.9.3-1thac
- Updated to latest devel release

* Thu Aug 28 2003 Torbjorn Turpeinen <tobbe@nyvalls.se> 1.9.2-1thac
- Updated to latest devel release

* Wed Aug 27 2003 Torbjorn Turpeinen <tobbe@nyvalls.se> 1.9.1-1thac
- Updated to latest devel release
- Changed naming to differ from Mandrake cooker

* Mon Aug 25 2003 Torbjorn Turpeinen <tobbe@nyvalls.se> 1.8.1-3mdk
- Fixed documentation path
- Added some of Heikki Johannes Junes suggestions

* Sun Aug 24 2003 Torbjorn Turpeinen <tobbe@nyvalls.se> 1.8.1-2mdk
- Added Heikki Johannes Junes fix for confilcting PHP variable
  out=/dev/vc/ by adding unset out before compiling
- Compiled with recent guile = 1.6.4 and mftrace = 1.0.17
- Changed icon to lilypond.png
- Added menu and icons again

* Thu Aug 23 2003 Heikki Johannes Junes <hjunes@cc.hut.fi> 1.8.1-1mdk
- removed menu and icons, sync with redhat-spec

* Thu Jun 12 2003 Heikki Johannes Junes <hjunes@cc.hut.fi> 1.7.23-1mdk
- refreshed dependencies and file list.

* Sat Feb 01 2003 Torbjorn Turpeinen <tobbe@nyvalls.se> 1.7.12-1mdk
- Built for Mandrake 9.1

* Fri Dec 01 2002 Heikki Johannes Junes <hjunes@cc.hut.fi> 1.7.9-1mdk
- set menu-items to lilypond-info and lilypond-documentation.

* Fri Nov 30 2002 Heikki Johannes Junes <hjunes@cc.hut.fi> 1.7.8-4mdk
- add pre/post-dependencies and menus with icon from source.

* Fri Oct 28 2002 Heikki Johannes Junes <hjunes@cc.hut.fi> 1.7.4-1mdk
- info, commented menu

* Fri Aug 30 2002 Heikki Johannes Junes <hjunes@cc.hut.fi> 1.6.0-1mdk
- Adapted from lilypond.redhat.skel and skeleton found in Mandrake's RPM-docs.
- TODO: info (?) and dependencies.

* Fri Jun 01 2001 Lenny Cartier <lenny@mandrakesoft.com> 1.4.2-1mdk
- updated by Michael Brown <mbrown@linux-mandrake.com> :
	- Upgraded to 1.4.2
	- Changed URL
	- Removed /etc/profile.d scripts: all TeX bits are now located properly
	- Rearranged documentation
	- Tidied spec file
	- Updated README.first

* Mon Feb 26 2001 Lenny Cartier <lenny@mandrakesoft.com> 1.3.129-1mdk
- added in contribs by Michael Brown <mbrown@fensystems.co.uk> :
	- Removed info files completely (couldn't get info reader to read them)
	- TODO: Get this to work at some point (in the meantime, use documentation in lilypond-extras)

* Sat Feb 17 2001 Michael Brown <mbrown@fensystems.co.uk>
- Moved TeX font folders into the system TeX tree (this ensures that the /var/lib/texmf font cache is used instead of current folder)
- Added mktexlsr to post-install and post-uninstall scripts
- Patched scripts in /etc/profile.d to reflect changes to font locations
- Added QuickStart guide and Points to note sections to README.first (well worth reading)
- Fixed install-info and uninstall-info sections to use Mandrake's RPM macros :-)

* Tue Feb 13 2001 Michael Brown <mbrown@fensystems.co.uk>
- First Mandrake package
- spec file heavily adapted from PowerPC contribs.
- Note HTML documentation may contain duff links and may be incomplete.  Lots of warnings appear when building HTML docs.
- PostScript documentation is duplicated (how do you get an rpm package to contain a symlink?)
- Created README.first file
