Name: ocaml
Summary: The Objective Caml compiler and programming environment
Summary(ja): Objective Caml コンパイラとプログラミング環境
Version: 3.12.1
Release: 1%{?_dist_release}
Source0: http://caml.inria.fr/distrib/ocaml-3.10/ocaml-%{version}.tar.bz2
Source1: http://caml.inria.fr/distrib/ocaml-3.10/ocaml-3.12-refman.html.tar.gz
Source2: http://caml.inria.fr/distrib/ocaml-3.10/ocaml-3.12-refman.ps.gz
Source3: http://caml.inria.fr/distrib/ocaml-3.10/ocaml-3.12-refman.info.tar.gz
Source4: ocaml-info-entry

# Vine Source(s)
Source10: caml-mode-install.sh
Source11: caml-mode-remove.sh

License: QPL/LGPL
Group: Development/Languages
URL: http://caml.inria.fr/

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: ncurses-devel gdbm-devel emacsen
BuildRequires: libX11-devel
BuildRequires: tk tcl expect thread 
Provides: ocaml(runtime) = %{version}
Requires(post): install-info
Requires(preun): install-info

Vendor: Project Vine
Distribution: Vine Linux

Packager: inagaki, kenta

%define debug_package %{nil}

%global __ocaml_requires_opts -c -f %{buildroot}%{_bindir}/ocamlobjinfo
%global __ocaml_provides_opts -f %{buildroot}%{_bindir}/ocamlobjinfo

%description
Objective Caml is a high-level, strongly-typed, functional and
object-oriented programming language from the ML family of languages.

This package comprises two batch compilers (a fast bytecode compiler
and an optimizing native-code compiler), an interactive toplevel system,
parsing tools (Lex,Yacc,Camlp4), a replay debugger, a documentation generator,
and a comprehensive library.

%description -l ja
Object Caml は ML 系言語の方言で、高水準で強い型付けを備えた関数型と
オブジェクト指向を併せ持ったプログラミング言語です。
このパッケージには、2 つのバッチコンパイラ (コンパイル速度が高速な
バイトコードコンパイラと最適化を行なうネイティブコードコンパイラ)、
トップレベル対話環境、構文解析ツール (Lex, Yac, Camlp4)、リプレイ
デバッガ、ドキュメント生成ツール、そして広範囲に渡るライブラリが含まれて
います。

%package labltk
Summary: Tk bindings for Objective Caml
Summary(ja): Objective Caml の Tk バインディング
Group: Development/Languages
Requires: ocaml = %{version}-%{release}
Requires: tk tcl
Obsoletes: labltk <= %{version}

%description labltk
A library for interfacing Objective Caml with the scripting language
Tcl/Tk. It include the OCamlBrowser code editor / library browser.

%package camlp4
Summary: Pre-Processor-Pretty-Printer for OCaml
Group: Development/Languages
Requires: ocaml = %{version}-%{release}
Obsoletes: camlp4 <= %{version}

%description camlp4
Camlp4 is a Pre-Processor-Pretty-Printer for OCaml, parsing a source
file and printing some result on standard output.

%package mode
Summary: Emacs mode for Objective Caml
Summary(ja): Objective Caml の Emacs mode
Group: Applications/Editors/Emacs
Requires: ocaml = %{version}-%{release}
Requires(post): emacs, emacsen-common
Requires(preun): emacs, emacsen-common
Obsoletes: ocaml-emacs <= %{version}

%description mode
Emacs mode for Objective Caml.

%description -l ja mode
Objective Caml 用の Emacs mode です．


%prep
%setup -q -T -b 0
%setup -q -T -D -a 1
%setup -q -T -D -a 3
cp %{SOURCE2} refman.ps.gz
cp %{SOURCE4} infoman/ocaml-info-entry

%build
./configure -cc "%{__cc} %{optflags}" -with-pthread \
    -bindir %{_bindir} \
    -libdir %{_libdir}/ocaml \
    -mandir %{_mandir} \
    -prefix %{_prefix}
make world opt opt.opt
(cd infoman; gzip -cd ocaml.info.gz >> ocaml-info-entry; mv ocaml-info-entry  ocaml.info; gzip -f ocaml.info)
# for dumpobj, objinfo
(cd tools; make dumpobj; make objinfo; cd ..)

