Blob Blame History Raw
# Upstream includes option for generation of optimized binaries,
# however, specifically generates bytecode versions for certain
# executables even when optimized option is set, namely the following:

# coq-tex, coq_makefile, coq-interface, coqwc, coqdoc, parser, coqdep,
# gallina

# (coqtop.byte, coqide.byte binaries are also made available.)

# .coqide-gtk2rc also produces an rpmlint warning due to its name,
# however, this name is proper as per the Coq documentation

# Disable creation of the debug package: if bytecode executables are
# created find-debuginfo.sh will ruin them, while if optimized
# executables are created they will be stripped by the Makefile
# anyway, thus we won't get anything useful from the debug info
# package creation.
#
# It appears as though ALL of these are necessary to prevent unwanted
# stripping
%define __os_install_post /usr/lib/rpm/brp-compress %{nil}
%define _enable_debug_package 0
%define debug_package %{nil}

Name:		coq
Version:	8.1pl3
Release:	1%{?dist}
Summary:	Coq proof management system

Group:		Applications/Engineering
License:	LGPLv2
URL:		http://coq.inria.fr/
Source0:	http://coq.inria.fr/V%{version}/files/coq-%{version}.tar.gz
Source1:	Coq-Library.pdf.gz
Source2:	Coq-Reference-Manual.pdf.gz
Source3:	Coq-Tutorial.v.pdf.gz 
Source4:	Coq-RecTutorial.pdf.gz
Source5:	coq-refman-html.tar.gz
Source6:	coq-stdlib-html.tar.gz
Source7:	RecTutorial.v
Source8:	coqide.desktop
Source9:	coq-icon.png
Source10:	README.coq-emacs
Patch0:		makefile.patch
Patch1:		cmxa-install.patch
Patch2:		makefile-strip.patch
Patch3:		check.patch
BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires:	ocaml >= 3.08, ocaml-camlp5-devel, gtk2-devel, ocaml-lablgtk-devel, desktop-file-utils, emacs, texlive-latex, texlive-texmf
# ExcludeArch:	ppc64

%description
Coq is a formal proof management system. It allows for the development
of theorems through first order logic that are mechanically checked by
the machine. Sets of definitions and theorems can be saved as compiled
modules and loaded into the system.

This package provides the main Coq binary without an optional IDE,
Coqide.

# The IDE's package name will become "coq-coqide".  That way,
# searching for either "coqide" (the Ubuntu/Debian package name, and
# also the full name of the IDE) or "coq" and "ide" will find
# this. (If the package were named "coq-ide", the former would fail.)
%package coqide
Group:		Applications/Engineering
Summary:	Coqide IDE for Coq proof management system
Requires:	coq

%description coqide
Coq is a formal proof management system. It allows for the development
of theorems through first order logic that are mechanically checked by
the machine. Sets of definitions and theorems can be saved as compiled
modules and loaded into the system.

This package provides Coqide, a lightweight IDE for Coq.

%package doc
Group:		Applications/Engineering
Summary:	Documentation for Coq proof management system

%description doc
Coq is a formal proof management system. It allows for the development
of theorems through first order logic that are mechanically checked by
the machine. Sets of definitions and theorems can be saved as compiled
modules and loaded into the system.

This package provides documentation and tutorials for the system. The
main documentation comes in two parts: the main Library documentation,
which decribes all Coq.* modules, and the Reference Manual, which
gives a more complete description of the whole system. Included are
also HTML versions of both. Furthermore, there are two tutorials, the
main one, and one specifically on recursive types. The example code
for the latter is also included.

%package emacs
Group:		Applications/Engineering
Summary:	Elisp files for Coq proof management system
Requires:	coq, emacs

%description emacs
Coq is a formal proof management system. It allows for the development
of theorems through first order logic that are mechanically checked by
the machine. Sets of definitions and theorems can be saved as compiled
modules and loaded into the system.

This package provides emacs mode files for formatting Coq input.

%prep
%setup -q

# Patch description:
# Considered each of the seven patches from the Debian Coq package:

# Credit goes to the Debian patch creators for their patches
# (See http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/coq/trunk/debian/patches/?rev=0&sc=0)
#
# For most patches I merely reproduced the results in non-dpatch
# form. I opted for no patching in cases where it did not seem
# necessary or immediately correct.
#

# - browser.dpatch: changes firefox option for linux, however, link
# x-www-browser does not exist in Fedora setup, and changing this
# option does not actually fix the problem in the IDE wherein a
# browser window needs to be open in order to actually open any help
# file -> do not change until the real source of the problem can be
# detected
# - check.dpatch: suppress a test warning, similar change made in my
# check.patch
# - cmxa-install.dpatch: fixes cmxa install by testing for opt, similar
# change made in cmxa-install.patch
# - configure.dpatch: fixes detection of ocamlopt - We do this detection
# seperately anyway in this RPM, no change made
# - coqdoc_stdlib.dpatch: extra documentation option - Perhaps do this
# in the future, but for now, no change made
# - makefile.dpatch: fix testing on non-native architecture compiles, similar change made in makefile.patch
# - no-complexity-test.dpatch: turn off some of the tests - Perhaps this
# change was made due to a failure in complexity tests when they
# "don't run quickly enough", which is likely to be incredibly
# variable, but unsure, so no change made

