%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}

Summary:	A mouse server for the Linux console.
Summary(ja):	Linux コンソール用マウスサーバ

Name:		gpm
Version:	1.20.6
Release:	3%{?_dist_release}
License:	GPL
Group:		System Environment/Daemons

Vendor: Project Vine
Distribution: Vine Linux
Packager: daisuke

Source:		ftp://ftp.systemy.it/pub/develop/%{name}-%{version}.tar.gz
Source1:	gpm.init
Patch1:         gpm-1.20.6-multilib.patch
Patch2:         gpm-1.20.1-lib-silent.patch
Patch3:         gpm-1.20.3-gcc4.3.patch
Patch4:         gpm-1.20.5-close-fds.patch
Patch6:         gpm-1.20.6-libtool.patch
Patch100:	gpm-1.20.1-kterm.patch
Patch101:	gpm-1.20.1-miscterm.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: sed gawk texinfo bison ncurses-devel
Requires(pre): chkconfig install-info
Requires: bash >= 2.0
Requires: gpm-libs = %{version}

# this defines the library version that this package builds.
%define LIBVER 2.1.0

%description
Gpm provides mouse support to text-based Linux applications like the
Emacs editor and the Midnight Commander file management system.  Gpm
also provides console cut-and-paste operations using the mouse and
includes a program to allow pop-up menus to appear at the click of a
mouse button.

Gpm should be installed if you intend to use a mouse with your Vine Linux
system.

%description -l ja
Gpm は Emacs エディタや Midnight Commander のようなテキストベースの
Linux アプリケーションにマウスサポートを提供します。また Gpm はマウスを
使ったコンソール上でのカット&ペーストをできるようにしたり、マウスボタン
をクリックしてポップアップメニューを表示できるようにしたりします。

Vine Linux システムのコンソール上でマウスを使用したい場合は Gpm を
インストールしてください。


%package libs
Summary:	shared libraries for gpm
Summary(ja):	gpm 用の共有ライブラリ
Group:		System Environment/Libraries

%description libs
gpm-libs package provides shared libraries for gpm.

%description -l ja libs
gpm-libs パッケージは gpm 用の共有ライブラリを提供します。


%package devel
Summary:	Libraries and header files for developing mouse driven programs.
Summary(ja):	マウスで操作されるプログラムの開発に必要なライブラリとヘッダファイル
Group:		Development/Libraries
Requires:	%{name} = %{version}

%description devel
Gpm provides mouse support to text-based Linux applications like the
Emacs editor and the Midnight Commander file management system.  Gpm
also provides console cut-and-paste operations using the mouse and
includes a program to allow pop-up menus to appear at the click of a
mouse button.

%description -l ja devel
Gpm は Emacs エディタや Midnight Commander のようなテキストベースの
Linux アプリケーションにマウスサポートを提供します。また Gpm はマウスを
使ったコンソール上でのカット&ペーストをできるようにしたり、マウスボタン
をクリックしてポップアップメニューを表示できるようにしたりします。

%package static
Requires: %{name} = %{version}-%{release}
Summary: Static development files for the gpm library
Summary(ja): gpm ライブラリのスタティックライブラリ
Group: Development/Libraries

%description static
The gpm-static package includes static libraries of gpm. The gpm
provides mouse support to text-based Linux applications.

%package -n compat32-%{name}-libs
Summary:	shared libraries for gpm
Summary(ja):	gpm 用の共有ライブラリ
Group:		System Environment/Libraries

%description -n compat32-%{name}-libs
gpm-libs package provides shared libraries for gpm.

%description -l ja -n compat32-%{name}-libs
gpm-libs パッケージは gpm 用の共有ライブラリを提供します。


%package -n compat32-%{name}-devel
Summary:	Libraries and header files for developing mouse driven programs.
Summary(ja):	マウスで操作されるプログラムの開発に必要なライブラリとヘッダファイル
Group:		Development/Libraries
Requires:	compat32-%{name}-libs = %{version}
Requires:	%{name}-devel = %{version}

%description -n compat32-%{name}-devel
Gpm provides mouse support to text-based Linux applications like the
Emacs editor and the Midnight Commander file management system.  Gpm
also provides console cut-and-paste operations using the mouse and
includes a program to allow pop-up menus to appear at the click of a
mouse button.