%install
rm -rf $RPM_BUILD_ROOT

make install BINDIR=$RPM_BUILD_ROOT%{_bindir} LIBDIR=$RPM_BUILD_ROOT%{_libdir}/ocaml MANDIR=$RPM_BUILD_ROOT%{_mandir}

mv $RPM_BUILD_ROOT%{_libdir}/ocaml/ld.conf $RPM_BUILD_ROOT%{_libdir}/ocaml/ld.conf.orig
sed -e "s|^%{buildroot}||" $RPM_BUILD_ROOT%{_libdir}/ocaml/ld.conf.orig > $RPM_BUILD_ROOT%{_libdir}/ocaml/ld.conf
rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/ld.conf.orig
(mkdir -p $RPM_BUILD_ROOT%{_infodir}; cd infoman; cp ocaml*.gz $RPM_BUILD_ROOT%{_infodir})
# for dumpobj, objinfo
(cd tools; install dumpobj objinfo $RPM_BUILD_ROOT%{_bindir}) 

# for Emacs Lisp
make -C emacs install install-ocamltags BINDIR=$RPM_BUILD_ROOT%{_bindir} \
    EMACSDIR=$RPM_BUILD_ROOT%{_datadir}/emacs/site-lisp/caml-mode

# emacsen-common-ize
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/emacsen-common/packages/install
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/emacsen-common/packages/remove
%_installemacsenscript caml-mode %{SOURCE10}

%_removeemacsenscript  caml-mode %{SOURCE11}


# Disable build root strip policy:
# executables generated by ocamlc -custom MUST NOT BE STRIPPED
# But now that we have dynamic loading of C code, none of the executables
# in the distribution is generated by ocamlc -custom, so leave default.
# %define __spec_install_post /usr/lib/rpm/brp-compress

%clean
rm -rf $RPM_BUILD_ROOT

%post
/sbin/install-info %{_infodir}/ocaml.info %{_infodir}/dir

%post mode
if [ "$1" = 2 ]; then
    %_emacsenPackageRemove caml-mode

fi

%_addemacsenlist caml-mode

%_emacsenPackageInstall caml-mode

%preun
if [ $1 = 0 ]; then
    /sbin/install-info --delete %{_infodir}/ocaml.info %{_infodir}/dir
fi

%preun mode
if [ "$1" = 0 ]; then
    %_emacsenPackageRemove caml-mode
    
    %_removeemacsenlist caml-mode

fi