%patch0
%patch1

# I created patch3 to consistently strip native-code binaries, unlike
# the inconsistent way it was done in the original makefile
%patch2

# This patch may not be strictly necessary unless the tests are
# incorporated into the build process somehow. However, the tests don't
# work properly without it.
%patch3

# Fix some files that are not in UTF-8 encoding

for f in CHANGES CREDITS COPYRIGHT; do
mv $f $f.old; iconv -f ISO-8859-1 -t UTF-8 < $f.old > $f; rm $f.old
done

%define emacs_lispdir %{_datadir}/emacs/site-lisp
%define tex_dir %{_datadir}/texmf/tex/latex/misc

# Seems like setup only sets up the main file
cp %SOURCE1 %SOURCE2 %SOURCE3 %SOURCE4 %SOURCE5 %SOURCE6 %SOURCE7 %SOURCE8 %SOURCE9 %SOURCE10 .
gunzip *.gz
for f in *.tar; do
tar xf $f
done

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

# optimized binary ppc64 building does not work at the moment - the
# log files are no real help, but we fail on bootstrap with the
# optimized compiler:
#
# bin/coqtop.opt -boot -nois -compile theories/Init/Notations
#
# appears to be the command that dies. It appears that the status of
# OCaml has been somewhat uncertain on ppc64, perhaps this is the cause?
# However, bytecode compilation DOES work -> do this for now
%ifarch ppc64
%define opt 0
%endif

# Define opt flag based upon prior opt detection and restrictions
%if %{opt}
%define opt_option --opt
%else
%define opt_option --byte-only
%endif

bash configure -prefix %{_prefix} -libdir %{_datadir}/coq -bindir %{_bindir} -mandir %{_mandir} -emacs %{emacs_lispdir} -coqdocdir %{tex_dir} %{opt_option} -reals all > /dev/null
make world 2>/dev/null

# Fix permissions in the documentation
chmod -R a+rX refman stdlib

%install
rm -rf %{buildroot}

make COQINSTALLPREFIX="%{buildroot}" install

# Install desktop icon and menu entry

%define coqdatadir %{_datadir}/coq
%if %(test -d %{buildroot}%{coqdatadir} && echo 1 || echo 0) != 1
mkdir -p %{buildroot}%{coqdatadir}
%endif
cp coq-icon.png %{buildroot}%{coqdatadir}

sed -i -e 's|ICON-LOCATION-BASE|%{coqdatadir}|' coqide.desktop

desktop-file-install --vendor="fedora"			\
--dir=%{buildroot}%{_datadir}/applications		\
coqide.desktop

# Install tutorial code

%define tutorialcodedir %{coqdatadir}/tutorial
%if %(test -d %{buildroot}%{tutorialcodedir} && echo 1 || echo 0) != 1
mkdir -p %{buildroot}%{tutorialcodedir}
%endif
mv RecTutorial.v %{buildroot}%{tutorialcodedir}

%clean
rm -rf %{buildroot}

# Note: we want to keep both coqtop.opt and coqtop.byte because the
# byte compiled version can be used to compile new version through
# coqmktop

%files
%defattr(-,root,root,-)
%doc CHANGES COMPATIBILITY COPYRIGHT CREDITS INSTALL KNOWN-BUGS LICENSE README
%doc %{_mandir}/man1/coq*
%doc %{_mandir}/man1/gallina.1.gz
%doc %{_mandir}/man1/parser.1.gz
%{_datadir}/coq
%{_bindir}/coq*
%{_bindir}/gallina
%{_bindir}/parser
%if %{opt}
%{_bindir}/parser.opt
%endif
# Exclude ide files to put in a separate package
%exclude %{_bindir}/coqide*
%exclude %{_datadir}/coq/ide
%if %{opt}
%exclude %{_datadir}/coq/*.cmxa
%endif
%{tex_dir}/coq*

%files coqide
%defattr(-,root,root,-)
%doc INSTALL.ide
%{_bindir}/coqide*
%{_datadir}/coq/ide
# Exclude a corrupted file from the tarball
%exclude %{_datadir}/coq/ide/coq.png
# Instead include a non-corrupted icon somewhere else
%dir %{coqdatadir}
%{coqdatadir}/coq-icon.png

# Is it ok to assume this is what desktop-file-install renames coqide.desktop to?
%{_datadir}/applications/fedora-coqide.desktop

%files doc
%defattr(-,root,root,-)
%doc Coq-Library.pdf
%doc Coq-Reference-Manual.pdf
%doc Coq-Tutorial.v.pdf
%doc Coq-RecTutorial.pdf
%dir %{coqdatadir}
%{tutorialcodedir}
# Standard permissions with - in defattr make the manual unreadable... unknown how to fix
%doc refman
%doc stdlib

%files emacs
%defattr(-,root,root,-)
%{_datadir}/emacs/site-lisp/coq*
%doc README.coq-emacs

%changelog
* Wed Jun 14 2008 Alan Dunn <amdunn@gmail.com> 8.1pl3-1
- Initial Fedora RPM version.