%global itcl_version 4.2.0
%global tdbc_version 1.1.1
%global thread_version 2.8.5

%{!?sdt:%define sdt 0}

Summary: A Tcl/Tk development environment: tcl
Summary(ja): Tcl/Tk 開発環境: tcl
Name: tcl
Version: 8.6.13
%global majorver %(echo %{version} | sed -e 's/\.[0-9]*$//')
%global minorver %(echo %{version} | sed -e 's/^.*\.//')
%global htmlver %{version}
Release: 1%{?_dist_release}
Group: programming
Vendor: Project Vine
Distribution: Vine Linux

License: TCL
URL:     http://tcl.sourceforge.net/
Source0: https://prdownloads.sourceforge.net/tcl/%{name}%{version}-src.tar.gz
#Source1: https://prdownloads.sourceforge.net/tcl/%{name}%{htmlver}-html.tar.gz
Patch0: tcl-8.6.12-autopath.patch
Patch1: tcl-8.6.12-conf.patch
Patch2: tcl-8.6.13-hidden.patch
Patch3: tcl-8.6.13-tcltests-path-fix.patch
Patch4: tcl-8.6.13-configure-c99.patch

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

%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: programming
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.


%package itcl
Summary: Object oriented extensions to Tcl and Tk
Summary(ja): Tcl/Tk のオブジェクト指向拡張
Group: programming
Requires: %{name} = %{version}-%{release}
Provides: itcl = %{itcl_version}
Obsoletes: itcl < 4.0.0

%description itcl
[incr Tcl] is Tcl extension that provides object-oriented features that are
missing from the Tcl language.


%package itcl-devel
Summary: Development headers and libraries for linking against tcl-itcl
Summary(ja): tcl-itclとリンクするためのヘッダ・ライブラリ
Group: programming
Requires: %{name}-itcl = %{version}-%{release}
Provides: itcl-devel = %{itcl_version}
Obsoletes: itcl-devel < 4.0.0

%description itcl-devel
Development headers and libraries for linking against itcl.


%package tdbc
Summary: database extensions to Tcl and Tk
Summary(ja): Tcl/Tk のデータベース拡張
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Provides: tdbc = %{tdbc_version}

%description tdbc
tdbc is Tcl extension that provides database features to tcl/tk.


%package tdbc-devel
Summary: Development headers and libraries for linking against tcl-tdbc
Summary(ja): tcl-tdbcとリンクするためのヘッダ・ライブラリ
Group: programming
Requires: %{name}-tdbc = %{version}-%{release}
Requires: sqlite3-tcl
Provides: tdbc-devel = %{tdbc_version}

%description tdbc-devel
Development headers and libraries for linking against tdbc.


%package thread
Summary: thread extensions to Tcl and Tk
Summary(ja): Tcl/Tk のスレッド拡張
Group: programming
Requires: %{name} = %{version}-%{release}
Provides: thread = %{thread_version}
Obsoletes: thread < 2.8.0

%description thread
 You can use this extension to gain script-level access to Tcl threading
capabilities.


%debug_package


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

%autopatch -p1
rm -rf compat/zlib

pushd unix
sed -i -e 's/@SHLIB_LD@/@SHLIB_LD@ -fPIC -Wl,-soname,libtcl%{majorver}.so/' Makefile.in
popd


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

make %{?_smp_mflags} CFLAGS="%{optflags} -fPIC" 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/'{}' ';'
pushd $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
popd

# 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

# sqlite3 extension is provided by sqlite3-tcl
rm -rf %{buildroot}%{_libdir}/sqlite3*
rm -f %{buildroot}%{_mandir}/mann/sqlite3*

%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%license license.terms
%doc README.md changes
#doc html/*
%{_bindir}/tclsh*
%{_libdir}/libtcl%{majorver}.so
%dir %{_libdir}/tcl%{majorver}
%{_datadir}/%{name}8
%{_datadir}/tcl%{majorver}
%{_mandir}/man1/*
%{_mandir}/mann/*
# itcl
%exclude %{_mandir}/mann/body.n*
%exclude %{_mandir}/mann/class.n*
%exclude %{_mandir}/mann/code.n*
%exclude %{_mandir}/mann/configbody.n*
%exclude %{_mandir}/mann/delete.n*
%exclude %{_mandir}/mann/ensemble.n*
%exclude %{_mandir}/mann/find.n*
%exclude %{_mandir}/mann/is.n*
%exclude %{_mandir}/mann/itcl*.n*
%exclude %{_mandir}/mann/local.n*
%exclude %{_mandir}/mann/scope.n*
# tdbc
%exclude %{_mandir}/mann/tdbc*
# thread
%exclude %{_mandir}/mann/thread.n*
%exclude %{_mandir}/mann/tpool.n*
%exclude %{_mandir}/mann/tsv.n*
%exclude %{_mandir}/mann/ttrace.n*


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

%files itcl
%{_libdir}/itcl*
%exclude %{_libdir}/itcl*/itclConfig.sh
%exclude %{_libdir}/itcl*/libitclstub*.a
%{_mandir}/mann/body.n*
%{_mandir}/mann/class.n*
%{_mandir}/mann/code.n*
%{_mandir}/mann/configbody.n*
%{_mandir}/mann/delete.n*
%{_mandir}/mann/ensemble.n*
%{_mandir}/mann/find.n*
%{_mandir}/mann/is.n*
%{_mandir}/mann/itcl*.n*
%{_mandir}/mann/local.n*
%{_mandir}/mann/scope.n*

%files itcl-devel
%{_libdir}/itcl*/itclConfig.sh
%{_libdir}/itcl*/libitclstub*.a
%{_includedir}/itcl*.h

%files tdbc
%{_libdir}/tdbc*
%exclude %{_libdir}/tdbc*/libtdbcstub*.a
%exclude %{_libdir}/tdbc*/tdbcConfig.sh
%{_bindir}/sqlite3_analyzer
%{_libdir}/tcl8/%{majorver}/tdbc/sqlite3-*.tm
%{_mandir}/mann/tdbc*

%files tdbc-devel
%{_libdir}/tdbc*/libtdbcstub*.a
%{_libdir}/tdbc*/tdbcConfig.sh
%{_includedir}/tdbc*.h

%files thread
%{_libdir}/thread*
%{_mandir}/mann/thread.n*
%{_mandir}/mann/tpool.n*
%{_mandir}/mann/tsv.n*
%{_mandir}/mann/ttrace.n*


%changelog
* Sat Oct 21 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 8.6.13-1
- new upstream release.
- dropped ldconfig scriptlets.
- re-imported patches from rawhide.

* Wed Jul 01 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 8.6.10-1
- new upstream release.
- replaced all patches to the newest rawhide's.

* Fri Oct 04 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 8.6.9-1
- new upstream release.
- dropped Patch101: get same effects by sed and configure options.
- imported Patch103.
- added subpackages: itcl{,-devel}, tdbc{,-devel} and thread.

* 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
