%define	tcl_major	8.4
%define	tk_major	8.4
%define thread_major	2.6
%define	itcl_major	3.2
%define	itclvers	%{itcl_major}.1

Summary: [Incr Tcl] OOP Extension for TCL
Summary(ja): [Incr Tcl] TCL のオブジェクト指向拡張
Name: itcl
Version: %{itclvers}
Release: 2%{?_dist_release}
Group: Development/Languages
License: BSD
Source0: http://prdownloads.sourceforge.net/incrtcl/itcl%{itclvers}_src.tgz
Patch31: itcl-3.2.1-makecfg.patch

BuildRequires: tcl >= %{tcl_major}
BuildRequires: tk >= %{tk_major}
BuildRequires: thread >= %{thread_major}
Requires: tcl >= %{tcl_major}
Requires: tk >= %{tk_major}
Requires: thread >= %{thread_major}
Buildroot: %{_tmppath}/%{name}-%{version}-root
Distribution: Vine Linux
Vendor: Project Vine

%description 
[incr Tcl] is an object-oriented extension of the Tcl language.  It
was created to support more structured programming in Tcl.  Tcl scripts
that grow beyond a few thousand lines become extremely difficult to
maintain.  This is because the building blocks of vanilla Tcl are
procedures and global variables, and all of these building blocks
must reside in a single global namespace.  There is no support for
protection or encapsulation.

[incr Tcl] introduces the notion of objects.  Each object is a bag
of data with a set of procedures or "methods" that are used to
manipulate it.  Objects are organized into "classes" with identical
characteristics, and classes can inherit functionality from one
another.  This object-oriented paradigm adds another level of
organization on top of the basic variable/procedure elements, and
the resulting code is easier to understand and maintain.

%description -l ja
[incr Tcl] は Tcl 言語のオブジェクト指向な拡張キットで、Tcl で
より構造的なプログラムをサポートするために作成されました。
2, 3000 行を超えるくらい増えた Tcl スクリプトは、メンテナンスが極めて
困難です。これは vanilla Tcl を構成するブロックが手続きやグローバル変数
であり、それらすべてのブロック一つのグローバルな名前空間に属さなければ
ならないためです。保護やカプセル化はサポートされておりません。

[incr Tcl]はオブジェクトの概念を導入します。各オブジェクトは、それを操作
するために使用する手続きや「方法」のセットを含んだデータのひと包みになり
ます。オブジェクトはその識別特性により「クラス」化され、クラスはお互いに
機能を継承することができます。このオブジェクト指向のパラダイムにより、基
本的な変数/手続きの要素の上に、別のレベルの組織化を行うことができます。
その結果、コードの理解やメンテナンスが容易になります。

%prep
%setup -q -n %{name}%{itclvers}
%patch31 -p1 -b .makecfg


#==========================================
%build

# make the libraries reentrant
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -D_REENTRANT"

#------------------------------------------
# Itcl
#
%configure \
	--enable-shared \
	--enable-threads \
	--with-tcl=%{_libdir} \
	--with-tk=%{_libdir} \

make

#==========================================
%install
rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}
rm -f *.files


#------------------------------------------
# Itcl
#
%makeinstall \
	ITCL_LIBRARY=$RPM_BUILD_ROOT%{_datadir}/itcl%{itcl_major} \
	ITK_LIBRARY=$RPM_BUILD_ROOT%{_datadir}/itk%{itcl_major}

# fixed *Config variables
ln -sf ../itclConfig.sh $RPM_BUILD_ROOT%{_libdir}/itcl%{itcl_major}/itclConfig.sh
ln -sf ../itkConfig.sh $RPM_BUILD_ROOT%{_libdir}/itk%{itcl_major}/itkConfig.sh

echo "ITCL_SRC_DIR='%{_includedir}/tcl%{tcl_major}/'" >> $RPM_BUILD_ROOT%{_libdir}/itcl%{itcl_major}/itclConfig.sh
echo "ITCL_BUILD_LIB_SPEC='-L%{_libdir} -litcl%{itcl_major}'" >> $RPM_BUILD_ROOT%{_libdir}/itcl%{itcl_major}/itclConfig.sh

# install include files
mkdir -p $RPM_BUILD_ROOT%{_includedir}/tcl%{tcl_major}/generic
mkdir -p $RPM_BUILD_ROOT%{_includedir}/tk%{tk_major}/generic


cp itcl/generic/*.h $RPM_BUILD_ROOT%{_includedir}/tcl%{tcl_major}/generic
cp itk/generic/*.h $RPM_BUILD_ROOT%{_includedir}/tk%{tk_major}/generic

rm -rf  $RPM_BUILD_ROOT%{_mandir}/mann/dialog.*
rm -rf  $RPM_BUILD_ROOT%{_mandir}/mann/menubar.*

echo "%%defattr(-,root,root)" > itcl.files
(find ${RPM_BUILD_ROOT}%{_bindir} ${RPM_BUILD_ROOT}%{_includedir} \
        ${RPM_BUILD_ROOT}%{_mandir} -type f -o -type l;
 find ${RPM_BUILD_ROOT}%{_libdir}/*) | cat - *.files \
        | sort | uniq -u >> itcl.files

set +x +H
for n in `cat itcl.files`; do
        [ -f $n ] || continue
        head -1 $n | grep -q ^#! || continue
        chmod u+w $n
        perl -pi -e "s|${RPM_BUILD_ROOT}||" $n
done
set -x -H

#==========================================
# post process the *.files list, removing build sys references and mark
# which are directories

set +x
for n in *.files; do
        mv $n $n.in
        sed "s|.*%{_prefix}\\>|%{_prefix}|" < $n.in | while read file; do
            if [ -d ${RPM_BUILD_ROOT}/$file ]; then
                echo -n '%dir '
            fi
            echo $file
        done > $n
        rm -f $n.in
done
set -x

# Man pages can be compressed
perl -pi -e 's|(^%{_mandir}/man.*$)|\1\*|' *.files

#==========================================
%post -p /sbin/ldconfig -n itcl

%postun -p /sbin/ldconfig -n itcl

%clean
rm -rf $RPM_BUILD_ROOT

%files -f itcl.files -n itcl
%defattr(-,root,root,-)
%{_datadir}/itcl%{itcl_major}
%{_datadir}/itk%{itcl_major}


%changelog
* Tue Jun 29 2010 Shu KONNO <owa@bg.wakwak.com> 3.2.1-2
- rebuilt with tcl/tk-8.4.19-2

* Sat Jul 26 2008 Shu KONNO <owa@bg.wakwak.com> 3.2.1-1vl5
- applied new versioning policy and spec in utf-8

* Sun Feb 17 2008 Shu KONNO <owa@bg.wakwak.com> 3.2.1-0vl4
- rebuild with tcl/tk-8.4.18

* Tue Jan 01 2008 Shu KONNO <owa@bg.wakwak.com> 3.2.1-0vl3
- moved itcl script path to /usr/share/{itcl3.2,itk3.2} like tcl/tk

* Tue Oct 09 2007 Shu KONNO <owa@bg.wakwak.com> 3.2.1-0vl2
- rebuild with tcl/tk-8.4.16
- changed macro %%thread_major to 2.6
- added {ITCL,ITK}_LIBRARY to %%makeinstall for lib64 support

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

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

* 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
