Blob Blame History Raw
# Testing note: The makefile in test is broken in version 0.9.10.  After
# repairing it, compilation of ctest1.c fails due to too few arguments to
# ap_pkgrid_manager_alloc().  Try to create a %%check section again later.

Name:           apron
Version:        0.9.10
Release:        4%{?dist}
Summary:        Numerical abstract domain library

# The entire package is LGPLv2+ except newpolka/mf_qsort.c and ppl/*, all of
# which are GPLv2+.  This means that libpolkaMPQ.so.*, libpolkaRll.so.*, and
# libap_ppl.so.* are GPLv2+, and the other libraries are all LGPLv2+.
License:        LGPLv2+ and GPLv2+
URL:            http://apron.cri.ensmp.fr/library/
Source0:        http://apron.cri.ensmp.fr/library/%{name}-%{version}.tgz
# This patch has not been sent upstream as it is GCC-specific.  Certain
# symbols are defined in both libpolkaMPQ and libpolkaRll, with different
# implementations.  This patch makes references to those symbols in
# libap_pkgrid be weak references, since that library can be combined with
# either of the 2 implementations.
Patch0:         %{name}-weak.patch

BuildRequires:  mpfr-devel
BuildRequires:  ppl-devel
%ifarch %{ocaml_arches}
BuildRequires:  ocaml
BuildRequires:  ocaml-camlidl-devel
BuildRequires:  ocaml-mlgmpidl-devel
BuildRequires:  ocaml-ocamldoc

%global opt %(test -x %{_bindir}/ocamlopt && echo 1 || echo 0)
%endif

%global sover %(echo %{version} | cut -d. -f 1)

%description
The APRON library is dedicated to the static analysis of the numerical
variables of a program by Abstract Interpretation.  The aim of such an
analysis is to infer invariants about these variables, like 1<=x+y<=z,
which holds during any execution of the program.

The APRON library is intended to be a common interface to various
underlying libraries/abstract domains and to provide additional services
that can be implemented independently from the underlying
library/abstract domain.

%package        devel
Summary:        Development files for %{name}
Requires:       %{name}%{?_isa} = %{version}-%{release}
Requires:       gmp-devel%{?_isa}
Requires:       mpfr-devel%{?_isa}

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

%ifarch %{ocaml_arches}
%package -n     ocaml-%{name}
Summary:        Ocaml interface to APRON
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description -n ocaml-%{name}
Ocaml interface to the APRON library.

%package -n     ocaml-%{name}-devel
Summary:        Development files for the Ocaml interface to APRON
Requires:       ocaml-%{name}%{?_isa} = %{version}-%{release}
Requires:       ocaml-camlidl-devel%{?_isa}
Requires:       ocaml-mlgmpidl-devel%{?_isa}
Requires:       %{name}-devel%{?_isa} = %{version}-%{release}

%description -n ocaml-%{name}-devel
Development files for the Ocaml interface to the APRON library.
%endif

%prep
%setup -q
%patch0

# Set the configuration values
sed -e "s|^# HAS_CPP.*|HAS_CPP = 1|" \
    -e "s|^# HAS_PPL.*|HAS_PPL = 1|" \
    -e "s|^# HAS_LONG_DOUBLE.*|HAS_LONG_DOUBLE = 1|" \
    -e "s|^APRON_PREFIX =.*|APRON_PREFIX=%{_prefix}|" \
    -e "s|^MLGMPIDL_PREFIX =.*|MLGMPIDL_PREFIX=%{_libdir}/ocaml/mlgmpidl|" \
    -e "s|^PPL_PREFIX =.*|PPL_PREFIX=%{_prefix}|" \
    -e "s|^-fPIC -O3 -DNDEBUG|$RPM_OPT_FLAGS -fPIC -DNDEBUG -Wl,--as-needed|" \
    -e "s|^-fPIC -g -O0|$RPM_OPT_FLAGS -fPIC -O0 -Wl,--as-needed|" \
