%define majorver 8.5
%define minorver 15
%define version %{majorver}.%{minorver}
%define htmlver %{majorver}.15

%{!?sdt:%define sdt 0}

Summary: A Tcl/Tk development environment: tcl
Summary(ja): Tcl/Tk 開発環境: tcl
Name: tcl
Version: %{version}
Release: 3%{?_dist_release}
Group: Development/Languages
License: TCL
URL:     http://tcl.sourceforge.net/

Source0: http://prdownloads.sourceforge.net/tcl/%{name}%{version}-src.tar.gz
Source1: http://prdownloads.sourceforge.net/tcl/%{name}%{htmlver}-html.tar.gz
# patches from Red Hat Enterprise Linux tcl-8.5.7-6.el6
Patch100: tcl-8.5.1-autopath.patch
Patch101: tcl-8.5.15-conf.patch
Patch102: tcl-8.5.0-hidden.patch

Buildroot: %{_tmppath}/%{name}-%{version}-root
Buildrequires: autoconf
BuildRequires: zlib-devel
%if %sdt
BuildRequires: systemtap-sdt-devel
%endif

Vendor: Project Vine
Distribution: Vine Linux

%description
Tcl is a simple scripting language designed to be embedded into
other applications.  Tcl is designed to be used with Tk, a widget
set, which is provided in the tk package.  This package also includes
tclsh, a simple example of a Tcl application.

%description -l ja
Tcl は様々なアプリケーションの実行を行うための、簡単なスクリプ
ト言語です。Tclはウィジッド・セットであるTkとともに用いるように
デザインしています。このパッケージにはTclの簡単な例として、tclsh 
も含んでいます。

%package devel
Summary: Tcl scripting language development environment
Summary(ja): Tcl スクリプト言語の開発環境
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}

%description devel
Tcl is a simple scripting language designed to be embedded into
other applications.  Tcl is designed to be used with Tk, a widget
set, which is provided in the tk package.  This package also includes
tclsh, a simple example of a Tcl application.

The package contains the development files and man pages for tcl.


%prep
%setup -n %{name}%{version} -q -a 1
mv tcl%{htmlver}/html .

%patch100 -p1 -b .autopath
%patch101 -p1 -b .conf
%patch102 -p1 -b .hidden

%build
pushd unix
autoconf
%configure \
%if %sdt
--enable-dtrace \
%endif
--disable-threads \
--enable-symbols \
--enable-shared

make %{?_smp_mflags} TCL_LIBRARY=%{_datadir}/%{name}%{majorver}


%install
rm -rf $RPM_BUILD_ROOT
make install -C unix INSTALL_ROOT=$RPM_BUILD_ROOT TCL_LIBRARY=%{_datadir}/%{name}%{majorver}

ln -s tclsh%{majorver} $RPM_BUILD_ROOT%{_bindir}/tclsh

# for linking with -lib%{name}
ln -s lib%{name}%{majorver}.so $RPM_BUILD_ROOT%{_libdir}/lib%{name}.so

mkdir -p $RPM_BUILD_ROOT/%{_libdir}/%{name}%{majorver}

# postgresql and maybe other packages too need tclConfig.sh
# paths don't look at /usr/lib for efficiency, so we symlink into tcl8.5 for now
ln -s %{_libdir}/%{name}Config.sh $RPM_BUILD_ROOT/%{_libdir}/%{name}%{majorver}/%{name}Config.sh

mkdir -p $RPM_BUILD_ROOT/%{_includedir}/%{name}-private/{generic,unix}
find generic unix -name "*.h" -exec cp -p '{}' $RPM_BUILD_ROOT/%{_includedir}/%{name}-private/'{}' ';'
( cd $RPM_BUILD_ROOT/%{_includedir}
	for i in *.h ; do
		[ -f $RPM_BUILD_ROOT/%{_includedir}/%{name}-private/generic/$i ] && ln -sf ../../$i $RPM_BUILD_ROOT/%{_includedir}/%{name}-private/generic ;
	done
)

# remove buildroot traces
sed -i -e "s|$PWD/unix|%{_libdir}|; s|$PWD|%{_includedir}/%{name}-private|" $RPM_BUILD_ROOT/%{_libdir}/%{name}Config.sh
rm -rf $RPM_BUILD_ROOT/%{_datadir}/%{name}%{majorver}/tclAppInit.c
rm -rf $RPM_BUILD_ROOT/%{_datadir}/%{name}%{majorver}/ldAix

