%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}
%{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}

Summary: A development library for text mode user interfaces.
Summary(ja): テキストモードインターフェースのための開発ライブラリ
Name: newt
Version: 0.52.14
Release: 1%{?_dist_release}
License: LGPL
Group: System Environment/Libraries
URL: https://fedorahosted.org/newt/

Source: https://fedorahosted.org/releases/n/e/newt/newt-%{version}.tar.gz
# patches from mdv
Patch1: newt-0.51.4-fix-wstrlen-for-non-utf8-strings.patch
# patches from ubuntu
Patch10: 400_python_memory_allocation.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: python-devel, popt-devel, slang-devel
Provides: snack = %{version}-%{release}

Vendor: Project Vine
Distribution: Vine Linux
Packager: daisuke


%description
Newt is a programming library for color text mode, widget based user
interfaces.  Newt can be used to add stacked windows, entry widgets,
checkboxes, radio buttons, labels, plain text fields, scrollbars,
etc., to text mode user interfaces.  This package also contains the
shared library needed by programs built with newt, as well as a
/usr/bin/dialog replacement called whiptail.  Newt is based on the
slang library.


%package devel
Summary: Newt windowing toolkit development files.
Summary(ja): Newt ウィンドウツールキット開発ファイル集
Requires: slang-devel %{name} = %{version}
Group: Development/Libraries


%description devel
The newt-devel package contains the header files and libraries
necessary for developing applications which use newt.  Newt is a
development library for text mode user interfaces.  Newt is based on
the slang library.

Install newt-devel if you want to develop applications which will use
newt.


## to build compat32 for x86_64 architecture support
%package -n compat32-%{name}
Summary: A development library for text mode user interfaces.
Group: System Environment/Libraries
%description -n compat32-%{name}
Newt is a programming library for color text mode, widget based user
interfaces.  Newt can be used to add stacked windows, entry widgets,
checkboxes, radio buttons, labels, plain text fields, scrollbars,
etc., to text mode user interfaces.  This package also contains the
shared library needed by programs built with newt, as well as a
/usr/bin/dialog replacement called whiptail.  Newt is based on the
slang library.

%package -n compat32-%{name}-devel
Summary: Newt windowing toolkit development files.
Group: Development/Libraries
Requires: compat32-%{name} = %{version}
%description -n compat32-%{name}-devel
The newt-devel package contains the header files and libraries
necessary for developing applications which use newt.  Newt is a
development library for text mode user interfaces.  Newt is based on
the slang library.

Install newt-devel if you want to develop applications which will use
newt.


%prep
%setup -q -n %{name}-%{version}
%patch1 -p1 -b .fix-wstrlen-for-non-utf8-strings
%patch10 -p1 -b .python_memory_allocation

%build
%if %{build_compat32}
export CC='gcc -m32'
%configure --without-tcl
make CC='gcc -m32'
#make CC='gcc -m32' shared
%else
%configure --without-tcl
make
make shared
%endif
chmod 0644 peanuts.py popcorn.py

%install
rm -rf $RPM_BUILD_ROOT
make instroot=$RPM_BUILD_ROOT install

%find_lang %{name}

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%if %{build_compat32}
%post -n compat32-%{name} -p /sbin/ldconfig
%postun -n compat32-%{name} -p /sbin/ldconfig
%endif

%clean
rm -rf $RPM_BUILD_ROOT

