+# NOTE: tests >100 processes, so ensure proper ulimit
+#
+# Conditional build:
+%bcond_without doc # build without documentation
+%bcond_with clisp # build using clisp instead of sbcl
+#
+# To build with an unpackaged Common Lisp implementation,
+# pass --define bootstrap_cl /path/to/lisp/binary to builder.
+#
Summary: The Steel Bank Common Lisp development environment
-Summary(pl): ¦rodowisko programowania Steel Bank Common Lisp
+Summary(pl.UTF-8): Środowisko programowania Steel Bank Common Lisp
Name: sbcl
-Version: 0.8.1
+Version: 1.3.10
Release: 1
License: MIT
Group: Development/Languages
-Source0: http://dl.sourceforge.net/sbcl/%{name}-%{version}-source.tar.bz2
-# Source0-md5: 884771bd1ac26bc78c897ae6510541d9
-URL: http://sbcl.sourceforge.net
-BuildRequires: sbcl
-BuildRequires: docbook-utils
+Source0: http://download.sourceforge.net/sbcl/%{name}-%{version}-source.tar.bz2
+# Source0-md5: c8bd43e149109127651a6917976dda4a
+Source10: http://download.sourceforge.net/sbcl/sbcl-1.2.7-x86-linux-binary.tar.bz2
+# Source10-md5: f6a1b2137fbc74b4a8aaf338643f4ae2
+Source11: http://download.sourceforge.net/sbcl/sbcl-1.3.10-x86-64-linux-binary.tar.bz2
+# Source11-md5: 56fe67f916ccdd84e7b739d0a731cf9f
+# TODO (portability) - also available:
+#SourceXX: http://download.sourceforge.net/sbcl/sbcl-1.3.10-arm64-linux-binary.tar.bz2
+#SourceXX: http://download.sourceforge.net/sbcl/sbcl-1.3.9-armhf-linux-binary.tar.bz2
+#SourceXX: http://download.sourceforge.net/sbcl/sbcl-1.2.7-armel-linux-binary.tar.bz2
+#SourceXX: http://download.sourceforge.net/sbcl/sbcl-1.2.7-powerpc-linux-binary.tar.bz2
+#SourceXX: http://download.sourceforge.net/sbcl/sbcl-1.0.23-mips-linux-binary.tar.bz2
+#SourceXX: http://download.sourceforge.net/sbcl/sbcl-1.0.28-mipsel-linux-binary.tar.bz2
+#SourceXX: http://download.sourceforge.net/sbcl/sbcl-1.0.28-alpha-linux-binary.tar.bz2
+#SourceXX: http://download.sourceforge.net/sbcl/sbcl-1.0.28-sparc-linux-binary.tar.bz2
+Patch0: %{name}-tests.patch
+Patch1: %{name}-threads.patch
+Patch2: %{name}-info.patch
+URL: http://sbcl.sourceforge.net/
+%{?with_clisp:BuildRequires: clisp}
+%if %{with doc}
+BuildRequires: tetex-dvips
+BuildRequires: texinfo-texi2dvi
+%endif
+%if %{without clisp}
+%{!?bootstrap_cl:ExclusiveArch: %{ix86} %{x8664}}
+# also: %{arm} aarch64 alpha mips mipsel ppc sparc
+%endif
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
Steel Bank Common Lisp (SBCL) is a Open Source development environment
-for Common Lisp based on CMUCL. It includes an integrated native compiler,
-interpreter, and debugger.
+for Common Lisp based on CMUCL. It includes an integrated native
+compiler, interpreter, and debugger.
-%description -l pl
-Steel Bank Common Lisp (SBCL) to ¶rodowisko programistyczne Open
+%description -l pl.UTF-8
+Steel Bank Common Lisp (SBCL) to środowisko programistyczne Open
Source dla Common Lispa oparte na CMUCL. Zawiera zintegrowany natywny
kompilator, interpreter i debugger.
+%package doc-info
+Summary: The Steel Bank Common Lisp documentation (info)
+Summary(pl.UTF-8): Dokumentacja Steel Bank Common Lisp (info)
+Group: Development/Languages
+
+%description doc-info
+Documentation of Steel Bank Common Lisp (SBCL) in info format.
+
+%description doc-info -l pl.UTF-8
+Dokumentacja Steel Bank Common Lisp (SBCL) w formacie info.
+
+%package doc-html
+Summary: The Steel Bank Common Lisp documentation (HTML)
+Summary(pl.UTF-8): Dokumentacja Steel Bank Common Lisp (HTML)
+Group: Development/Languages
+
+%description doc-html
+Documentation of Steel Bank Common Lisp (SBCL) in HTML format.
+
+%description doc-html -l pl.UTF-8
+Dokumentacja Steel Bank Common Lisp (SBCL) w formacie HTML.
+
+%package doc-pdf
+Summary: The Steel Bank Common Lisp documentation (PDF)
+Summary(pl.UTF-8): Dokumentacja Steel Bank Common Lisp (PDF)
+Group: Development/Languages
+
+%description doc-pdf
+Documentation of Steel Bank Common Lisp (SBCL) in PDF format.
+
+%description doc-pdf -l pl.UTF-8
+Dokumentacja Steel Bank Common Lisp (SBCL) w formacie PDF.
+
%prep
-%setup -q
+%ifarch %{ix86}
+%setup -q -a 10
+%endif
+%ifarch %{x8664}
+%setup -q -a 11
+%endif
+%patch0 -p1
+%ifarch %{ix86} %{x8664}
+%patch1 -p1
+%endif
+%patch2 -p1
+
+mkdir sbcl-bootstrap
+cd sbcl-*-linux
+INSTALL_ROOT=`pwd`/../sbcl-bootstrap sh ./install.sh
+cd -
+
+# clean.sh is so stupid it removed sbcl-bootstrap contents
+%{__mv} clean.sh clean.sh.orig
+echo "#!/bin/sh" >clean.sh
+chmod 755 clean.sh
+
+%if %{with clisp}
+%define bootstrap_cl "clisp"
+%endif
%build
-GNUMAKE="make"
-CFLAGS="%{rpmcflags}"
-CC="%{__cc}"
-export GNUMAKE CC CFLAGS
-./make.sh "sbcl --disable-debugger"
-cd doc
-docbook2html user-manual.sgml || :
-install -d manual
-mv -f *.html manual
-cd ..
+export GNUMAKE="make"
+export CC="%{__cc}"
+export CFLAGS="%{rpmcflags}"
+export SBCL_HOME=`pwd`/sbcl-bootstrap/lib/sbcl
+export PATH=`pwd`/sbcl-bootstrap/bin:${PATH}
+./make.sh \
+ --prefix=%{_prefix} \
+ %{?bootstrap_cl}
+
+%if %{with doc}
+%{__make} -C doc/manual -j1
+%endif
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{%{_bindir},%{_libdir},%{_mandir}/man1}
+install -d $RPM_BUILD_ROOT{%{_bindir},%{_libdir},%{_mandir},%{_infodir}} \
+ $RPM_BUILD_ROOT/etc/env.d
+
+env -u SBCL_HOME INSTALL_ROOT=`pwd`/_install %{_buildshell} ./install.sh
+
+%{__mv} _install/lib/sbcl $RPM_BUILD_ROOT%{_libdir}/%{name}
+%{__mv} _install/bin/sbcl $RPM_BUILD_ROOT%{_bindir}/%{name}
+%{__mv} _install/share/man/* $RPM_BUILD_ROOT%{_mandir}
+%if %{with doc}
+%{__mv} _install/share/info/*.info* $RPM_BUILD_ROOT%{_infodir}
+%endif
-install src/runtime/sbcl $RPM_BUILD_ROOT%{_bindir}
-install output/sbcl.core $RPM_BUILD_ROOT%{_libdir}
-install doc/sbcl.1 $RPM_BUILD_ROOT%{_mandir}/man1
+echo SBCL_HOME=%{_libdir}/%{name} > $RPM_BUILD_ROOT/etc/env.d/SBCL_HOME
%clean
rm -rf $RPM_BUILD_ROOT
+%post
+%env_update
+
+%postun
+%env_update
+
+%if %{with doc}
+%post doc-info -p /sbin/postshell
+-/usr/sbin/fix-info-dir -c %{_infodir}
+
+%postun doc-info
+[ ! -x /usr/sbin/fix-info-dir ] || /usr/sbin/fix-info-dir -c %{_infodir} >/dev/null 2>&1
+%endif
+
%files
%defattr(644,root,root,755)
-%doc BUGS COPYING CREDITS NEWS README PRINCIPLES ChangeLog doc/manual
+%doc _install/share/doc/sbcl/{BUGS,COPYING,CREDITS,NEWS}
%attr (755,root,root) %{_bindir}/sbcl
-%{_libdir}/sbcl.core
-%{_mandir}/man1/*
+%{_libdir}/%{name}
+%{_mandir}/man1/sbcl.1*
+%config(noreplace,missingok) %verify(not md5 mtime size) /etc/env.d/SBCL_HOME
+
+%if %{with doc}
+%files doc-info
+%defattr(644,root,root,755)
+%{_infodir}/asdf.info*
+%{_infodir}/sbcl.info*
+
+%files doc-html
+%defattr(644,root,root,755)
+%doc _install/share/doc/sbcl/*.html
+
+%files doc-pdf
+%defattr(644,root,root,755)
+%doc _install/share/doc/sbcl/*.pdf
+%endif