%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}
%define mver 1.8

Version: 1.8.7
Release: 1%{?_dist_release}

Summary: A GNU implementation of Scheme for application extensibility.
Summary(ja): アプリケーション拡張用 Scheme の GNU な実装
Name: guile
Source: ftp://ftp.gnu.org/gnu/guile-%{version}.tar.gz
Source2: http://ai.king.net.pl/guile-1.6-missing-tools.tar.gz
Patch1: guile-1.6.7-rpath.patch
Patch2: guile-1.6.0-unknown_arch.patch
Patch3: guile-1.6.0-ppc64.patch
Patch4: guile-1.6.7-ltdl.patch
Patch5: guile-1.6.7-64bit.patch

# following patchs are imported from fedora-dev 
#Patch11: guile-1.8.4-multilib.patch
#Patch12: guile-1.8.4-testsuite.patch
Patch14: guile-1.8.6-deplibs.patch

License: GPL
Group: Development/Languages
Buildroot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: libtool libtool-ltdl-devel >= 2.2.6a
BuildRequires: gmp-devel readline-devel emacs
Requires(post): /sbin/install-info
Requires(preun): /sbin/install-info
Requires: coreutils


Vendor:		Project Vine
Distribution:	Vine Linux
Packager:	yasumichi

%description
GUILE (GNU's Ubiquitous Intelligent Language for Extension) is a library
implementation of the Scheme programming language, written in C.  GUILE
provides a machine-independent execution platform that can be linked in
as a library during the building of extensible programs.

Install the guile package if you'd like to add extensibility to programs
that you are developing.

%package devel
Summary: Libraries and header files for the GUILE extensibility library.
Summary(ja): GUILE 用の開発ライブラリおよびヘッダファイル
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: gmp-devel

%description devel
The guile-devel package includes the libraries, header files, etc.,
that you'll need to develop applications that are linked with the
GUILE extensibility library.

You need to install the guile-devel package if you want to develop
applications that will be linked to GUILE.  You'll also need to
install the guile package.

%package -n compat32-%{name}
Summary: A GNU implementation of Scheme for application extensibility.
Summary(ja): アプリケーション拡張用 Scheme の GNU な実装
Group: Development/Languages
Requires: %{name} = %{version}-%{release}

%description -n compat32-%{name}
GUILE (GNU's Ubiquitous Intelligent Language for Extension) is a library
implementation of the Scheme programming language, written in C.  GUILE
provides a machine-independent execution platform that can be linked in
as a library during the building of extensible programs.

Install the guile package if you'd like to add extensibility to programs
that you are developing.

%package -n compat32-%{name}-devel
Summary: Libraries and header files for the GUILE extensibility library.
Summary(ja): GUILE 用の開発ライブラリおよびヘッダファイル
Group: Development/Libraries
Requires: %{name}-devel = %{version}-%{release}
Requires: compat32-%{name} = %{version}-%{release}
Requires: compat32-gmp-devel

%description -n compat32-%{name}-devel
The guile-devel package includes the libraries, header files, etc.,
that you'll need to develop applications that are linked with the
GUILE extensibility library.

You need to install the guile-devel package if you want to develop
applications that will be linked to GUILE.  You'll also need to
install the guile package.

%prep
%setup -q
#%patch1 -p1 -b .rpath
#%patch2 -p1 -b .unknown_arch
#%patch3 -p1 -b .ppc64
#%patch4 -p1 -b .ltdl
#%patch5 -p1 -b .64bit

#%patch11 -p1 -b .multilib
#%patch12 -p1 -b .testsuite
%patch14 -p1 -b .deplibs

%build
%configure --disable-static --disable-error-on-warning

# Remove RPATH
sed -i 's|" $sys_lib_dlsearch_path "|" $sys_lib_dlsearch_path %{_libdir} "|' \
    {,guile-readline/}libtool

make %{?_smp_mflags}


%install
rm -rf ${RPM_BUILD_ROOT}

make DESTDIR=${RPM_BUILD_ROOT} install

mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/guile/site

rm -f ${RPM_BUILD_ROOT}%{_libdir}/libguile*.la
rm -f ${RPM_BUILD_ROOT}%{_infodir}/dir

# Compress large documentation
bzip2 NEWS

for i in ${RPM_BUILD_ROOT}%{_infodir}/goops.info; do
    iconv -f iso8859-1 -t utf-8 < $i > $i.utf8 && mv -f ${i}{.utf8,}
done

touch ${RPM_BUILD_ROOT}%{_datadir}/guile/%{mver}/slibcat
ln -s ../../slib ${RPM_BUILD_ROOT}%{_datadir}/guile/%{mver}/slib


%clean
rm -rf ${RPM_BUILD_ROOT}

%post
/sbin/ldconfig
/sbin/install-info  %{_infodir}/guile.info.gz %{_infodir}/dir
/sbin/install-info  %{_infodir}/r5rs.info.gz %{_infodir}/dir
/sbin/install-info  %{_infodir}/goops.info.gz %{_infodir}/dir
/sbin/install-info  %{_infodir}/guile-tut.info.gz %{_infodir}/dir

%postun -p /sbin/ldconfig

%preun
if [ "$1" = 0 ]; then
    /sbin/install-info --delete %{_infodir}/guile.info.gz %{_infodir}/dir
    /sbin/install-info --delete %{_infodir}/r5rs.info.gz %{_infodir}/dir
    /sbin/install-info --delete %{_infodir}/goops.info.gz %{_infodir}/dir
    /sbin/install-info --delete %{_infodir}/guile-tut.info.gz %{_infodir}/dir
fi
:

%post -n compat32-%{name} -p /sbin/ldconfig

%postun -n compat32-%{name} -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc AUTHORS COPYING* ChangeLog HACKING NEWS.bz2 README THANKS
%{_bindir}/guile
%{_bindir}/guile-tools
%{_libdir}/libguile*.so.*
%{_libdir}/libguilereadline-*.so
%{_libdir}/libguile-srfi-srfi-*.so
%dir %{_datadir}/guile
%dir %{_datadir}/guile/%{mver}
%{_datadir}/guile/%{mver}/ice-9
%{_datadir}/guile/%{mver}/lang
%{_datadir}/guile/%{mver}/oop
%{_datadir}/guile/%{mver}/scripts
%{_datadir}/guile/%{mver}/srfi
%{_datadir}/guile/%{mver}/guile-procedures.txt
%ghost %{_datadir}/guile/%{mver}/slibcat
%ghost %{_datadir}/guile/%{mver}/slib
%dir %{_datadir}/guile/site
%dir %{_datadir}/emacs/site-lisp
%{_datadir}/emacs/site-lisp/*.el
%{_infodir}/*
%{_mandir}/man1/guile.1*

%files devel
%defattr(-,root,root,-)
%{_bindir}/guile-config
%{_bindir}/guile-snarf
%{_datadir}/aclocal/*
%{_libdir}/libguile.so
%{_libdir}/pkgconfig/*.pc
%{_includedir}/guile
%{_includedir}/libguile
%{_includedir}/libguile.h

# compat32
%if %{build_compat32}
%files -n compat32-%{name}
%defattr(-,root,root,-)
%{_libdir}/libguile*.so.*
%{_libdir}/libguilereadline-*.so
%{_libdir}/libguile-srfi-srfi-*.so

%files -n compat32-%{name}-devel
%defattr(-,root,root,-)
%{_libdir}/libguile.so
%{_libdir}/pkgconfig/*.pc
%endif

%changelog
* Tue Nov 03 2009 Yasumichi Akahoshi <yasumichi@vinelinux.org> 1.8.7-1
- new upstream release.
- comment out Patch11,12.

* Fri Jul 24 2009 NAKAMURA Kenta <kenta@vinelinux.org> 1.8.6-4
- added Requires: gmp-devel to guile-devel

* Sat Jun 27 2009 NAKAMURA Kenta <kenta@vinelinux.org> 1.8.6-3
- added compat32 package for x86_64 arch support

* Wed Apr 15 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 1.8.6-2
- rebuild with libtool-2.2.6a

* Mon Jan 12 2009 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 1.8.6-1
- new upstream release
- import some patches from fedora development
- drop some old patches
- update spec based on fedora package
- spec in utf-8

* Tue May 13 2008 Yasumichi Akahoshi <yasumichi@vinelinux.org> 1.6.7-6vl5
- use macro for Release

* Sat May 10 2008 Yasumichi Akahoshi <yasumichi@vinelinux.org> 1.6.7-5vl5
- apply new virsioning policy.
- remove *.la

* Sun Apr 23 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.6.7-4vl2
- rebuilt with readline 5.1

* Sun Oct 23 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.6.7-4vl1
- added Patches from Fedora
  * Fri Sep 02 2005 Phil Knirsch <pknirsch@redhat.com> 5:1.6.7-4
  - Fix dynamic linking on 64bit archs (#159971)
  * Tue Dec 21 2004 Phil Knirsch <pknirsch@redhat.com> 5:1.6.4-16
  - Moved info files to base package as they are not devel related (#139948)
  - Moved static guilereadline and guile-srfi-srfi libs to devel package (#140893)
  - Fixed guile-tools not finding guile lib dir (#142642)
  - Added some nice tools (#142642)
  - Removed smp build, seems to be broken atm

* Fri Jan  7 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.6.7-0vl1
- new upstream release
- dropped patch2, 4, 6
- added BuildPrereq: perl

* Fri Jan  2 2004 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.6.4-0vl2
- rebuild with new toolchains
- s/Copyright/License/
- added srfi libs
- patch for ppc64 from Fedora package

* Thu May 15 2003 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.6.4-0vl1
- update to 1.6.4

* Wed Apr 02 2003 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 1.6.3-0vl3
- rebuild with readline-4.3

* Thu Feb 13 2003 Ryoichi INAGAKI <ryo1i@bc.wakwak.com> 1.6.3-0vl2
- based on Rawhide 1.6.0-4
  - Included s390 as working arch as well, switch to general unknown arch patch
  - rebuild to fix broken deps
  - fix continuations.h on ia64
- new upstream 1.6.3

* Mon Mar 26 2001 Kazuhisa TAKEI <takei@vinelinux.org> 1.3.4-9vl1
- porting for Vine Linux
- remove 1.3 patches( not required  so that upstream upgrade )

* Fri Jul 14 2000 Nalin Dahyabhai <nalin@redhat.com>
- Add version number to prereq for umb-scheme to get the post-install to
  work properly.

* Thu Jul 13 2000 Nalin Dahyabhai <nalin@redhat.com>
- Add an Epoch = 1 in case anyone happened to have 1.4 installed.

* Thu Jul 13 2000 Prospector <bugzilla@redhat.com>
- automatic rebuild

* Tue Jul 11 2000 Nalin Dahyabhai <nalin@redhat.com>
- Back down to 1.3.4.
- Fix to actually link against the version of libguile in the package.

* Sun Jun  4 2000 Nalin Dahyabhai <nalin@redhat.com>
- FHS fixups using the %%{makeinstall} macro.

* Sun Mar 26 2000 Florian La Roche <Florian.LaRoche@redhat.com>
- fix preun-devel
- call ldconfig directly in postun

* Fri Mar 24 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- rebuild with new readline
- update to 1.3.4

* Mon Feb 28 2000 Nalin Dahyabhai <nalin@redhat.com>
- using the same catalog as umb-scheme makes umb-scheme a prereq

* Thu Feb 17 2000 Florian La Roche <Florian.LaRoche@redhat.com>
- readline is needed for %post

* Tue Feb  8 2000 Nalin Dahyabhai <nalin@redhat.com>
- use the same catalog as umb-scheme

* Thu Sep  2 1999 Jeff Johnson <jbj@redhat.com>
- fix broken %postun

* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> 
- auto rebuild in the new build environment (release 6)

* Wed Mar 17 1999 Michael Johnson <johnsonm@redhat.com>
- added .ansi patch to fix #endif

* Wed Feb 10 1999 Cristian Gafton <gafton@redhat.com>
- add patch for the scm stuff

* Sun Jan 17 1999 Jeff Johnson <jbj@redhat.com>
- integrate changes from rhcn version (#640)

* Tue Jan 12 1999 Cristian Gafton <gafton@redhat.com>
- call libtoolize first to get it to compile on the arm

* Sat Jan  9 1999 Todd Larason <jtl@molehill.org>
- Added "Requires: guile" at suggestion of Manu Rouat <emmanuel.rouat@wanadoo.fr>

* Fri Jan  1 1999 Todd Larason <jtl@molehill.org>
- guile-devel does depend on guile
- remove devel dependancy on m4
- move guile-snarf from guile to guile-devel
- Converted to rhcn

* Wed Oct 21 1998 Jeff Johnson <jbj@redhat.com>
- update to 1.3.
- don't strip libguile.so.*.0.0. (but set the execute bits).

* Thu Sep 10 1998 Cristian Gafton <gafton@redhat.com>
- spec file fixups

* Wed Sep  2 1998 Michael Fulbright <msf@redhat.com>
- Updated for RH 5.2

* Mon Jan 26 1998 Marc Ewing <marc@redhat.com>
- Started with spec from Tomasz Koczko <kloczek@idk.com.pl>
- added slib link

* Thu Sep 18 1997 Tomasz Koczko <kloczek@idk.com.pl>          (1.2-3)
- added %attr(-, root, root) for %doc, 
- in %post, %postun ldconfig runed as parameter "-p",
- removed /bin/sh from requires,
- added %description,
- changes in %files.

* Fri Jul 11 1997 Tomasz Koczko <kloczek@rudy.mif.pg.gda.pl>  (1.2-2)
- all rewrited for using Buildroot,
- added %postun,
- removed making buid logs,
- removed "--inclededir", added "--enable-dynamic-linking" to configure
  parameters,
- added striping shared libs and /usr/bin/guile,
- added "Requires: /bin/sh" (for guile-snarf) in guile package and
  "Requires: m4" for guile-devel,
- added macro %{PACKAGE_VERSION} in "Source:" and %files,
- added %attr macros in %files.