%ifarch %{ocaml_arches}
%if !%opt
    -e "s|^HAS_OCAMLOPT.*|# HAS_OCAMLOPT = 1|" \
    -e "s|\.opt||" \
%endif
%else
    -e "s|^HAS_OCAML =*|# HAS_OCAML = 1|" \
    -e "s|^HAS_OCAMLOPT.*|# HAS_OCAMLOPT = 1|" \
%endif
    Makefile.config.model > Makefile.config

# Fix library paths
sed -e "s|\$(CAMLIDL_PREFIX)/lib/ocaml|%{_libdir}/ocaml|g" \
    -e "s|\$(MLGMPIDL_PREFIX)/include|\$(MLGMPIDL_PREFIX)|g" \
    -e "s|\$(MLGMPIDL_PREFIX)/lib|\$(MLGMPIDL_PREFIX)|g" \
    -i Makefile box/Makefile examples/Makefile mlapronidl/Makefile \
       newpolka/Makefile octagons/Makefile ppl/Makefile products/Makefile \
       test/Makefile

# Remove rpaths
for f in `find . -name Makefile`; do
  sed -r -e 's| ?-L\$\(APRON_PREFIX\)/lib||' \
         -e 's| ?-L\$\(GMP_PREFIX\)/lib||' \
         -e 's| ?-L\$\(MPFR_PREFIX\)/lib||' \
         -e 's| ?-L\$\(PPL_PREFIX\)/lib||' \
         -i $f
done

# Fix the install location for libraries
if [ %{__isa_bits} = "64" ]; then
  sed -e "s|\$(APRON_PREFIX)/lib|\$(APRON_PREFIX)/lib64|g" \
      -e "s|\$(PREFIX)/lib|\$(PREFIX)/lib64|g" \
      -i apron/Makefile apronxx/Makefile box/Makefile examples/Makefile \
         itv/Makefile mlapronidl/Makefile newpolka/Makefile octagons/Makefile \
         ppl/Makefile products/Makefile test/Makefile
fi

# Add sonames
sed -i -e "s|-shared|-shared -Wl,-soname=\$@.%{sover}|" apron/Makefile
sed -r -e "s|(-shared -o \\\$@ \\\$\^ \\\$\(LIBS.*\))|\1 -Wl,-soname=\$@.%{sover}|" \
    -i apronxx/Makefile box/Makefile newpolka/Makefile octagons/Makefile \
    ppl/Makefile products/Makefile

# Fix submakes
sed -i "s|make|\$(MAKE)|g" Makefile

# Fix encodings
iconv -f iso8859-1 -t utf-8 Changes > Changes.utf8
touch -r Changes Changes.utf8
mv -f Changes.utf8 Changes

%build
# FIXME: Cannot use %%{?_smp_mflags} due to missing Makefile dependencies
make

%install
mkdir -p $RPM_BUILD_ROOT%{_prefix}
make install APRON_PREFIX=$RPM_BUILD_ROOT%{_prefix}

# We don't really want the test binaries
rm -fr $RPM_BUILD_ROOT%{_bindir}

