%define _sysconfdir /etc
%define using_netpbm 1
%define have_mkdtemp 1
#%%define have_mkdtemp 0

Summary: A getty replacement for use with data and fax modems.
Name: mgetty
Version: 1.1.25
Release: 5vl4
Source: ftp://ftp.leo.org/pub/comp/os/unix/networking/mgetty/mgetty%{version}-Feb01.tar.gz
Source1: logrotate.mgetty
Source2: logrotate.sendfax
Source3: logrotate.vgetty
Source4: logrotate.vm
Patch0: http://www-internal.alphanet.ch/~schaefer/vgetty/global_patches/CURRENT/mgetty-1.1.25-to-11032001.bz2
Patch1: mgetty-1.1.22-config.patch
Patch2: mgetty-1.1.26-policy.patch
Patch3: mgetty-1.1.25-faxprint.patch
Patch4: mgetty-1.1.21-giftopnm.patch
Patch5: mgetty-1.1.25-voiceconfig.patch
Patch6: mgetty-1.1.25-elsa.patch
License: GPL
Group: Applications/Communications
Prereq: /sbin/install-info
BuildPrereq: groff, tetex, texinfo
Buildroot: %{_tmppath}/%{name}-root
Requires: mktemp
URL: http://www.leo.org/~doering/mgetty/index.html

%package sendfax
Summary: Provides support for sending faxes over a modem.
Requires: mgetty = %{version}
Group: Applications/Communications
%if %{using_netpbm}
Requires: netpbm-progs
%else
Requires: libgr-progs
%endif

%package voice
Summary: A program for using your modem and mgetty as an answering machine.
Requires: mgetty = %{version}
Group: Applications/Communications

%package viewfax
Summary: An X Window System fax viewer.
Group: Applications/Communications

%description
The mgetty package contains a "smart" getty which allows logins over a
serial line (i.e., through a modem).  If you're using a Class 2 or 2.0
modem, mgetty can receive faxes.  If you also need to send faxes,
you'll need to install the sendfax program.

If you'll be dialing in to your system using a modem, you should
install the mgetty package.  If you'd like to send faxes using mgetty
and your modem, you'll need to install the mgetty-sendfax program.  If
you need a viewer for faxes, you'll also need to install the
mgetty-viewfax package.

%description sendfax
Sendfax is a standalone backend program for sending fax files.  The
mgetty program (a getty replacement for handling logins over a serial
line) plus sendfax will allow you to send faxes through a Class 2
modem.

If you'd like to send faxes over a Class 2 modem, you'll need to
install the mgetty-sendfax and the mgetty packages.

%description voice
The mgetty-voice package contains the vgetty system, which enables
mgetty and your modem to support voice capabilities.  In simple terms,
vgetty lets your modem act as an answering machine.  How well the
system will work depends upon your modem, which may or may not be able
to handle this kind of implementation.

Install mgetty-voice along with mgetty if you'd like to try having
your modem act as an answering machine.

%description viewfax
Viewfax displays the fax files received using mgetty in an X11 window.
Viewfax is capable of zooming in and out on the displayed fax.

If you're installing the mgetty-viewfax package, you'll also need to
install mgetty.

%prep
%setup -q
%patch0 -p1 -b .vgetty
%patch1 -p1 -b .config
%patch2 -p1 -b .policy
%patch3 -p1 -b .faxprint
%if %{using_netpbm}
%patch4 -p1 -b .giftopnm
%endif
%patch5 -p1 -b .voiceconfig
# Should be outdated by the vgetty patch.
#%patch6 -p1 -b .elsa
cp policy.h-dist policy.h

%build
%define makeflags CFLAGS="$RPM_OPT_FLAGS -Wall -DAUTO_PPP"                                        CONFDIR=%{_sysconfdir}/mgetty+sendfax                                           ECHO="'echo -e'" prefix=%{_prefix}

make %{makeflags}
make -C voice %{makeflags}
make -C tools %{makeflags}

%if %{have_mkdtemp}
MKDTEMP_FLAGS=
%else
MKDTEMP_FLAGS=-DNEED_MKDTEMP
%endif

