%define orgname kterm

# if you want to make kterm_plus version, 
# uncomment below line, or rpm --define plus:1
# % define plus 1

%define name %{orgname}%{?plus:_plus}

Summary: A Kanji (Japanese character set) terminal emulator for X.%{?plus:(Enhanced)}
Summary(ja): 日本語の表示が可能な X 上のターミナルソフト%{?plus:(拡張版)}
Name: %{name}
Version: 6.2.0
Release: 42%{?_dist_release}
License: X, distributable
Group: User Interface/Desktops
#Source: ftp://ftp.sunet.se/pub/X11/R6contrib/applications/kterm-6.2.0.tar.gz
Source: kterm-6.2.0.tar.bz2
Source1: kterm.termtypes.tgz
Source2: kterm.wmconfig
Source3: KTerm.ad
Source4: KTerm-ja.ad
Source5: README.rightscrlbar
Patch0: kterm-6.2.0-kbd.patch.bz2
Patch1: kterm-6.2.0-glibc.patch.bz2
Patch2: kterm-6.2.0-utmp98.patch.bz2
Patch3: kterm-debian.patch.bz2
Patch4: kterm-%{version}.envvars.patch.bz2
Patch5: kterm-6.2.0-xmodifiers.patch
Patch6: kterm-6.2.0-ia64.patch
Patch7: kterm-6.2.0-malloc.patch

# VinePatch
Patch20: kterm-6.2.0-16colors.diff
Patch21: kterm-6.2.0-pje.diff
Patch22: kterm-6.2.0-glibc.pje.patch
Patch23: kterm-6.2.0.ext02.patch
Patch24: http://phe.phyas.aichi-edu.ac.jp/~cyamauch/arch/kterm-6.2.0-rightbar.patch

# based on kterm3d-6.2.0-wp1-DND.patch (VinePlus2.1 kterm-6.2.0_3D)
%{?plus:Patch50: kterm-6.2.0-xaw3d.patch}
%{?plus:Patch51: kterm-6.2.0-DnD.patch}

# based on http://delegate.uec.ac.jp:8081/club/mma/%7Etakkun/fun/handling/kterm-6.2.0-wp-BGP-20000423-beta.patch.gz
# see http://delegate.uec.ac.jp:8081/club/mma/~takkun/fun/handling/wallpaper/kterm.html
%{?plus:Patch52: kterm-6.2.0-wp-BGP-20000423-beta-vine.patch}

#Requires: /usr/sbin/utempter
Requires: utempter
BuildRequires: ncurses-devel
BuildRequires: libX11-devel, libICE-devel, libSM-devel, libXext-devel
BuildRequires: libXmu-devel, libXpm-devel, libXt-devel
BuildRequires: desktop-file-utils
BuildRequires: libutempter-devel
%{!?plus:BuildPrereq: libXaw-devel >= 1.0.5}

%{?plus:Obsoletes: kterm_3D}
%{?plus:BuildPrereq: Xaw3d-devel, imlib-devel}
%{?plus:Requires: Xaw3d, imlib}
%{?plus:Provides: kterm}

Distribution: Vine Linux
Vendor: Project Vine

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

%define plusdesc %{?plus:This package has additional features - Xaw3D scrollbar color, OffiX DnD and WallPaper.}

%define plusdescja %{?plus:また、Xaw3D による立体化、OffiX DnD、壁紙指定の拡張がされています. }

%description
Kterm is an X11 terminal emulator that can handle multi-lingual text.
This release is based on xterm of X11R6.1.

This binary is patched with xterm security patch and 16 colors patch.

%{plusdesc}

%description -l ja
日本語の表示が可能な X 上のターミナルソフトです. X の標準ターミナルソ
フト xterm に日本語を取り扱う機能が付加されています. xterm の上位互換
となっており, オプションの設定や操作方法は xterm とほとんど同じです. 

このパッケージには xterm セキュリティーパッチと16 色パッチが当たってい
ます. 

%{plusdescja}

ドキュメントは man kterm および man xterm を参考にしてください.

%prep
rm -rf %{buildroot}

%setup -a 1  -n %{orgname}-%{version}
cp %{SOURCE5} .

