Summary: A CRT screen handling and optimization package.
Summary(ja): CRT スクリーンの操作と最適化を行うパッケージ
Name: ncurses
Version: 5.9
%define includedirw %{_includedir}/ncursesw
%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}
Release: 2%{?_dist_release}
License: distributable
Group: System Environment/Libraries
URL: http://dickey.his.com/ncurses/ncurses.html

Source0: ftp://invisible-island.net/ncurses/ncurses-%{version}.tar.gz

Patch1: ncurses-5.9-20110409-20110716.patch.bz2
Patch8: ncurses-config.patch
Patch9: ncurses-libs.patch
Patch11: ncurses-urxvt.patch
Patch12: ncurses-kbs.patch

Requires(post): /sbin/ldconfig

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: pkgconfig

Vendor: Project Vine
Distribution: Vine Linux
Packager: daisuke

%description
The curses library routines are a terminal-independent method of
updating character screens with reasonable optimization.  The ncurses
(new curses) library is a freely distributable replacement for the
discontinued 4.4 BSD classic curses library.


%package devel
Summary: The development files for applications which use ncurses.
Summary(ja): ncurses を用いるアプリケーション開発用のファイル
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Obsoletes: libtermcap-devel <= 2.0.8-46vl1
Provides: libtermcap-devel = 2.0.8-47

%description devel
The header files and libraries for developing applications that use
the ncurses CRT screen handling and optimization package.

Install the ncurses-devel package if you want to develop applications
which will use ncurses.

Use the following compiler flags to build against the ncurses library:
                                                                                
-lncurses
(compile and link against the regular ncurses library)
                                                                                
-I %{includedirw} -lncursesw
(compile and link against the wide-character, UTF-8, library)


%package c++-devel
Summary: C++ bindings to ncurses
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: %{name}-devel = %{version}-%{release}
 
%description c++-devel
C++ bindings to ncurses


%package -n compat32-%{name}
Summary: A CRT screen handling and optimization package.
Summary(ja): CRT スクリーンの操作と最適化を行うパッケージ
Group: System Environment/Libraries
Requires: %{name} = %{version}-%{release}

%description -n compat32-%{name}
The curses library routines are a terminal-independent method of
updating character screens with reasonable optimization.  The ncurses
(new curses) library is a freely distributable replacement for the
discontinued 4.4 BSD classic curses library.


%package -n compat32-%{name}-devel
Summary: The development files for applications which use ncurses.
Summary(ja): ncurses を用いるアプリケーション開発用のファイル
Group: Development/Libraries
Requires: compat32-%{name} = %{version}-%{release}
Requires: %{name}-devel = %{version}-%{release}
Obsoletes: compat32-libtermcap-devel <= 2.0.8-46vl1
Provides: compat32-libtermcap-devel = 2.0.8-47

%description -n compat32-%{name}-devel
The header files and libraries for developing applications that use
the ncurses CRT screen handling and optimization package.

Install the ncurses-devel package if you want to develop applications
which will use ncurses.

Use the following compiler flags to build against the ncurses library:
                                                                                
-lncurses
(compile and link against the regular ncurses library)
                                                                                
-I %{includedirw} -lncursesw
(compile and link against the wide-character, UTF-8, library)


%package -n compat32-%{name}-c++-devel
Summary: C++ bindings to ncurses
Group: System Environment/Libraries
Requires: compat32-%{name} = %{version}-%{release}
Requires: compat32-%{name}-devel = %{version}-%{release}
Requires: %{name}-c++-devel = %{version}-%{release}
 
%description -n compat32-%{name}-c++-devel
C++ bindings to ncurses


%prep
%setup -q
%patch1 -p1

%patch8 -p1 -b .config
%patch9 -p1 -b .libs
%patch11 -p1 -b .urxvt
%patch12 -p1 -b .kbs

find . -name "*.orig" -exec rm -f {} \;