%files -f %{name}.lang
%defattr (-,root,root)
%doc CHANGES COPYING
%{_libdir}/libnewt.so.*
%{_bindir}/whiptail
%{python_sitearch}/*.py*
%{python_sitearch}/*.so
%{_mandir}/man1/whiptail.1*

%files devel
%defattr (-,root,root)
%doc tutorial.sgml peanuts.py popcorn.py
%{_includedir}/newt.h
%{_libdir}/libnewt.a
%{_libdir}/libnewt.so
%{_libdir}/pkgconfig/libnewt.pc

%if %{build_compat32}
%files -n compat32-%{name}
%defattr (-,root,root)
%{_libdir}/libnewt.so.*

%files -n compat32-%{name}-devel
%defattr (-,root,root)
%{_libdir}/libnewt.a
%{_libdir}/libnewt.so
%endif


%changelog
* Sun Feb 19 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.52.14-1
- new upstram release

* Thu Oct 06 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 0.52.13-1
- new upstram release

* Sat Jun 04 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 0.52.12-2
- add patch2,3 from mdv
- add patch10 from ubuntu

* Tue May 31 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 0.52.12-1
- update to 0.52.12
- add patch0: don't hang in form when stdin disappears
- remove patch100, fixed in upstream

* Mon Apr 18 2011 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.52.10-7
- rebuilt with recent environment.

* Fri Feb 12 2010 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 0.52.10-6
- rebuilt with gcc-4.4.3-3 on ppc

* Fri Feb  5 2010 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 0.52.10-5
- rebuilt with rpm-4.8.0-3 (on ppc)

* Wed Feb 03 2010 Shu KONNO <owa@bg.wakwak.com> 0.52.10-4
- rebuilt with python-2.6.4

* Thu Oct  8 2009 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 0.52.10-3
- fix build_compat32 if-endif

* Sat Sep 26 2009 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 0.52.10-2
- add patch100 for fix CVE-2009-2905 (textbox BoF) from fc10

* Sun Aug 24 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 0.52.10-1
- new upstream release
- use %%python_sitearch macro
- remove --with-gpm-support
- drop obsolete patches

* Sun Aug 20 2006 NAKAMURA Kenta <kenta@vinelinux.org> 0.50.35-0vl6
- rebuild to fix dependency problem on x86_64 architecture

* Thu Feb 16 2006 Shu KONNO <owa@bg.wakwak.com> 0.50.35-0vl5
- added BuildRequires: slang-devel
- added newt-0.50.35-Makefile.in.patch
- updated newt-0.50.35-make.patch
- changed /usr/lib to %%{_libdir}
- added compat32-* packages for x86_64 architecture support

* Sun Apr 03 2005 Shu KONNO <owa@bg.wakwak.com> 0.50.35-0vl4
- rebuild with python-2.4.1-0vl1

* Sat Apr 17 2004 Shu KONNO <owa@bg.wakwak.com> 0.50.35-0vl3
- rebuild with python-2.3.3-0vl1

* Sat Apr 10 2004 Shu KONNO <owa@bg.wakwak.com> 0.50.35-0vl2.1
- rebuild with python-2.3.3-0vl0.3 (for TestPkg)

* Wed Jan 29 2003 Tomoya TAKA <taka@vinelinux.org> 0.50.35-0vl2
- build against python-2.2
- drop Patch20

* Thu Oct 10 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 0.50.35-0vl1
- updated to new upstream release 0.50.35
- updated Patch11 and added Patch20
  (Patch20 is for python 1.5: REMOVE IT WHEN WE DECIDED TO GO WITH PYTHON2)

* Sat Mar 09 2002 Tomoya TAKA <taka@vinelinux.org> 0.50.33-0vl1
- update to new upstream release

* Mon Jul  2 2001 MATUBARA Kazuyuki <matubara@mb.asmnet.ne.jp>
- 0.50.22-0vl1
- updated to 0.50.22
- use Release No for Vine Linux
- use better macros
- bytecompile the snack python module

* Wed Sep 29 1999 Norihito Ohmori <ohmori@flatout.rog>
- fix spec file

* Sun Sep 11 1999 Norihito Ohmori <ohmori@flatout.org>
- added Japanese support patch

* Wed Sep 01 1999 Erik Troan <ewt@redhat.com>
- added suspend/resume to snack

* Tue Aug 31 1999 Matt Wilson <msw@redhat.com>
- enable gpm support

* Fri Aug 27 1999 Matt Wilson <msw@redhat.com>
- added hotkey assignment for gridforms, changed listbox.setcurrent to
  take the item key

* Wed Aug 25 1999 Matt Wilson <msw@redhat.com>
- fixed snack callback function refcounts, as well as optional data args
- fixed suspend callback ref counts

* Mon Aug 23 1999 Matt Wilson <msw@redhat.com>
- added buttons argument to entrywindow

* Thu Aug 12 1999 Bill Nottingham <notting@redhat.com>
- multi-state checkboxtrees. Woohoo.

* Mon Aug  9 1999 Matt Wilson <msw@redhat.com>
- added snack wrappings for checkbox flag setting

* Thu Aug  5 1999 Matt Wilson <msw@redhat.com>
- added snack bindings for setting current listbox selection
- added argument to set default selection in snack ListboxChoiceWindow

* Mon Aug  2 1999 Matt Wilson <msw@redhat.com>
- added checkboxtree
- improved snack binding

* Fri Apr  9 1999 Matt Wilson <msw@redhat.com>
- fixed a glibc related bug in reflow that was truncating all text to 1000
chars

* Fri Apr 09 1999 Matt Wilson <msw@redhat.com>
- fixed bug that made newt apps crash when you hit <insert> followed by lots
of keys

* Mon Mar 15 1999 Matt Wilson <msw@redhat.com>
- fix from Jakub Jelinek for listbox keypresses

* Fri Feb 27 1999 Matt Wilson <msw@redhat.com>
- fixed support for navigating listboxes with alphabetical keypresses

* Thu Feb 25 1999 Matt Wilson <msw@redhat.com>
- updated descriptions
- added support for navigating listboxes with alphabetical keypresses

* Mon Feb  8 1999 Matt Wilson <msw@redhat.com>
- made grid wrapped windows at least the size of their title bars

* Fri Feb  5 1999 Matt Wilson <msw@redhat.com>
- Function to set checkbox flags.  This will go away later when I have
  a generic flag setting function and signals to comps to go insensitive.

* Tue Jan 19 1999 Matt Wilson <msw@redhat.com>
- Stopped using libgpm, internalized all gpm calls.  Still need some cleanups.

* Thu Jan  7 1999 Matt Wilson <msw@redhat.com>
- Added GPM mouse support
- Moved to autoconf to allow compiling without GPM support
- Changed revision to 0.40

* Wed Oct 21 1998 Bill Nottingham <notting@redhat.com>
- built against slang-1.2.2

* Wed Aug 19 1998 Bill Nottingham <notting@redhat.com>
- bugfixes for text reflow
- added docs

* Fri May 01 1998 Cristian Gafton <gafton@redhat.com>
- devel package moved to Development/Libraries

* Thu Apr 30 1998 Erik Troan <ewt@redhat.com>
- removed whiptcl.so -- it should be in a separate package

* Mon Feb 16 1998 Erik Troan <ewt@redhat.com>
- added newtWinMenu()
- many bug fixes in grid code

* Wed Jan 21 1998 Erik Troan <ewt@redhat.com>
- removed newtWinTernary()
- made newtWinChoice() return codes consistent with newtWinTernary()

* Fri Jan 16 1998 Erik Troan <ewt@redhat.com>
- added changes from Bruce Perens
    - small cleanups
    - lets whiptail automatically resize windows
- the order of placing a grid and adding components to a form no longer
  matters
- added newtGridAddComponentsToForm()

* Wed Oct 08 1997 Erik Troan <ewt@redhat.com>
- added newtWinTernary()

* Tue Oct 07 1997 Erik Troan <ewt@redhat.com>
- made Make/spec files use a buildroot
- added grid support (for newt 0.11 actually)

* Mon Jun 02 1997 Erik Troan <ewt@redhat.com>
- Added patched from Clarence Smith for setting the size of a listbox
- Version 0.9

* Tue May 28 1997 Elliot Lee <sopwith@redhat.com> 0.8-2
- Touchups on Makefile
- Cleaned up NEWT_FLAGS_*

* Tue Mar 18 1997 Erik Troan <ewt@redhat.com>
- Cleaned up listbox
- Added whiptail
- Added newtButtonCompact button type and associated colors
- Added newtTextboxGetNumLines() and newtTextboxSetHeight()

* Tue Feb 25 1997 Erik Troan <ewt@redhat.com>
- Added changes from sopwith for C++ cleanliness and some listbox fixes.