# Move the header files into a subdirectory
mkdir $RPM_BUILD_ROOT%{_includedir}/%{name}
mv $RPM_BUILD_ROOT%{_includedir}/*.h $RPM_BUILD_ROOT%{_includedir}/apronxx \
   $RPM_BUILD_ROOT%{_includedir}/oct $RPM_BUILD_ROOT%{_includedir}/%{name}

%ifarch %{ocaml_arches}
# Most files in _libdir are ocaml files, and so are in the wrong place.
mkdir -p $RPM_BUILD_ROOT%{_libdir}/ocaml/%{name}
mv $RPM_BUILD_ROOT%{_libdir}/*.{a,cma,cmi,cmx,cmxa,idl,ml,mli} \
   $RPM_BUILD_ROOT%{_libdir}/*_caml.so \
   $RPM_BUILD_ROOT%{_libdir}/*_caml_debug.so \
   $RPM_BUILD_ROOT%{_libdir}/ocaml/%{name}
%else
# Some ocaml-only files got installed.  Remove them.
rm -f $RPM_BUILD_ROOT%{_libdir}/*.{a,idl,ml,mli}
%endif

# Remove extraneous executable bits
%ifarch %{ocaml_arches}
chmod a-x $RPM_BUILD_ROOT%{_libdir}/ocaml/%{name}/*.{a,cma,cmi,cmx*,idl,ml,mli}
%endif
find $RPM_BUILD_ROOT%{_includedir} \( -name \*.h -o -name \*.hh \) \
     -perm /0111 | xargs chmod a-x

# Make duplicate files be symbolic links instead of copies
%ifarch %{ocaml_arches}
for f in ap_ppl apron boxD boxMPFR boxMPQ octD octMPQ polkaGrid polkaMPQ \
         polkaRll; do
  rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/%{name}/dll${f}_caml.so
  ln -s lib${f}_caml.so \
        $RPM_BUILD_ROOT%{_libdir}/ocaml/%{name}/dll${f}_caml.so
  rm -f $RPM_BUILD_ROOT%{_libdir}/ocaml/%{name}/dll${f}_caml_debug.so
  ln -s lib${f}_caml_debug.so \
        $RPM_BUILD_ROOT%{_libdir}/ocaml/%{name}/dll${f}_caml_debug.so
done
%endif

# Fix up the shared library names
cd $RPM_BUILD_ROOT%{_libdir}
for f in lib*.so; do
  mv $f $f.%{version}
  ln -s $f.%{sover} $f
  ln -s $f.%{version} $f.%{sover}
done

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%doc AUTHORS Changes COPYING README apron/apron.pdf
%{_libdir}/*.so.*
%exclude %{_libdir}/*_debug.so*

%files devel
%doc apron/html/*
%{_libdir}/*.so
%exclude %{_libdir}/*_debug.so
%{_includedir}/%{name}
%ifarch %{ocaml_arches}
%exclude %{_includedir}/%{name}/apron_caml.h
%endif

%ifarch %{ocaml_arches}
%files -n ocaml-%{name}
%doc mlapronidl/mlapronidl.pdf
%{_libdir}/ocaml/%{name}
%exclude %{_libdir}/ocaml/%{name}/*_debug.so
%if %opt
%exclude %{_libdir}/ocaml/%{name}/*.a
%exclude %{_libdir}/ocaml/%{name}/*.cmxa
%exclude %{_libdir}/ocaml/%{name}/*.cmx
%endif
%exclude %{_libdir}/ocaml/%{name}/*.ml
%exclude %{_libdir}/ocaml/%{name}/*.mli

%files -n ocaml-%{name}-devel
%doc mlapronidl/html/*
%{_includedir}/%{name}/apron_caml.h
%if %opt
%{_libdir}/ocaml/%{name}/*.a
%exclude %{_libdir}/ocaml/%{name}/*_debug.a
%{_libdir}/ocaml/%{name}/*.cmxa
%{_libdir}/ocaml/%{name}/*.cmx
%endif
%{_libdir}/ocaml/%{name}/*.ml
%{_libdir}/ocaml/%{name}/*.mli
%endif

%changelog
* Tue Nov  8 2011 Jerry James <loganjerry@gmail.com> - 0.9.10-4
- -devel also needs ocaml-camlidl-devel
- Pass --as-needed to the linker to fix unused shared library dependencies

* Fri Nov  4 2011 Jerry James <loganjerry@gmail.com> - 0.9.10-3
- Comment on license situation
- Drop debug libraries altogether

* Wed Aug 24 2011 Jerry James <loganjerry@gmail.com> - 0.9.10-2
- Correct license
- Build C and C++ interfaces even when the ocaml interface cannot be built
- Move debug libraries to separate packages

* Fri Jul  8 2011 Jerry James <loganjerry@gmail.com> - 0.9.10-1
- Initial RPM