pushd frontends/X11/viewfax-2.5
xmkmf
make depend
make CDEBUGFLAGS="$RPM_OPT_FLAGS $MKDTEMP_FLAGS" CONFDIR=%{_sysconfdir}/mgetty+sendfax
popd

%install
rm -rf $RPM_BUILD_ROOT

mkdir -p $RPM_BUILD_ROOT{%{_bindir},%{_infodir},%{_libdir}/mgetty+sendfax}
mkdir -p $RPM_BUILD_ROOT{%{_mandir},%{_sbindir},/sbin,/var/spool}

%define instflags                                                                       CFLAGS="$RPM_OPT_FLAGS"                                                         prefix=$RPM_BUILD_ROOT%{_prefix}                                                spool=$RPM_BUILD_ROOT%{_var}/spool                                              BINDIR=$RPM_BUILD_ROOT%{_bindir}                                                SBINDIR=$RPM_BUILD_ROOT%{_sbindir}                                              LIBDIR=$RPM_BUILD_ROOT%{_libdir}/mgetty+sendfax                                 HELPDIR=$RPM_BUILD_ROOT%{_libdir}/mgetty+sendfax                                CONFDIR=$RPM_BUILD_ROOT%{_sysconfdir}/mgetty+sendfax                            MANDIR=$RPM_BUILD_ROOT%{_mandir}                                                MAN1DIR=$RPM_BUILD_ROOT%{_mandir}/man1                                          MAN4DIR=$RPM_BUILD_ROOT%{_mandir}/man4                                          MAN5DIR=$RPM_BUILD_ROOT%{_mandir}/man5                                          MAN8DIR=$RPM_BUILD_ROOT%{_mandir}/man8                                          INFODIR=$RPM_BUILD_ROOT%{_infodir}                                              ECHO='echo -e' INSTALL=%{__install}
make install %instflags
install -m700 callback/callback $RPM_BUILD_ROOT%{_sbindir}
install -m4711 callback/ct $RPM_BUILD_ROOT%{_bindir}

