File ocaml-camlidl.spec of Package ocaml-camlidl

#
# spec file for package ocaml-camlidl
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           ocaml-camlidl
Version:        1.05
Release:        0
%{?ocaml_preserve_bytecode}
Summary:        Stub code generator and COM binding for Objective Caml
License:        QPL-1.0 and LGPL-2.0
Url:            http://caml.inria.fr/pub/old_caml_site/camlidl/
Group:		Development/Languages/OCaml
Source0:        http://caml.inria.fr/pub/old_caml_site/distrib/bazar-ocaml/camlidl-%{version}.tar.gz
Source1:        http://caml.inria.fr/pub/old_caml_site/distrib/bazar-ocaml/camlidl-%{version}.doc.pdf
# PATCH-FIX-UPSTREAM fix-include.patch peter.trommler@ohm-hochschule.de - add missing include statement to prevent 64 bit compatibility issue
Patch2:         fix-include.patch
BuildRequires:  ocaml
BuildRequires:  ocaml-oasis
BuildRequires:  ocaml-ocamldoc
BuildRequires:  ocaml-rpm-macros >= 4.03
BuildRequires:  perl
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
CamlIDL is a stub code generator and COM binding for Objective Caml.

CamlIDL comprises two parts:

* A stub code generator that generates the C stub code required for
  the Caml/C interface, based on an MIDL specification. (MIDL stands
  for Microsoft's Interface Description Language; it looks like C
  header files with some extra annotations, plus a notion of object
  interfaces that look like C++ classes without inheritance.)

* A (currently small) library of functions and tools to import COM
  components in Caml applications, and export Caml code as COM
  components.

%package        devel
Summary:        Development files for %{name}
Group:          Development/Languages/OCaml
Requires:       %{name} = %{version}

%description    devel
The %{name}-devel package contains libraries and signature files for
developing applications that use %{name}.

%prep
%setup -q -n camlidl-%{version}
%patch2 -p1
cp %{SOURCE1} .
#
# compiler/ contains a module called 'Array' which conflicts with the
# OCaml stdlib module (although only when using ocamlopt for some
# reason).
mv compiler/array.ml compiler/idlarray.ml
mv compiler/array.mli compiler/idlarray.mli

perl -pi.bak -e 's/array/idlarray/g' \
  compiler/Makefile compiler/.depend
perl -pi.bak -e 's/Array(?!\d)/Idlarray/g' \
  compiler/*.ml
#

%build
pushd compiler
sed -e 's|%%%%CPP%%%%|cpp|' config.mlp > config.ml
popd
tee _oasis <<_EOF_
OASISFormat: 0.4
Name:        camlidl
Version:     %{version}
Synopsis:    Stub code generator for OCaml
Authors:     Xavier Leroy
LicenseFile: LICENSE
License:     %{license}
Plugins:     META(`oasis version`)
BuildTools:  ocamlbuild

Library com
 Path: lib
 Install: true
 Modules: Com

Library camlidl
 Path: runtime
 Install: true
 Datafiles: camlidlruntime.h (\$standard_library/caml)
 CSources: idlalloc.c
 CCOpt: -I$PWD/runtime %{optflags} -fPIC

Document "camlidl"
 Title:                API reference for camlidl
 Type:                 ocamlbuild
 BuildTools+:          ocamldoc
 InstallDir:           \$htmldir
 Install:              true
 XOCamlbuildPath:      .
 XOCamlbuildLibraries: com

Executable camlidl
 Install: true
 Path: compiler
 MainIs: main.ml
 CompiledObject: best
_EOF_

%oasis_setup
%ocaml_oasis_configure --enable-docs
%ocaml_oasis_build
%ocaml_oasis_doc

%install
%ocaml_oasis_findlib_install
#
mkdir -vp %{buildroot}/etc/ld.so.conf.d/
tee %{buildroot}/etc/ld.so.conf.d/%{name}.conf <<_EOF_
%{_libdir}/ocaml/camlidl
_EOF_
#

%post   -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc LICENSE
/etc/ld.so.conf.d/*.conf
%{_bindir}/camlidl
%dir %{_libdir}/ocaml/*
%if 0%{?ocaml_native_compiler}
%{_libdir}/ocaml/*/*.cmxs
%endif
%{_libdir}/ocaml/*/*.so

%files devel
%defattr(-,root,root,-)
%doc LICENSE README Changes camlidl-%{version}.doc.pdf tests
%{oasis_docdir_html}
%dir %{_libdir}/ocaml/*
%{_libdir}/ocaml/*/*.a
%if 0%{?ocaml_native_compiler}
%{_libdir}/ocaml/*/*.cmx
%{_libdir}/ocaml/*/*.cmxa
%endif
%{_libdir}/ocaml/*/*.annot
%{_libdir}/ocaml/*/*.cma
%{_libdir}/ocaml/*/*.cmi
%{_libdir}/ocaml/*/*.cmt
%{_libdir}/ocaml/*/*.cmti
%{_libdir}/ocaml/*/*.h
%{_libdir}/ocaml/*/*.mli
%{_libdir}/ocaml/*/META