%build
%define rootdatadir /lib
%define ncurses_options \\\
    --with-shared --without-ada --with-ospeed=unsigned \\\
    --enable-hard-tabs --enable-xmc-glitch --enable-colorfgbg \\\
    --with-terminfo-dirs=%{_sysconfdir}/terminfo:%{_datadir}/terminfo:%{rootdatadir}/terminfo \\\
    --enable-overwrite \\\
    --enable-pc-files \\\
    --with-termlib=tinfo \\\
    --with-chtype=long

mkdir narrowc widec
cd narrowc
ln -s ../configure .
%configure %{ncurses_options} --with-ticlib
make %{?_smp_mflags} libs
make %{?_smp_mflags} -C progs

cd ../widec
ln -s ../configure .
%configure %{ncurses_options} --enable-widec --without-progs
make %{?_smp_mflags} libs
cd ..


%install
rm -rf ${RPM_BUILD_ROOT}

make -C narrowc DESTDIR=$RPM_BUILD_ROOT install.{libs,progs,data}
rm -f $RPM_BUILD_ROOT%{_libdir}/libtinfo.*
make -C widec DESTDIR=$RPM_BUILD_ROOT install.{libs,includes,man}

chmod 755 ${RPM_BUILD_ROOT}%{_libdir}/lib*.so.*.*
chmod 644 ${RPM_BUILD_ROOT}%{_libdir}/lib*.a

# move lib{ncurses{,w},tinfo}.so.* to /lib*
mkdir $RPM_BUILD_ROOT/%{_lib}
mv $RPM_BUILD_ROOT%{_libdir}/lib{ncurses{,w},tinfo}.so.* $RPM_BUILD_ROOT/%{_lib}
for l in $RPM_BUILD_ROOT%{_libdir}/lib{ncurses{,w},tinfo}.so; do
    ln -sf $(echo %{_libdir} | \
        sed 's,\(^/\|\)[^/][^/]*,..,g')/%{_lib}/$(readlink $l) $l
done

mkdir -p $RPM_BUILD_ROOT{%{rootdatadir},%{_sysconfdir}}/terminfo

# move few basic terminfo entries to /lib
baseterms=
for termname in \
        ansi dumb linux vt100 vt100-nav vt102 vt220 vt52
do
    for t in $(find $RPM_BUILD_ROOT%{_datadir}/terminfo \
        -samefile $RPM_BUILD_ROOT%{_datadir}/terminfo/${termname::1}/$termname)
    do
        baseterms="$baseterms $(basename $t)"
    done
done
for termname in $baseterms; do
    termpath=terminfo/${termname::1}/$termname
    mkdir $RPM_BUILD_ROOT%{rootdatadir}/terminfo/${termname::1} &> /dev/null || :
    mv $RPM_BUILD_ROOT%{_datadir}/$termpath $RPM_BUILD_ROOT%{rootdatadir}/$termpath
    ln -s $(dirname %{_datadir}/$termpath | \
        sed 's,\(^/\|\)[^/][^/]*,..,g')%{rootdatadir}/$termpath \
        $RPM_BUILD_ROOT%{_datadir}/$termpath
done

# prepare -base and -term file lists
for termname in \
    Eterm cons25 cygwin gnome* hurd jfbterm mach* mlterm mrxvt \
    nsterm putty* pcansi rxvt rxvt-\* screen screen-\* screen.* \
    sun teraterm wsvt25* xfce xterm xterm-\*
do
    for i in $RPM_BUILD_ROOT%{_datadir}/terminfo/?/$termname; do
        for t in $(find $RPM_BUILD_ROOT%{_datadir}/terminfo -samefile $i); do
            baseterms="$baseterms $(basename $t)"
        done
    done
done 2> /dev/null
for t in $baseterms; do
    echo "%dir %{_datadir}/terminfo/${t::1}"
    echo %{_datadir}/terminfo/${t::1}/$t