gzip -9n $RPM_BUILD_ROOT%{_infodir}/*

mv $RPM_BUILD_ROOT%{_sbindir}/mgetty $RPM_BUILD_ROOT/sbin

# this conflicts with efax
mv $RPM_BUILD_ROOT%{_mandir}/man1/fax.1 $RPM_BUILD_ROOT%{_mandir}/man1/mgetty_fax.1

# tools
make -C tools install %instflags

# voice mail extensions
mkdir -p $RPM_BUILD_ROOT%{_var}/spool/voice/{messages,incoming}
make -C voice install %instflags
mv $RPM_BUILD_ROOT%{_sbindir}/vgetty $RPM_BUILD_ROOT/sbin
install -m 600 -c voice/voice.conf-dist $RPM_BUILD_ROOT%{_sysconfdir}/mgetty+sendfax/voice.conf

# don't ship documentation that is executable...
find samples -type f -exec chmod 644 {} \;

make -C frontends/X11/viewfax-2.5 install %instflags
make -C frontends/X11/viewfax-2.5 install.man %instflags MANDIR=$RPM_BUILD_ROOT%{_mandir}/man1

# install logrotate control files
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d
install -m 0644 $RPM_SOURCE_DIR/logrotate.mgetty  $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/mgetty
install -m 0644 $RPM_SOURCE_DIR/logrotate.sendfax $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/sendfax
install -m 0644 $RPM_SOURCE_DIR/logrotate.vgetty  $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/vgetty
install -m 0644 $RPM_SOURCE_DIR/logrotate.vm      $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/vm

%clean
rm -rf $RPM_BUILD_ROOT

%post
/sbin/install-info %{_infodir}/mgetty.info.gz %{_infodir}/dir --entry="* mgetty: (mgetty).		Package to handle faxes, voicemail and more."

%preun
if [ $1 = 0 ]; then
    /sbin/install-info --delete %{_infodir}/mgetty.info.gz %{_infodir}/dir --entry="* mgetty: (mgetty). 	Package to handle faxes, voicemail and more."
fi

%files
%defattr(-,root,root)
%doc BUGS ChangeLog README.1st Recommend THANKS doc/modems.db samples 
%doc doc/mgetty.ps doc/*.txt
/sbin/mgetty
%{_sbindir}/callback
%{_mandir}/man4/mgettydefs.4*
%{_mandir}/man8/mgetty.8*
%{_mandir}/man8/callback.8*
%{_infodir}/mgetty.info*
%dir %{_sysconfdir}/mgetty+sendfax
%config %{_sysconfdir}/mgetty+sendfax/login.config
%config %{_sysconfdir}/mgetty+sendfax/mgetty.config
%config %{_sysconfdir}/mgetty+sendfax/dialin.config
%config %{_sysconfdir}/logrotate.d/mgetty

%files sendfax
%defattr(-,root,root)
%dir %{_var}/spool/fax
%dir %{_var}/spool/fax/incoming
%dir %{_var}/spool/fax/outgoing
%dir %{_var}/spool/fax/outgoing/locks
%attr(0755,root,root) %{_bindir}/ct
%{_bindir}/faxq
%{_bindir}/faxrm
%{_bindir}/faxrunq
%{_bindir}/faxspool
%{_bindir}/g3cat
%{_bindir}/g32pbm
%{_bindir}/kvg
%{_bindir}/newslock
%{_bindir}/pbm2g3
%{_sbindir}/faxrunqd
%{_sbindir}/sendfax
%dir %{_libdir}/mgetty+sendfax
%{_libdir}/mgetty+sendfax/cour25.pbm
%{_libdir}/mgetty+sendfax/cour25n.pbm
%{_mandir}/man1/g32pbm.1*
%{_mandir}/man1/pbm2g3.1*
%{_mandir}/man1/g3cat.1*
%{_mandir}/man1/mgetty_fax.1*
%{_mandir}/man1/faxspool.1*
%{_mandir}/man1/faxrunq.1*
%{_mandir}/man1/faxq.1*
%{_mandir}/man1/faxrm.1*
%{_mandir}/man1/coverpg.1*
%{_mandir}/man5/faxqueue.5*
%{_mandir}/man8/faxrunqd.8*
%{_mandir}/man8/sendfax.8*
%dir %{_sysconfdir}/mgetty+sendfax
%config %{_sysconfdir}/mgetty+sendfax/sendfax.config
%config %{_sysconfdir}/mgetty+sendfax/faxrunq.config
%config %{_sysconfdir}/mgetty+sendfax/faxspool.rules.sample
%config %{_sysconfdir}/mgetty+sendfax/faxheader
%config %{_sysconfdir}/logrotate.d/sendfax

%files voice
%defattr(-,root,root)
%doc voice/doc/* voice/Announce voice/ChangeLog voice/Readme
%dir %{_var}/spool/voice
%dir %{_var}/spool/voice/incoming
%dir %{_var}/spool/voice/messages
/sbin/vgetty
%{_bindir}/vm
%{_bindir}/pvfamp
%{_bindir}/pvfcut
%{_bindir}/pvfecho
%{_bindir}/pvffft
%{_bindir}/pvffile
%{_bindir}/pvffilter
%{_bindir}/pvfmix
%{_bindir}/pvfnoise
%{_bindir}/pvfreverse
%{_bindir}/pvfsine
%{_bindir}/pvfspeed
%{_bindir}/rmdfile
%{_bindir}/pvftormd
%{_bindir}/rmdtopvf
%{_bindir}/pvftovoc
%{_bindir}/voctopvf
%{_bindir}/pvftolin
%{_bindir}/lintopvf
%{_bindir}/pvftobasic
%{_bindir}/basictopvf
%{_bindir}/pvftoau
%{_bindir}/autopvf
%{_bindir}/pvftowav
%{_bindir}/wavtopvf
%{_mandir}/man1/zplay.1*
%{_mandir}/man1/pvf.1*
%{_mandir}/man1/pvfamp.1*
%{_mandir}/man1/pvfcut.1*
%{_mandir}/man1/pvfecho.1*
%{_mandir}/man1/pvffile.1*
%{_mandir}/man1/pvffft.1*
%{_mandir}/man1/pvfmix.1*
%{_mandir}/man1/pvfreverse.1*
%{_mandir}/man1/pvfsine.1*
%{_mandir}/man1/pvfspeed.1*
%{_mandir}/man1/pvftormd.1*
%{_mandir}/man1/rmdtopvf.1*
%{_mandir}/man1/rmdfile.1*
%{_mandir}/man1/pvftovoc.1*
%{_mandir}/man1/voctopvf.1*
%{_mandir}/man1/pvftolin.1*
%{_mandir}/man1/lintopvf.1*
%{_mandir}/man1/pvftobasic.1*
%{_mandir}/man1/basictopvf.1*
%{_mandir}/man1/pvftoau.1*
%{_mandir}/man1/autopvf.1*
%{_mandir}/man1/pvftowav.1*
%{_mandir}/man1/wavtopvf.1*
%dir %{_sysconfdir}/mgetty+sendfax
%config %{_sysconfdir}/mgetty+sendfax/voice.conf
%config %{_sysconfdir}/logrotate.d/vgetty
%config %{_sysconfdir}/logrotate.d/vm

%files viewfax
%defattr(-,root,root)
%doc frontends/X11/viewfax-2.5/C* frontends/X11/viewfax-2.5/README
%{_bindir}/viewfax
%dir %{_libdir}/mgetty+sendfax
%{_libdir}/mgetty+sendfax/viewfax.tif
%{_mandir}/man1/viewfax.1x*

%changelog
* Wed Dec 19 2001 Toru Sagami <sagami@vinelinux.org> 1.1.25-5vl4
- change %%define mkdtemp 1 in oreder to build on glibc22 system

* Thu Nov 15 2001 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 1.1.25-5vl3
- BuildPreReq: pTex, pLaTeX2e -> tetex again :)
- (Machino-san previously put 5vl2, but the src.rpm was gone...)

* Thu May 24 2001 MATSUBAYASHI 'Shaolin' Kohji <shaolin@vinelinux.org>
- 1.1.25-5vl1
- based on 1.1.25-5 from RH 7.1 security update
- BuildPreReq pTeX and pLaTeX2e instead of tetex and tetex-latex
- change %%define mkdtemp 0 (current Vine is based on glibc-2.1.3 yet)

* Wed Apr 18 2001 Nalin Dahyabhai <nalin@redhat.com>
- define _sysconfdir, not sysconfdir

* Mon Apr 16 2001 Nalin Dahyabhai <nalin@redhat.com>
- add logrotate.vm and logrotate.vgetty (note from Heiner Kordewiner)
- add voice/{Announce,Changelog,Readme} to documentation set

* Tue Apr 10 2001 Nalin Dahyabhai <nalin@redhat.com>
- define CNDFILE in policy.h

* Tue Mar 20 2001 Nalin Dahyabhai <nalin@redhat.com>
- change the default group in the vgetty configuration file from phone to uucp,
  which matches the settings for faxes

* Tue Mar 13 2001 Nalin Dahyabhai <nalin@redhat.com>
- update to 1.1.25
- ditch the elsa patch in favor of the current vgetty patch
- don't need to strip binaries, buildroot policies do that
- add docs to the voice subpackage

* Tue Jan 16 2001 Nalin Dahyabhai <nalin@redhat.com>
- use mkdtemp() when printing faxes

* Mon Jan 15 2001 Preston Brown <pbrown@redhat.com>
- fix misdetection of USR voice modem detection <cjj@u.washington.edu>

* Mon Jan 08 2001 Preston Brown <pbrown@redhat.com>
- 1.1.24 includes tmpfile security enhancements, some of our patches

* Tue Sep 19 2000 Nalin Dahyabhai <nalin@redhat.com>
- back out quoting patch
- change Copyright: distributable to License: GPL
- add URL
- remove logging changes from excl patch, based on input from Gert
- rework ia64 patch, break out gets/fgets change based on input from Gert

* Thu Sep  7 2000 Nalin Dahyabhai <nalin@redhat.com>
- make sure all scripts quote variables where possible (#17179)
- make sure all scripts use mktemp for generating temporary files

* Sat Aug 26 2000 Bill Nottingham <notting@redhat.com>
- update to 1.1.22; fixes security issues

* Mon Aug  7 2000 Nalin Dahyabhai <nalin@redhat.com>
- fix excl patch to keep everything from segfaulting all the time (#11523,11590)

* Mon Jul 24 2000 Nalin Dahyabhai <nalin@redhat.com>
- forcibly strip binaries (#12431)
- change dependency on libgr-progs (which is gone) to netgr-progs (#10819)
- change dependency on giftoppm to giftopnm (#8088)
- attempt to plug some potential security problems (#11874)

* Thu Jul 12 2000 Than Ngo <than@redhat.de>
- add new V250modem patch from ELSA (thanks to JÓgen Kosel)

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

* Fri Jun 23 2000 Than Ngo <than@redhat.de>
- add support ELSA Microlink 56k

* Sun Jun  4 2000 Nalin Dahyabhai <nalin@redhat.com>
- Overhaul for FHS fixes.
- Stop removing logs in postun.
- Stop stripping everything.
- ia64 fixes.

* Wed May 17 2000 Ngo Than <than@redhat.de>
- updated the new vgetty (#bug 10440)

* Sat May  6 2000 Bill Nottingham <notting@redhat.com>
- fix compilation with new gcc, or ia64, or something...

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

* Thu Feb 03 2000 Cristian Gafton <gafton@redhat.com>
- man pages are compressed

* Tue Sep  7 1999 Jeff Johnson <jbj@redhat.com>
- add fax print command (David Fox).

* Tue Sep 07 1999 Cristian Gafton <gafton@redhat.com>
- version 1.1.21

* Tue Aug 31 1999 Jeff Johnson <jbj@redhat.com>
- move callback to base package (#4799).

* Wed Jun  2 1999 Jeff Johnson <jbj@redhat.com>
- update to 1.1.20 (#3216).

* Tue Apr  6 1999 Bill Nottingham <notting@redhat.com>
- strip setuid bit from ct

* Tue Mar 23 1999 Preston Brown <pbrown@redhat.com>
- better log handling

* Wed Jan 06 1999 Cristian Gafton <gafton@redhat.com>
- rebuild for glibc 2.1

* Sat Aug 22 1998 Jos Vos <jos@xos.nl>
- Use a patch for creating policy.h using policy.h-dist.
- Add viewfax subpackage (X11 fax viewing program).
- Add logrotate config files for mgetty and sendfax log files.
- Properly define ECHO in Makefile for use with bash.
- Add optional use of dialin.config (for modems supporting this).
- Change default notification address to "root" (was "faxadmin").
- Change log file names according to better defaults.
- Change default notify program to /etc/mgetty+sendfax/new_fax (was
  /usr/local/bin/new_fax).

* Fri Aug 21 1998 Jeff Johnson <jbj@redhat.com>
- add faxrunqd man page (problem #850)
- add missing pbm2g3 (and man page); remove unnecessary "rm -f pbmtog3"
- delete redundant ( cd tools; make ... )

* Fri Apr 24 1998 Prospector System <bugs@redhat.com>
- translations modified for de, fr, tr

* Fri Apr 10 1998 Cristian Gafton <gafton@redhat.com>
- updated to 1.1.14
- AutoPPP patch
 
* Thu Dec 18 1997 Mike Wangsmo <wanger@redhat.com>
- added more of the documentation files to the rpm

* Wed Oct 29 1997 Otto Hammersmith <otto@redhat.com>
- added install-info support

* Tue Oct 21 1997 Otto Hammersmith <otto@redhat.com>
- updated version

* Wed Oct 15 1997 Erik Troan <ewt@redhat.com>
- now requires libgr-progs instead of netpbm

* Mon Aug 25 1997 Erik Troan <ewt@redhat.com>
- built against glibc