%description -l ja -n compat32-%{name}-devel
Gpm は Emacs エディタや Midnight Commander のようなテキストベースの
Linux アプリケーションにマウスサポートを提供します。また Gpm はマウスを
使ったコンソール上でのカット&ペーストをできるようにしたり、マウスボタン
をクリックしてポップアップメニューを表示できるようにしたりします。


%prep
%setup -q
%patch1 -p1 -b .multilib
%patch2 -p1 -b .lib-silent
%patch3 -p1 -b .gcc4.3
%patch4 -p1 -b .close-fds
%patch6 -p1 -b .libtool
%patch100 -p1 -b .kterm
%patch101 -p1 -b .miscterm

%build
%if %{build_compat32}
export CC="%__cc -m32"
%endif

autoreconf -f -i
CFLAGS="-D_GNU_SOURCE $RPM_OPT_FLAGS" \
    lispdir=%{buildroot}%{_datadir}/emacs/site-lisp \
    %configure
make

%install
rm -rf %{buildroot}
mkdir -p %{buildroot}/etc

PATH=/sbin:$PATH:/usr/sbin:$PATH

mkdir -p %{buildroot}%{_datadir}/emacs/site-lisp
%makeinstall lispdir=%{buildroot}%{_datadir}/emacs/site-lisp

chmod 0755 %{buildroot}/%{_libdir}/libgpm.so.%{LIBVER}
ln -sf libgpm.so.%{LIBVER} %{buildroot}/%{_libdir}/libgpm.so

%ifnarch s390 s390x
install -m644 doc/gpm-root.1 %{buildroot}%{_mandir}/man1
install -m644 conf/gpm-root.conf %{buildroot}/etc
install -s -m755 src/prog/hltest %{buildroot}%{_bindir}
%else
rm -f $RPM_BUILD_ROOT%{_bindir}/{mev,gpm-root}
%endif

%ifnarch s390 s390x
mkdir -p %{buildroot}/etc/rc.d/init.d  
install -m 755 $RPM_SOURCE_DIR/gpm.init %{buildroot}/etc/rc.d/init.d/gpm
%endif

mkdir -p $RPM_BUILD_ROOT/etc/sysconfig
cat >$RPM_BUILD_ROOT/etc/sysconfig/gpm <<EOF
# Additional options for gpm (e.g. acceleration), device
OPTIONS=""
DEVICE="/dev/mouse"
EOF

# remove stuff from the buildroot that we aren't shipping
rm -f $RPM_BUILD_ROOT%{_bindir}/disable-paste
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/mouse-test.1*
%ifarch s390 s390x
rm -f $RPM_BUILD_ROOT/usr/sbin/gpm
rm -f $RPM_BUILD_ROOT/usr/bin/hltest
rm -f $RPM_BUILD_ROOT/usr/bin/mouse-test
rm -rf $RPM_BUILD_ROOT/%{_mandir}
%endif

%clean
rm -rf %{buildroot}

%post
%ifnarch s390 s390x
/sbin/chkconfig --add gpm
%endif
/sbin/install-info %{_infodir}/gpm.info.gz %{_infodir}/dir

%preun
if [ $1 = 0 ]; then
    /sbin/install-info %{_infodir}/gpm.info.gz --delete %{_infodir}/dir
%ifnarch s390 s390x   
    /etc/rc.d/init.d/gpm stop >/dev/null 2>&1
    /sbin/chkconfig --del gpm
%endif
fi

%postun
%ifnarch s390 s390x
if [ "$1" -ge "1" ]; then
  /etc/rc.d/init.d/gpm condrestart >/dev/null 2>&1
fi
%endif

%post libs -p /sbin/ldconfig

%postun libs -p /sbin/ldconfig

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

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