%files
%defattr(-, root, root)
%doc README LICENSE refman.ps.gz htmlman
%{_bindir}/*
%{_mandir}/man1/*
%{_mandir}/man3/*
%{_libdir}/ocaml
%{_infodir}/*
### in ocaml-camlp4
%exclude %{_bindir}/camlp4*
%exclude %{_bindir}/mkcamlp4
%exclude %{_libdir}/ocaml/camlp4/
### in ocaml-labltk
%exclude %{_bindir}/labltk
%exclude %{_bindir}/ocamlbrowser
%exclude %{_libdir}/ocaml/labltk/
%exclude %{_libdir}/ocaml/stublibs/dlllabltk.so
### in ocaml-mode
%exclude %{_bindir}/ocamltags

%files camlp4
%defattr(-, root, root, 0755)
%{_bindir}/camlp4*
%{_bindir}/mkcamlp4
%dir %{_libdir}/ocaml/
%{_libdir}/ocaml/camlp4/

%files labltk
%defattr(-, root, root, 0755)
%doc otherlibs/labltk/examples_*tk
%{_bindir}/labltk
%{_bindir}/ocamlbrowser
%dir %{_libdir}/ocaml/
%dir %{_libdir}/ocaml/stublibs/
%{_libdir}/ocaml/labltk/
%{_libdir}/ocaml/stublibs/dlllabltk.so

%files mode
%defattr(-, root, root, 0755)
%doc emacs/README
%{_bindir}/ocamltags
%dir %{_datadir}/emacs/
%dir %{_datadir}/emacs/site-lisp/caml-mode
%{_datadir}/emacs/site-lisp/caml-mode/*.el
#{_datadir}/emacs/site-lisp/caml-mode/*.elc
%{_prefix}/lib/emacsen-common/packages/install/caml-mode
%{_prefix}/lib/emacsen-common/packages/remove/caml-mode


%changelog
* Sun Jan 15 2012 NAKAMURA Kenta <kenta@vinelinux.org> 3.12.1-1
- new upstream version 3.12.1
- rebuild with rpm-4.9.1.2

* Wed Apr 27 2011 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 3.12.0-1
- new upstream release 

* Fri Apr 16 2010 Shu KONNO <owa@bg.wakwak.com> 3.11.0-2
- rebuilt with new tool chain

* Sat May  9 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 3.11.0-1
- new upstream release 
- spec in UTF-8

* Sat Jul 12 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 3.10.2-1vl5
- new upstream release for VineSeed 

* Sat Jul 12 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 3.10.2-1vl4
- new upstream release

* Wed Feb  6 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 3.10.1-0vl1
- new upstream release

* Sun Sep 23 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 3.10.0-0vl2
- rebuilt with VineSeed

* Sun Sep 23 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 3.10.0-0vl1
- new upstream release

* Tue Nov 28 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 3.09.3-0vl2
- rebuilt for VinePlus/4.0

* Mon Nov 27 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 3.09.3-0vl1
- new upstream release

* Tue Sep 12 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 3.09.2-0vl4
- changed ocaml-mode Group to Appliations/Editors/Emacs <BTS:VineLinux:163>

* Wed Aug 30 2006 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> - 3.09.2-0vl3
- add BuildRequires: XOrg-devel, ncurses-devel, gdbm-devel, emacsen
- use %%{_prefix}/lib instead of %%{_libdir} for elisp directory

* Wed Jun  7 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 3.09.2-0vl2
- rebuilt for VineSeed Plus

* Wed Jun  7 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 3.09.2-0vl1
- new upstream release

* Sat Feb 25 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 3.09.1-0vl3
- rebuilt for VineSeed Plus

* Sat Feb 25 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 3.09.1-0vl2
- rebuilt for VinePlus/3.0
- added BuildRequires: expect, thread

* Sat Jan 28 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 3.09.1-0vl1
- new upstream release

* Sat Nov  5 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 3.09.0-0vl2
- rebuild for VineSeed Plus

* Thu Nov  3 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 3.09.0-0vl1
- new upstream release

* Tue Oct 18 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 3.08.4-0vl3
- rebuild with VineSeed Plus

* Mon Oct 17 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 3.08.4-0vl2
- rebuild with VinePlus/3.0
- added dumpobj, objinfo

* Sat Oct  8 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 3.08.4-0vl1
- new upstream release
- split to caml4p, labltk, mode packages 

* Thu Mar 24 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 3.08.3-0vl1
- new upstream release

* Sat Dec  4 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 3.08.2-0vl1
- new upstream release

* Fri Oct 15 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 3.08.1-0vl1
- new upstream release

* Fri Aug 20 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 3.08.0-0vl4
- fixed typo based on 3.08.0-0vl3
  * Thu Aug 12 2004 IKEDA Katsumi <ikeda@webmasters.gr.jp> 3.08.0-0vl3
  - Modified typo: %%descriptin -l ja into %description -l ja

* Tue Aug 17 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 3.08.0-0vl3
- rebuild for VinePlus/3.0 and VineSeedPlus
- updated Japanese description
- merged VinePlus/2.6 spec file
  * Fri Jul 23 2004 IKEDA Katsumi <ikeda@webmasters.gr.jp> 3.08.0-0vl2
  - Modified the character code of this file into euc-jp.
  * Tue Jul 21 2004 by IKEDA Katsumi <ikeda@rg8.so-net.ne.jp> 3.08.0-0vl1
  - new upstream release.
  - Modified Copyright.
  - Added Summary(ja), %%descriptin -l ja, Prereq and %%clean.
  - Added %%post and %%preun for running /sbin/install-info.

* Wed Apr  7 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 3.07-2vl2
- rebuild for VineSeed
- s/Copyright/License/

* Thu Feb 12 2004 by IKEDA Katsumi <ikedak@rg8.so-net.ne.jp>
- 3.07-2vl1
- Modified %Vendor and %BuildRoot.
- Add %Distribution.
