%define majorver 8.6
%define epoch 1

Name:          tk
Version:       8.6.8
Release:       3
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: tcl-devel = %{epoch}:%{version} autoconf libX11-devel libXft-devel

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

Patch6001:     Bugfix-4966cad4d4-Now-function-NotebookPlaceSlaves-i.patch
Patch6002:     Fix-382712ade6-X11-event-generate-.-KeyPress-segfaul.patch
Patch6003:     Fix-657c389120-and-b4214b4712-Segfault-when-destroyi.patch
Patch6004:     Fix-1821174fff-and-1938774fff-RenderBadPicture-inval.patch
Patch6005:     More-complete-patch-from-Christian-Werner-to-fix-182.patch
Patch6006:     Fix-broken-build-one-line-of-the-patch-was-missing.patch
Patch6007:     Latest-fix-proposal-from-Christian-Werner-revert-the.patch
Patch6008:     Fix-5d991b822e-segmentation-violation-in-TclObjLooku.patch
Patch6009:     Fix-502e74e9ad-crash-for-untrusted-X-connections-for.patch
Patch6010:     Further-patch-from-Christian-Werner-on-the-observati.patch
Patch6011:     Fix-de01e24aa1-Text-replace-command-involving-select.patch
Patch6012:     Fix-fbaed1f66b-image-create-photo-errors-out-on-a-sa.patch
Patch6013:     Fix-3441086fff-ttk-style-layout-with-empty-children-.patch
Patch6014:     More-general-error-message-since-it-can-be-raised-no.patch
Patch6015:     bugfix-branch-for-6fcaaa6f80.patch
Patch6016:     Fix-6437e8d00d-font-24.5-test-fails-on-macOS-and-Lin.patch
Patch6017:     Fix-4b555aca34-text-search-all-hangs-and-eats-all-me.patch
Patch6018:     Another-proposed-fix-for-4b555aca34-text-search-all-.patch
Patch6019:     Third-fix-proposal-for-4b555aca34-text-search-all-ha.patch
Patch6020:     Fix-6b22d436aa-Treeview-ActivateHeading-Binding-Fail.patch
Patch6021:     Crash-prevention.-Still-buggy-now-test-text-11a.22-f.patch
Patch6022:     fix-bug-18a4ba19bd-winfo-containing-gives-wrong-answ.patch
Patch6023:     Avoid-errors-when-a-menu-is-destroyed-before-its-pos.patch
Patch6024:     gif-read-not-complete-on-overflow-image-information-.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
%doc README changes license.terms
%defattr(-,root,root,-)
%{_bindir}/wish*
%{_datadir}/%{name}%{majorver}
%exclude %{_datadir}/%{name}%{majorver}/tkAppInit.c
%{_libdir}/lib%{name}%{majorver}.so
%{_libdir}/%{name}%{majorver}

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

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

%changelog
* 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