%files
%defattr(-,root,root)
%ifnarch s390 s390x
%config %{_sysconfdir}/gpm-root.conf
%config %{_sysconfdir}/rc.d/init.d/gpm
%{_bindir}/*
%{_sbindir}/*
%{_mandir}/man?/*
%endif
%{_infodir}/gpm.info*
%config %{_sysconfdir}/sysconfig/gpm

%files libs
%defattr(-,root,root)
%{_libdir}/libgpm.so.*

%files devel
%defattr(-,root,root)
%{_includedir}/*
%{_libdir}/libgpm.so

%files static
%defattr(-,root,root)
%{_libdir}/libgpm.a

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

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

%changelog
* Sun Jul 20 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> - 1.20.6-3
- rebuild with VineSeed environment

* Fri May 29 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.20.6-2
- Release tag missed the actual number (1) on 1.20.6-1; bumped the release no.

* Wed May 27 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 	1.20.6-1
- new upstream release
- spec in utf-8
- new versioning policy
- split static library to -static subpackage

* Sun Sep 10 2006 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 1.20.1-35vl8
- change gpm Group to System Environment/Daemons. <BTS:VineLinux:163>

* Sat Aug 26 2006 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 1.20.1-35vl7
- fix typo in changelog
- oops, add BuildRequires: emacsen

* Fri Aug 25 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.20.1-35vl6
- fixed Group typo

* Thu Aug 24 2006 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 1.20.1-35vl5
- add BuildRequires: emacsen
- add Requires: %%{name}-libs for %%{name}-devel instead of gpm
- added compat32-* packages for x86_64 architecture support
  - add CC="%%__cc -m32" if compat32 is enabled

* Fri Jul 14 2006 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 1.20.1-35vl4
- add patch 101 to fix error with alsaconf on VT. <BTS:VineLinux:85>
- add japanese summary and description.
- change gpm group to System Enviroment/Services.

* Thu Dec 15 2005 Daisuke SUZUKI <daisuke@linux.or.jp> 1.20.1-35vl3
- split shared libraries to gpm-libs sub package.

* Wed Jul 07 2004 Daisuke SUZUKI <daisuke@linux.or.jp> 1.20.1-35vl2
- rebuild witn new environment
- add patch20 to disable 'possibly I die' message.
- add patch100 to recognize kterm as xterm.

* Fri Jul  4 2003 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.20.1-35vl1
- rebuild with new toolchains
- based on Redhat Rawhide 1.20.1-35
  - Wed Jan 29 2003 Bill Nottingham <notting@redhat.com> 1.19.13-27
  - ship libraries on s390/s390x

* Mon Jun 11 2001 MATSUBAYASHI 'Shaolin' Kohji <shaolin@vinelinux.org>
- 1.19.3-0.6vl4
- rebuild for VineSeed

* Sat Dec 09 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaing.org>
- 1.19.3-0.6vl3
- rebuild with ncurses >= 5.0

* Thu Sep 07 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaing.org>
- 1.19.3-0.6vl2
- oops, fixed %install section for installing elisps

* Tue Sep 05 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 1.19.3-0.6vl1
- rebuild for Vine-2.x based on 1.19.3-0.6x from RH6.2/updates
  (http://www.redhat.com/support/errata/RHSA-2000-045-01.html)
- modified %install section to be compatible with rpm <= 3.0.3

* Tue Jul 25 2000 Preston Brown <pbrown@redhat.com>
- backport to 6.2 for errata

* Sat Jul 22 2000 Florian La Roche <Florian.LaRoche@redhat.de>
- update to 1.19.3

* Sat Jul 15 2000 Bill Nottingham <notting@redhat.com>
- move initscript back

* Thu Jul 13 2000 Prospector <bugzilla@redhat.com>
- automatic rebuild

* Fri Jun 30 2000 Matt Wilson <msw@redhat.com>
- use sysconf(_SC_OPEN_MAX)

* Tue Jun 27 2000 Preston Brown <pbrown@redhat.com>
- don't prereq, only require initscripts

* Mon Jun 26 2000 Preston Brown <pbrown@redhat.com>
- fix up and move initscript
- prereq initscripts >= 5.20

* Sat Jun 17 2000 Bill Nottingham <notting@redhat.com>
- fix %config tag for initscript

* Thu Jun 15 2000 Bill Nottingham <notting@redhat.com>
- move it back

* Thu Jun 15 2000 Preston Brown <pbrown@redhat.com>
- move init script

* Wed Jun 14 2000 Preston Brown <pbrown@redhat.com>
- security patch on socket descriptor from Chris Evans.  Thanks Chris.
- include limits.h for OPEN_MAX

* Mon Jun 12 2000 Preston Brown <pbrown@redhat.com>
- 1.19.2, fix up root (setuid) patch
- FHS paths

* Thu Apr  6 2000 Jakub Jelinek <jakub@redhat.com>
- 1.19.1
- call initgroups in gpm-root before spawning command as user
- make gpm-root work on big endian

* Sun Mar 26 2000 Florian La Roche <Florian.LaRoche@redhat.com>
- call ldconfig directly in postun

* Wed Mar 22 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- rebuild with new libncurses

* Sat Mar 18 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- 1.19.0
- fix build on systems that don't have emacs
  (configure built t-mouse* only if emacs was installed)

* Tue Feb 29 2000 Preston Brown <pbrown@redhat.com>
- important fix: improperly buildrooted for /usr/share/emacs/site-lisp, fixed.

* Tue Feb 15 2000 Jakub Jelinek <jakub@redhat.com>
- avoid cluttering of syslog with gpm No data messages

* Mon Feb 14 2000 Preston Brown <pbrown@redhat.com>
- disable-paste and mouse-test removed, they seem broken.

* Thu Feb 03 2000 Preston Brown <pbrown@redhat.com>
- updated gpm.init to have better shutdown and descriptive messages
- strip lib

* Wed Feb 02 2000 Cristian Gafton <gafton@redhat.com>
- fix description
- man pages are compressed

* Wed Jan 12 2000 Preston Brown <pbrown@redhat.com>
- 1.18.1.

* Tue Sep 28 1999 Preston Brown <pbrown@redhat.com>
- upgraded to 1.18, hopefully fixes sparc protocol issues

* Fri Sep 24 1999 Bill Nottingham <notting@redhat.com>
- install-info sucks, and then you die.

* Fri Sep 10 1999 Bill Nottingham <notting@redhat.com>
- chkconfig --del in %preun, not %postun

* Fri Aug 27 1999 Preston Brown <pbrown@redhat.com>
- upgrade to 1.17.9
- the maintainers are taking care of .so version now, removed patch

* Mon Aug 16 1999 Bill Nottingham <notting@redhat.com>
- initscript munging

* Wed Jun  2 1999 Jeff Johnson <jbj@redhat.com>
- disable-paste need not be setuid root in Red Hat 6.0 (#2654)

* Tue May 18 1999 Michael K. Johnson <johnsonm@redhat.com>
- gpm.init had wrong pidfile name in comments; confused linuxconf

* Mon Mar 22 1999 Preston Brown <pbrown@redhat.com>
- make sure all binaries are stripped, make init stuff more chkconfig style
- removed sparc-specific mouse stuff
- bumped libver to 1.17.5
- fixed texinfo source

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

* Thu Mar  4 1999 Matt Wilson <msw@redhat.com>
- updated to 1.75.5

* Tue Feb 16 1999 Cristian Gafton <gafton@redhat.com>
- avoid using makedev for internal functions (it is a #define in the system
  headers)

* Wed Jan 13 1999 Preston Brown <pbrown@redhat.com>
- upgrade to 1.17.2.

* Wed Jan 06 1999 Cristian Gafton <gafton@redhat.com>
- enforce the use of -D_GNU_SOURCE so that it will compile on the ARM
- build against glibc 2.1

* Tue Aug 11 1998 Jeff Johnson <jbj@redhat.com>
- build root

* Thu May 07 1998 Prospector System <bugs@redhat.com>
- translations modified for de, fr, tr

* Wed Apr 22 1998 Michael K. Johnson <johnsonm@redhat.com>
- enhanced initscript

* Fri Apr 10 1998 Cristian Gafton <gafton@redhat.com>
- recompiled for manhattan

* Wed Apr 08 1998 Erik Troan <ewt@redhat.com>
- updated to 1.13

* Mon Nov 03 1997 Donnie Barnes <djb@redhat.com>
- added patch from Richard to get things to build on the SPARC

* Tue Oct 28 1997 Donnie Barnes <djb@redhat.com>
- fixed the emacs patch to install the emacs files in the right
  place (hopefully).

* Mon Oct 13 1997 Erik Troan <ewt@redhat.com>
- added chkconfig support
- added install-info

* Thu Sep 11 1997 Donald Barnes <djb@redhat.com>
- upgraded from 1.10 to 1.12
- added status/restart functionality to init script
- added define LIBVER 1.11

* Thu Jun 19 1997 Erik Troan <ewt@redhat.com>
- built against glibc