done 2> /dev/null | sort -u > terms.base
find $RPM_BUILD_ROOT%{_datadir}/terminfo \! -type d | \
    sed "s|^$RPM_BUILD_ROOT||" | while read t
do
    echo "%dir $(dirname $t)"
    echo $t
done 2> /dev/null | sort -u | comm -2 -3 - terms.base > terms.term

cat terms.base terms.term |sort -u > terms.all

# can't replace directory with symlink (rpm bug), symlink all headers
mkdir $RPM_BUILD_ROOT%{_includedir}/ncurses{,w}
for l in $RPM_BUILD_ROOT%{_includedir}/*.h; do
    ln -s ../$(basename $l) $RPM_BUILD_ROOT%{_includedir}/ncurses
    ln -s ../$(basename $l) $RPM_BUILD_ROOT%{_includedir}/ncursesw
done

# don't require -ltinfo when linking with --no-add-needed
for l in $RPM_BUILD_ROOT%{_libdir}/libncurses{,w}.so; do
    soname=$(basename $(readlink $l))
    rm -f $l
    echo "INPUT($soname -ltinfo)" > $l
done
	     
rm -f $RPM_BUILD_ROOT%{_libdir}/libcurses{,w}.so
echo "INPUT(-lncurses)" > $RPM_BUILD_ROOT%{_libdir}/libcurses.so
echo "INPUT(-lncursesw)" > $RPM_BUILD_ROOT%{_libdir}/libcursesw.so

echo "INPUT(-ltinfo)" > $RPM_BUILD_ROOT%{_libdir}/libtermcap.so

rm -f ${RPM_BUILD_ROOT}%{_libdir}/terminfo
#rm -f $RPM_BUILD_ROOT%{_libdir}/pkgconfig/{*_g,ncurses++*}.pc


%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%post -n compat32-%{name} -p /sbin/ldconfig

%postun -n compat32-%{name} -p /sbin/ldconfig


%files -f terms.all
%defattr(-,root,root)
%doc ANNOUNCE AUTHORS README TO-DO
%{_bindir}/[cirt]*
%{_mandir}/man1/*
%{_mandir}/man5/*
%{_mandir}/man7/*
/%{_lib}/lib*.so.*
%{_libdir}/lib*.so.*
%dir %{_sysconfdir}/terminfo
%{rootdatadir}/terminfo
%{_datadir}/tabset
%dir %{_datadir}/terminfo

%files devel
%defattr(-,root,root)
%doc test
%doc doc/html/hackguide.html
%doc doc/html/ncurses-intro.html
%doc c++/README*
%{_bindir}/ncurses*-config
%{_libdir}/lib*.so
%{_libdir}/lib*.a
 %dir %{_includedir}/ncurses
%dir %{_includedir}/ncursesw
%{_includedir}/ncurses/*.h
%{_includedir}/ncursesw/*.h
%{_includedir}/*.h
%{_mandir}/man3/*
%{_libdir}/pkgconfig/*.pc
%exclude %{_libdir}/pkgconfig/ncurses++*.pc

%files c++-devel
%defattr(-,root,root)
%doc c++/NEWS c++/PROBLEMS c++/README*
%{_includedir}/ncurses/cursesapp.h
%{_includedir}/ncurses/curses?.h
%{_includedir}/ncurses/etip.h
%{_libdir}/libncurses++.a
%{_libdir}/libncurses++w.a
%{_libdir}/pkgconfig/ncurses++*.pc

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


%files -n compat32-%{name}-devel
%defattr(-,root,root)
%{_libdir}/lib*.so
%{_libdir}/lib*.a
%{_libdir}/pkgconfig/*.pc
%exclude %{_libdir}/pkgconfig/ncurses++*.pc
 

%files -n compat32-%{name}-c++-devel
%defattr(-,root,root)
%{_libdir}/libncurses++.a
%{_libdir}/libncurses++w.a
%{_libdir}/pkgconfig/ncurses++*.pc
%endif


%clean
rm -rf $RPM_BUILD_ROOT


%changelog
* Tue Dec 14 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 5.9-2
- don't require -ltinfo when linking with --no-add-needed

* Fri Sep 09 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 5.9-1
- update to 5.9 + 20110716
- update all patches
- add pkgconfig file

* Sun Mar 27 2011 IWAI, Masaharu <iwai@alib.jp> 5.6-5
- build with new toolchain

* Fri Mar  5 2010 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 5.6-4
- rebuilt with new toolchain
- add Requires(post,pre): /sbin/ldconfig

* Sat Jun 27 2009 NAKAMURA Kenta <kenta@vinelinux.org> 5.6-3
- updated %%files section on compat32-* packages

* Sun Mar 22 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 5.6-2
- changed c++-devel Group to Development/Libraries
- changelog of 5.6-1 is missing... seemed to be updated on Aug 10 2008 

* Fri Oct 28 2005 NAKAMURA Kenta <kenta@c.csce.kyushu-u.ac.jp> 5.4-0vl3
- added compat32- packages for x86_64 architecture support

* Mon May 17 2004 Tomoya TAKA <taka@vinelinux.org> 5.4-0vl2
- add patch10 taken from fedora's 5.4-4

* Sun May  9 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 5.4-0vl1
- new upstream release
- remove obsolete patches

* Mon Mar 22 2004 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 5.3-9vl1
- synced up with Fedora 5.3-9
  - Thu Sep 11 2003 Adrian Havill <havill@redhat.com> 5.3-9
  - remove not-so safe-sprintf configure option because the code does
    not appear to be stable enough for some apps. (#103790)
 
  - Wed Aug 20 2003 Adrian Havill <havill@redhat.com> 5.3-8.1
  - RHEL bump
 
  - Wed Aug 20 2003 Adrian Havill <havill@redhat.com> 5.3-8
  - multilib patch (#91211)
 
  - Mon Aug 11 2003 Adrian Havill <havill@redhat.com> 5.3-7
  - fixed the safe sprintf code that was enabled in the previous release
    by the configure parameter. (#101486)
 
  - Mon Jun 16 2003 Elliot Lee <sopwith@redhat.com> 5.3-6.1
  - Fix ac25 patch, make it easy to turn off GPM support
 
  - Wed Jun 04 2003 Elliot Lee <sopwith@redhat.com>
  - rebuilt
 
  - Thu May 22 2003 Adrian Havill <havill@redhat.com> 5.3-5
  - added latest rollup patch with widec/UTF8 centric weekly (20030517)
  - added --enable-widec to configure (#86311)
    original work done by Mr. Sam <sam@email-scan.com>
  - require sharutils (#86605)
  - add gpm, xmc support
  - add debug syms back into package
  - updated autoconf/configure patch

* Thu Mar 27 2003 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 5.3-4vl1
- synced Rawhide 5.3-4

* Fri Feb 08 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 5.2-16vl2
- revert to patch13 from 14 for XF86-4

* Wed Feb 06 2002 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 5.2-16vl1
- synced Rawhide 5.2-16

* Tue Aug 28 2001 Shoji Matsumoto <shom@vinelinux.org> 5.2-12vl2
- patch 3 (xterm) disabled. this patch is for XF86-4???

* Wed Aug 22 2001 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 5.2-12vl1
- added kon patch for Vine

* Fri Jul 20 2001 Bernhard Rosenkraenzer <bero@redhat.com> 5.2-12
- Sync terminfo with termcap 11.0.1-10

* Sun Jun 24 2001 Bernhard Rosenkraenzer <bero@redhat.com> 5.2-11
- Update to patchlevel 20010623, fixes some lynx issues
 
* Mon Jun 18 2001 Helge Deller <hdeller@redhat.de>
- fixed tput -S segfaulting bug (#44669)
- use _tmppath for BuildRoot:
- Copyright -> License

* Sun Apr 15 2001 Bernhard Rosenkraenzer <bero@redhat.com>
- Update to patchlevel 20010407

* Tue Mar  6 2001 Bernhard Rosenkraenzer <bero@redhat.com>
- Fix up some terminfo entries containing includes to
  "/var/tmp/ncurses-root/something" (#30771)

* Wed Feb 22 2001 Harald Hoyer <harald@redhat.de>
- fixed rxvt backspace setting

* Fri Feb  9 2001 Yukihiro Nakai <ynakai@redhat.com>
- Update Japanese kterm patch

* Mon Jan 15 2001 Bernhard Rosenkraenzer <bero@redhat.com>
- Update
- Add japanese patch from termcap
- Fix ospeed handling

* Mon Jan  1 2001 Bernhard Rosenkraenzer <bero@redhat.com>
- Add libcurses.a -> libncurses.a symlink (RFE #23023)

* Tue Dec 12 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- Use --with-ospeed='unsigned int'

* Fri Nov 17 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- Fix alpha and ia64
- Rebuild with gcc 2.96-64

* Thu Nov  2 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- 5.2
- Fix typo in man page (Bug #20205)
- update the "screen" terminfo entries to the version supplied with
  screen 3.9.8

* Mon Oct  9 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- Update (fixes the "make menuconfig" bug introduced by the security fix)

* Tue Oct  3 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- Fix security problem (possible buffer overrun)

* Fri Aug  4 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- Add the bugfix patches from the ncurses maintainer

* Thu Jul 13 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- 5.1

* Wed Jul 12 2000 Prospector <bugzilla@redhat.com>
- automatic rebuild

* Mon Jun  5 2000 Matt Wilson <msw@redhat.com>
- *don't ship symlinks from lib*.so.5 to lib*.so.4!
- use FHS macros

* Fri Jun  2 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- rebuild for 7.0
- /usr/share/man
- update URL for patches
- misc. fixes to spec file

* Mon Mar 20 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- use the real library version number
- update to 20000319

* Tue Mar  7 2000 Jeff Johnson <jbj@redhat.com>
- rebuild for sparc baud rates > 38400.

* Fri Feb 18 2000 Preston Brown <pbrown@redhat.com>
- xterm terminfo entries from XFree86 3.3.6
- final round of xterm fixes, follow debian policy.

* Sat Feb  5 2000 Bernhard Rosenkr舅zer <bero@redhat.com>
- strip libraries

* Thu Feb  3 2000 Bernhard Rosenkr舅zer <bero@redhat.com>
- More xterm fixes (Bug #9087)

* Thu Jan 27 2000 Bernhard Rosenkr舅zer <bero@redhat.com>
- More xterm fixes from Hans de Goede (Bug #8633)

* Sat Jan 15 2000 Bernhard Rosenkr舅zer <bero@redhat.com>
- remove some broken symlinks (leftovers from libncurses.so.5)
- Use %configure (Bug #8484)

* Tue Jan 11 2000 Bernhard Rosenkr舅zer <bero@redhat.com>
- Add xterm patch from Hans de Goede <hans@highrise.nl>
- Patch 20000108, this fixes a problem with a header file.

* Wed Jan  5 2000 Bernhard Rosenkr舅zer <bero@redhat.com>
- Add 20000101 patch, hopefully finally fixing the xterm description

* Wed Dec 22 1999 Cristian Gafton <gafton@redhat.com>
- revert to the old major number - because the ABI is not changed (and we
  should be handling the changes via symbol versioning anyway)

* Fri Nov 12 1999 Bernhard Rosenkraenzer <bero@redhat.com>
- Fix a typo in spec
- Add the 19991006 patch, fixing some C++ STL compatibility problems.
- get rid of profiling and debugging versions - we need to save space...

* Thu Nov  4 1999 Bernhard Rosenkraenzer <bero@redhat.com>
- 5.0
- some spec cleanups to make updating easier
- add links *.so.5 to *.so.4 - they are fully binary compatible.
  (Why did they change the invocation number???)

* Wed Sep 22 1999 Cristian Gafton <gafton@redhat.com>
- make clean in the test dir - don't ship any binaries at all.

* Mon Sep 13 1999 Preston Brown <pbrown@redhat.com>
- fixed stripping of test programs.

* Sun Aug 29 1999 Preston Brown <pbrown@redhat.com>
- removed 'flash' capability for xterm; see bug #2820 for details.

* Fri Aug 27 1999 Cristian Gafton <gafton@redhat.com>
- add the resetall script from Marc Merlin <marc@merlins.org>

* Fri Aug 27 1999 Preston Brown <pbrown@redhat.com>
- added iris-ansi-net as alias for iris-ansi (bug #2561)

* Fri Jul 30 1999 Michael K. Johnson <johnsonm@redhat.com>
- added ncurses-intro.hmtl and hackguide.html to -devel package [bug #3929]

* Tue Apr 06 1999 Preston Brown <pbrown@redhat.com>
- make sure ALL binaries are stripped (incl. test binaries)

* Thu Mar 25 1999 Preston Brown <pbrown@redhat.com>
- made xterm terminfo stuff MUCH better.

* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> 
- auto rebuild in the new build environment (release 16)

* Sat Mar 13 1999 Cristian Gafton <gafton@redhat.com>
- fixed header for C++ compiles

* Fri Mar 12 1999 Jeff Johnson <jbj@redhat.com>
- add terminfo entries for linux/linux-m on sparc (obsolete termfile_sparc).

* Thu Feb 18 1999 Cristian Gafton <gafton@redhat.com>
- updated patchset from original site

* Thu Dec 03 1998 Cristian Gafton <gafton@redhat.com>
- don't build the C++ demo code
- update patch set to the current as of today (redid all the individual
  patches in a single one)

* Wed Oct 14 1998 Cristian Gafton <gafton@redhat.com>
- make sure to strip the binaries

* Wed Sep 23 1998 Cristian Gafton <gafton@redhat.com>
- added another zillion of patches. The spec file *is* ugly
- defattr

* Mon Jul 20 1998 Cristian Gafton <gafton@redhat.com>
- added lots of patches. This spec file is starting to look ugly

* Wed Jul 01 1998 Alan Cox <alan@redhat.com>
- Fix setuid trusting. Open termcap/info files as the real user.

* Wed May 06 1998 Cristian Gafton <gafton@redhat.com>
- added terminfo entry for the poor guys using lat1 and/or lat-2 on their
  consoles... Enjoy linux-lat ! Thanks, Erik !

* Tue Apr 21 1998 Cristian Gafton <gafton@redhat.com>
- new patch to get xterm-color and nxterm terminfo entries
- aliased them to rxvt, as that seems to satisfy everybody

* Sun Apr 12 1998 Cristian Gafton <gafton@redhat.com>
- added %clean section

* Tue Apr 07 1998 Cristian Gafton <gafton@redhat.com>
- removed /usr/lib/terminfo symlink - we shouldn't need that

* Mon Apr 06 1998 Cristian Gafton <gafton@redhat.com>
- updated to 4.2 + patches
- added BuildRoot

* Sat Apr 04 1998 Cristian Gafton <gafton@redhat.com>
- rebuilt with egcs on alpha

* Wed Dec 31 1997 Erik Troan <ewt@redhat.com>
- version 7 didn't rebuild properly on the Alpha somehow -- no real changes
  are in this version

* Tue Dec 09 1997 Erik Troan <ewt@redhat.com>
- TIOCGWINSZ wasn't used properly

* Tue Jul 08 1997 Erik Troan <ewt@redhat.com>
- built against glibc, linked shared libs against -lc