%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc README changes 
%doc license.terms
%doc html/*
%{_bindir}/tclsh*
%{_libdir}/libtcl%{majorver}.so
%dir %{_libdir}/tcl%{majorver}
%{_datadir}/%{name}8
%{_datadir}/tcl%{majorver}
%{_mandir}/man1/*
%{_mandir}/mann/*

%files devel
%defattr(-,root,root,-)
%{_includedir}/*
%{_libdir}/libtcl.so
%{_libdir}/libtclstub%{majorver}.a
%{_libdir}/tclConfig.sh
%{_libdir}/tcl%{majorver}/tclConfig.sh
%{_mandir}/man3/*

%changelog
* Mon Jan 26 2015 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 8.5.15-3
- split development files into devel subpackage

* Wed Jan 15 2014 NAKAMURA Kenta <kenta@vinelinux.org> 8.5.15-2
- rebuilt with the current environment

* Tue Oct 01 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 8.5.15-1
- update to 8.5.15
- update Patch101 (tcl-8.5.15-conf.patch)
- remove Patch103 (tcl-8.5.7-sigabrt.patch)

* Fri Jan  4 2013 IWAI, Masaharu <iwai@alib.jp> 8.5.7-1
- update to 8.5.7: sync Red Hat Enterprise Linux 6 tcl-8.5.7-6.el6
- update License: TCL
- drop obsolete patches
 - tclm4-soname patch (Patch1)
 - lib-perm patch (Patch2)
 - configure patch (Patch3)
 - no rpath patch (Patch4)
 - init lib64 patch (Patch10)
- add some patches from RHEL tcl-8.5.7-6.el6
 - autopath patch (Patch100)
 - conf patch (Patch101)
 - hidden patch (Patch102)
 - sigabrt patch (Patch103)
- update build and install section: sync RHEL tcl-8.5.7-6.el6
- add BR: systemtap-sdt-devel: default disable

* Thu Apr 21 2011 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 8.4.19-4
- added imake to BR:.

* Sat Apr 16 2011 Shu KONNO <owa@bg.wakwak.com> 8.4.19-3
- rebuilt with rpm-4.8.1-3

* Tue Jun 29 2010 Shu KONNO <owa@bg.wakwak.com> 8.4.19-2
- rebuilt with new environment
- updated Patch3: tcl8.4.16-configure.patch

* Tue Jun 09 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 8.4.19-1
- new upstream release

* Tue Sep 30 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 8.4.18-2
- spec in UTF-8
- configure with disabled threads. See:
  https://bugzilla.redhat.com/show_bug.cgi?id=443246
  http://groups.google.com/group/comp.lang.tcl/msg/ce6a1324bada8db0

* Mon May 12 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 8.4.18-1
- rebuild with new environment

* Sun Feb 17 2008 Shu KONNO <owa@bg.wakwak.com> 8.4.18-0vl1
- updated tcl to 8.4.18
- updated tcl-html to 8.4.18

* Mon Oct 08 2007 Shu KONNO <owa@bg.wakwak.com> 8.4.16-0vl1
- updated tcl to 8.4.16
- updated tcl-html to 8.4.16
- dropt Patch3: tcl8.3.5-tclConfig-package-path-90160.patch
- added Patch3: tcl8.4.16-configure.patch

* Wed Jun 13 2007 Shu KONNO <owa@bg.wakwak.com> 8.4.15-0vl1
- updated tcl to 8.4.15
- updated tcl-html to 8.4.15
- dropt Patch1: tcl-8.3.5-tclm4-soname.patch
- added Patch10: tcl-8.4.15-init.lib64.patch
- rebuilt with new toolchain

* Wed May 10 2006 IWAI, Masaharu <iwai@alib.jp> 8.4.13-0vl1
- updated tcl to 8.4.13
- updated tcl-html to 8.4.13

* Sat Jan 28 2006 Shu KONNO <owa@bg.wakwak.com> 8.4.12-0vl1
- updated tcl to 8.4.12
- updated patch4

* Sat Aug 13 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 8.4.11-0vl1
- updated tcl to 8.4.11
- updated Patch4

* Thu Jun 24 2004 Shu KONNO <owa@bg.wakwak.com> 8.4.6-0vl1
- updated tcl to 8.4.6

* Mon Jan 12 2004 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 8.4.5-3vl2
- merged with fedora
  * Mon Dec  1 2003 Thomas Woerner <twoerner@redhat.com> 8.4.5-3
  - removed rpath (patch 4)

  * Fri Nov 28 2003 Jens Petersen <petersen@redhat.com> - 8.4.5-2
  - put private header files under generic and unix subdirs
  - include real generic/tclPort.h not just a symlink to tclUnixPort.h
  - add tclMath.h to %{_includedir}/tcl-private/generic for building tk

  * Thu Nov 27 2003 Jens Petersen <petersen@redhat.com> - 8.4.5-1
  - new package split out from tcltk
  - update to tcl 8.4.5 (#88429)
    - drop tcl-8.3.3-heiierarchy.patch, tcl-8.3.3-dlopen.patch
      and tcl8.3.5-koi8-u.enc-88806.patch
  - include private include headers under %{_includedir}/tcl-private
  - filtered changelog for tcl
  - buildrequire autoconf213 (#110583) [mvd@mylinux.com.ua]

* Sat Mar 29 2003 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 8.4.2-0vl1
- update based on BitWalk's tcltk-8.4.2-83bw

* Thu Nov 15 2001 Kazuhisa TAKEI <takei@linux.or.jp>
- split source package.

* Sun Jul 15 2001 Daisuke SUZUKI <daisuke@linux.or.jp> 8.0.5_jp-10vl2
- expand some macros.. (FIXME)

* Sat Jul 14 2001 Daisuke SUZUKI <daisuke@linux.or.jp> 8.0.5_jp-10vl1
- use %configure macros
- add Patch 47,50

* Thu May 31 2001 <sagami@vinelinux.org>
- 8.0.5_jp-10
- unexpand old %%{configure}, new one causes build failure
- fixed missing libtkx.so libtclx.so symlink in /usr/lib
- install manpages into %%{_mandir} and mode 644

* Wed Jul 19 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 8.0.5_jp-9
- modified %install section to handle compressed man pages
- fixed /usr/lib/tk8.0jp/demos.jp/images symlink

* Sun Jul  2 2000 Daisuke SUZUKI <daisuke@linux.or.jp>
- changed default fonts

* Tue Jan 25 2000 Jun Nishii <jun@vinelinux.org>
- added defattr

* Mon Jan 24 2000 Jun Nishii <jun@vinelinux.org>
- added some symlinks, such as libtcl8.0.so.
- obsoletes version number using _jp, now 8.0.5-31vl1

* Wed Jan 5 2000 Norihito Ohmori <nono@vinelinux.org>
- Apply Tcl/Tk 8.0 Japanese Patch 1.7

* Tue Nov 30 1999 Jakub Jelinek <jakub@redhat.com>
- fix tclX symlinks.
- compile on systems where SIGPWR == SIGLOST.

* Sat May  1 1999 Jeff Johnson <jbj@redhat.com>
- update tcl/tk to 8.0.5.
- avoid "containing" in Tix (#2332).

* Thu Apr  8 1999 Jeff Johnson <jbj@redhat.com>
- use /usr/bin/write in kibitz (#1320).
- use cirrus.sprl.umich.edu in weather (#1926).

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

* Mon Mar 08 1999 Preston Brown <pbrown@redhat.com>
- whoops, exec-prefix for itcl was set to '/foo', changed to '/usr'.

* Tue Feb 16 1999 Jeff Johnson <jbj@redhat.com>
- expect does unaligned access on alpha (#989)
- upgrade tcl/tk/tclX to 8.0.4
- upgrade expect to 5.28.
- add itcl 3.0.1

* Tue Jan 12 1999 Cristian Gafton <gafton@redhat.com>
- call libtoolize to allow building on the arm
- build for glibc 2.1
- strip binaries

* Thu Sep 10 1998 Jeff Johnson <jbj@redhat.com>
- update tcl/tk/tclX to 8.0.3, expect is updated also.

* Mon Jun 29 1998 Jeff Johnson <jbj@redhat.com>
- expect: mkpasswd needs delay before sending password (problem #576)

* Thu May 07 1998 Prospector System <bugs@redhat.com>
- translations modified for de, fr, tr

* Sat May 02 1998 Cristian Gafton <gafton@redhat.com>
- fixed expect binaries exec permissions

* Thu Apr 09 1998 Erik Troan <ewt@redhat.com>
- updated to Tix 4.1.0.006
- updated version numbers of tcl/tk to relflect includsion of p2

* Wed Mar 25 1998 Cristian Gafton <gafton@redhat.com>
- updated tcl/tk to patch level 2
- updated tclX to 8.0.2

* Thu Oct 30 1997 Otto Hammersmith <otto@redhat.com>
- fixed filelist for tix... replacing path to the expect binary in scripts
  was leaving junk files around.

* Wed Oct 22 1997 Otto Hammersmith <otto@redhat.com>
- added patch to remove libieee test in configure.in for tcl and tk.
  Shoudln't be needed anymore for glibc systems, but this isn't the "proper" 
  solution for all systems
- fixed src urls

* Mon Oct 06 1997 Erik Troan <ewt@redhat.com>
- removed version numbers from descriptions

* Mon Sep 22 1997 Erik Troan <ewt@redhat.com>
- updated to tcl/tk 8.0 and related versions of packages

* Tue Jun 17 1997 Erik Troan <ewt@redhat.com>
- built against glibc
- fixed dangling tclx/tkx symlinks