%patch0 -p1 -b .kbd
%patch1 -p1 -b .glibc
%patch2 -p1 -b .utempter
%patch3 -p1 -b .debian
%patch4 -p1 -b .envvars
# this patch is very very ad hoc.
# when XMODIFIERS is inappropriate value like @im=none for XIM,
# if a problem kterm crashes will be fixed, this patch doesn't apply.
%patch5 -p1 -b .xmodifiers
# ia64 fix
%patch6 -p1 -b .ia64
%patch7 -p1 -b .malloc

# 16 Colors Patch
%patch20 -p1 -b .16color

# PJE default Patch
%patch21 -p1 -b .pje

# for glibc-2.1
#%patch22 -p1

# resource for jisx0213-2000-1 jisx0213-2000-2 extension
%patch23 -p1 -b .jisx0213

# enable right scrollbar
%patch24 -p1 -b .rithtscr

# Xaw3D color patch
%{?plus:%patch50 -p1 -b .xaw3d}

# Offix DnD patch (on patch50)
%{?plus:%patch51 -p1 -b .dnd}

# WallPaper Background Imlib patch
%{?plus:%patch52 -p1 -b .wpbgpimlib}
rm -f wp-BGP-*.wpbgpimlib


%build
#PATH=/usr/X11R6/bin:$PATH
xmkmf -a ; make 


%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
make install.man DESTDIR=%{buildroot} MANPATH=%{_mandir}

chmod 755 %{buildroot}%{_bindir}/kterm

# Install config file for wmconfig
install -d %{buildroot}/etc/X11/wmconfig
install -m 0644 %{SOURCE2} \
	%{buildroot}/etc/X11/wmconfig/kterm

# Install Resource file
mkdir -p %{buildroot}%{_datadir}/X11/app-defaults
rm -f %{buildroot}%{_datadir}/X11/app-defaults/KTerm*
install -m 0444 %{SOURCE3} %{buildroot}%{_datadir}/X11/app-defaults/KTerm
install -m 0444 %{SOURCE4} %{buildroot}%{_datadir}/X11/app-defaults/KTerm-ja

# Modify Resource files for PPC
%ifarch ppc
##(cd %{buildroot}/usr/X11R6/lib/X11/app-defaults; \
##    grep -v EightBitInput KTerm > KTerm.new; \
##    mv -f KTerm.new KTerm)
##(cd %{buildroot}/usr/X11R6/lib/X11/ja/app-defaults; \
##    grep -v EightBitInput KTerm > KTerm.new; \
##    mv -f KTerm.new KTerm)
(
	cd %{buildroot}/usr/share/X11/app-defaults;
    grep -v EightBitInput KTerm > KTerm.new; mv -f KTerm.new KTerm;
    grep -v EightBitInput KTerm-ja > KTerm-ja.new; mv -f KTerm-ja.new KTerm-ja;
)
%endif

# Install Japanese Manual
mkdir -p %{buildroot}%{_mandir}/ja/man1
nkf -e kterm.jman > %{buildroot}%{_mandir}/ja/man1/kterm.1x

# gzip manuals
#gzip ${RPM_BUILD_ROOT}/usr/X11R6/man/man1/kterm.1x
#gzip ${RPM_BUILD_ROOT}/usr/X11R6/man/ja/man1/kterm.1x

#rm -f %{buildroot}/etc/X11/app-defaults/KTerm
#rm -f %{buildroot}/usr/lib/X11/app-defaults

mkdir -p $RPM_BUILD_ROOT%{_datadir}/applications
cat > $RPM_BUILD_ROOT%{_datadir}/applications/kterm.desktop <<EOF
[Desktop Entry]
Encoding=UTF-8
Name=kterm
Name[ja]=kterm 日本語端末
Comment=Kanji Terminal
Comment[ja]=日本語端末エミュレータ
TryExec=kterm
Exec=kterm
Icon=kterm
Terminal=false
Type=Application
Categories=Utility;TerminalEmulator;
EOF
chmod 0644 $RPM_BUILD_ROOT%{_datadir}/applications/kterm.desktop
desktop-file-validate $RPM_BUILD_ROOT%{_datadir}/applications/kterm.desktop

%post
update-desktop-database %{_datadir}/applications

%postun
update-desktop-database %{_datadir}/applications

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc README.kt  README.rightscrlbar DEMO.kt.uu DEMO.xbm kterm.termcap kterm.terminfo
%{?plus:%doc wp-BGP-*}
%{_bindir}/kterm
%{_sysconfdir}/X11/wmconfig/kterm
%{_datadir}/X11/app-defaults/KTerm
%{_datadir}/X11/app-defaults/KTerm-ja
%{_mandir}/man1/kterm.1x*
%{_mandir}/ja/man1/kterm.1x*
%config %{_datadir}/applications/kterm.desktop


