%define majorver 8.6
%define epoch 1

Name:          tk
Version:       8.6.10
Release:       2
Summary:       The graphical toolkit for the Tcl scripting language
Epoch:         1
License:       TCL
URL:           http://tcl.sourceforge.net
Source0:       http://download.sourceforge.net/sourceforge/tcl/%{name}%{version}-src.tar.gz
Requires:      tcl = %{epoch}:%{version} glibc
BuildRequires: gcc
BuildRequires: tcl-devel = %{epoch}:%{version} autoconf libX11-devel libXft-devel

Conflicts:     itcl <= 3.2
Obsoletes:     tile <= 0.8.2
Provides:      tile = 0.8.2

patch0001:     Bugfix-4966cad4d4-Now-function-NotebookPlaceSlaves-i.patch
Patch0002:     Fix-1821174fff-and-1938774fff-RenderBadPicture-inval.patch
Patch0003:     More-complete-patch-from-Christian-Werner-to-fix-182.patch
Patch0004:     Fix-5d991b822e-segmentation-violation-in-TclObjLooku.patch
Patch0005:     Fix-4b555aca34-text-search-all-hangs-and-eats-all-me.patch
Patch0006:     Another-proposed-fix-for-4b555aca34-text-search-all-.patch
Patch0007:     Crash-prevention.-Still-buggy-now-test-text-11a.22-f.patch
Patch0008:     tk-8.6.10-make.patch
Patch0009:     tk-8.6.10-conf.patch
Patch0010:     tk-8.6.7-no-fonts-fix.patch
Patch0011:     tk-8.6.10-font-sizes-fix.patch


%description
TK is a widget toolkit that creates graphical user interface(GUI). It's
especially easy to program a GUI application using tcl script language.


%package devel
Summary: Tk graphical toolkit development files
Requires: %{name} = %{epoch}:%{version}-%{release} libX11-devel libXft-devel tcl-devel = %{epoch}:%{version}

%description devel
Package devel includes files for developing with tk.

%package help
Summary: Documents for tf

%description help
Includes Man pages for tf.

%prep
%autosetup -n %{name}%{version} -p1

%build
cd unix
autoconf
%configure --enable-threads
%make_build CFLAGS="%{optflags}" TK_LIBRARY=%{_datadir}/%{name}%{majorver}

%install
%make_install -C unix INSTALL_ROOT=%{buildroot} TK_LIBRARY=%{_datadir}/%{name}%{majorver}

ln -s wish%{majorver} %{buildroot}%{_bindir}/wish
ln -s lib%{name}%{majorver}.so %{buildroot}%{_libdir}/lib%{name}.so

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

sed -i -e "s|$PWD/unix|%{_libdir}|; s|$PWD|%{_includedir}/%{name}-private|" %{buildroot}/%{_libdir}/%{name}Config.sh

%pre
[ ! -h %{_prefix}/%{_lib}/%{name}%{majorver} ] || rm %{_prefix}/%{_lib}/%{name}%{majorver}

%ldconfig_post
%ldconfig_postun

%files
%defattr(-,root,root,-)
%doc README.md changes license.terms
%{_bindir}/wish*
%{_datadir}/%{name}%{majorver}
%exclude %{_datadir}/%{name}%{majorver}/tkAppInit.c
%{_libdir}/%{name}%{majorver}
%{_libdir}/lib%{name}%{majorver}.so

%files devel
%defattr(-,root,root)
%{_includedir}/*
%{_libdir}/lib%{name}.so
%{_libdir}/%{name}Config.sh
%{_libdir}/pkgconfig/tk.pc
%{_libdir}/lib%{name}stub%{majorver}.a
%{_datadir}/%{name}%{majorver}/tkAppInit.c

%files help
%{_mandir}/man1/*
%{_mandir}/man3/*
%{_mandir}/mann/*

%changelog
* Thu May 27 2021 liuyumeng<liuyumeng5@huawei.com> - 1:8.6.10-2
- Add a BuildRequires for gcc

* Thu Jul 30 2020 chengguipeng<chengguipeng1@huawei.com> - 1:8.6.10-1
- Upgrade to 1:8.6.10-1

* Mon Jan 13 2020 zhangrui <zhangrui182@huawei.com> - 1:8.6.8-4
- del patches to be consistent with open source

* Sat Jan 11 2020 zhangrui <zhangrui182@huawei.com> - 1:8.6.8-3
- del patches to be consistent with open source

* Wed Sep 18 2019 Zaiwang Li<lizaiwang1@huawei.com> - 1:8.6.8-2
- Init package