%changelog 
* Sun Nov 09 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 6.2.0-42
- rebuild with libXaw.so.7 (libXaw-1.0.5)
- add BR: for xorg-x11 7.4

* Sat Jun 14 2008 Shu KONNO <owa@bg.wakwak.com> 6.2.0-41vl5
- applied new versioning policy and spec in utf-8
- added BuildRequires: xorg-x11-devel desktop-file-utils
- added %{_datadir}/applications/kterm.desktop

* Thu Feb 09 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 6.2.0-40vl2
- rebuilt

* Sat Apr 03 2004 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 6.2.0-40vl1
- synced with fedora
- fixed SOURCZE[34] for XOrg
- modified ext02 patch

* Tue Mar 16 2004 KOBAYASHI R. Taizo <tkoba@vinelinux.org> 6.2.0-14vl14
- kterm-6.2.0-malloc.patch: applied to fix wrong prototype declaration 
  for mallo.c. from
  * Wed Mar 10 2004 Akira TAGOH <tagoh@redhat.com> 6.2.0-40

* Thu Aug 21 2003 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 6.2.0-14vl13
- rebuild with new toolchains
- s/Copyright/License/

* Sat Oct 05 2002 Shoji Matsumoto <shom@vinelinux.org> 6.2.0-14vl12
- modify KTerm{,-ja}.ad to use openIm: on

* Wed Apr 11 2001 Jun Nishii <jun@vinelinux.org> 6.2.0-14vl11
- update rightscrbar patch (bug fix)

* Wed Apr 11 2001 Jun Nishii <jun@vinelinux.org> 6.2.0-14vl10
- put scrollbar on right side

* Mon Mar 26 2001 Jun Nishii <jun@vinelinux.org> 6.2.0-14vl9
- added rightscrbar.patch

* Mon Mar 12 2001 Shoji Matsumoto <shom@vinelinux.org> 6.2.0-14vl8
- add '_plus' operation 
  'rpm --define plus:1 -ba' makes 'kterm-plus' package.
  kterm_plus based on kterm-6.2.0_3D in VinePlus 2.1 and
  replaced with new wallpaper patch.

* Thu Feb 15 2001 Tomoya TAKA <tomoya@olive.plala.or.jp>
- 6.2.0-14vl7
- fixed 'Requires'
- use better macros (%%{buildroot}, %%{SOURCE2})

* Thu Feb 15 2001 Kunio Murasawa <murasawa@marineroad.com>
- 6.2.0-14vl6
- added utemper patch
- turn off suid bit for kterm

* Fri Dec 22 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 6.2.0-14vl5
- rebuilt with ncurses5

* Fri Jul 21 2000 Jun Nishii <jun@vinelinux.org>
- 6.2.0-14vl4
- added wheel mouse setting
- added Kterm.ad as a Source
- use alias font for menu

* Thu Jun  8 2000 Yasuyuki Furukawa <furukawa@vinelinux.org>
- 6.2.0-14vl3
- added ext02 patch for jisx213-2000-[1-2] extension.

* Thu Jun  1 2000 Jun Nishii <jun@vinelinux.org>
- 6.2.0-14vl2
- move mans to ja from ja_JP.ujis

* Mon Mar 13 2000 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 6.2.0-14vl1
- slight modifications of resource files for ppc archtecture
  (really only for ppc archtecture? or is this the appropriate solution?
   I don't even know... but it surely works well on PPC for now)

* Fri Dec 24 1999 Jun Nishii <jun@vinelinux.org>
- rel.14
- change group

* Sun Aug 22 1999 Jun Nishii <jun@flatout.org>
- rel.13
- scrollbar is true in default

* Tue Mar  2 1999 MATSUMOTO Shoji <vine@flatout.org>
- rel.10
- default resource modified

* Sun Feb 28 1999 Jun Nishii <jun@flatout.org>
- rel.9
- added a resource for ja for Vine

* Thu Nov 12 1998 Jun Nishii <jun@flatout.org>
- change header definitions in this spec file
- added -l ja for Description and Summary

* Tue Sep 29 1998 Jun Nishii <jun@flatout.org>
- add patch for glibc2 and wmconfig

* Wed Sep 16 1998 MATSUMOTO Shoji <pje@linux.or.jp>
- for glibc1
