Summary: Various applets for use with AfterStep and compatible window managers.
Name: AfterStep-APPS
Version: 20001212
Release: 0vl3
License: GPL
Group: User Interface/Desktops
Source0: http://www.tigr.net/afterstep/as-apps/download/as-apps-001212.tar
Patch0: AfterStep-APPS-1.5beta1-glibc.patch
Patch1: ascp-paths.patch
Patch2: as-apps-compile.patch
Patch4: xiterm-utmp.patch
Patch5: AfterStep-APPS-xiterm-getopt.patch
Patch6: AfterStep-APPS-xiterm-ccoptions.patch
Patch7: 05-asdm-make.patch
Patch100: asbutton-install.patch
#Requires: /usr/sbin/utempter
Requires: utempter
Prereq: /sbin/ldconfig
BuildPrereq: WindowMaker-devel
BuildRoot: %{_tmppath}/%{name}-root

%description
The AfterStep-APPS package includes a group of applications for use
with the AfterStep window manager. Applications in this package
include an Advanced Power Management system monitor for laptops
(asapm), a CPU load monitor (ascpu), a simple state machine (asexec),
a filesystem monitor (asfsm), a CPU load monitor for use with the PROC
filesystem (asload), a mail checker (asmail), a memory utilization
monitor (asmem), a volume controller knob for the /dev/mixer device
(asmix), a volume controller for various sound inputs (asmixer), a
modem status monitor (asmodem), an analog clock (astime), a color
VT102 emulator (aterm), an audio CD player (ascd), a clock (asclock),
and a control panel for configuring AfterStep (ascp).

Install AfterStep-APPS if you're planning to use the AfterStep window
manager.

%prep
%setup -q -c
rm -f *.asc
for archive in *.tar.gz ; do
	tar xzf $archive
	rm -f $archive
done
%patch0 -p1 -b .glibc
%patch1 -p1 -b .paths
%patch4 -p1 -b .xiutmp
%patch5 -p1 -b .getopt
%patch6 -p1 -b .ccoptions
# Someone forgot to make clean in some packages :/
find . -name "*.o" -exec rm -f {} \;
find . -name "*~" -exec rm -f {} \;
perl -pi -e "s,#include <linux/ucdrom.h>,," ascdc-0.3/ascdc.c
%patch100 -p0 -b .asbutton

%build
for package in `ls` ; do
    cd $package 
    case $package in
	ascd-* )
            perl -pi -e "s,/etc/X11,/usr/X11R6/lib/X11,g"  * ascd/* libworkman/*
	    patch -p2 -b --suffix .compile < %{PATCH2}
	    CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" ./configure << EOF
/mnt/cdrom
%{_prefix}/X11R6/bin
%{_prefix}/X11R6/man/man1
%{_datadir}/afterstep/ascd
1
EOF
	    perl -pi -e "s,/usr/local/share/AScd,/usr/share/$package,g" * misc/*
	    make MANDIR=/usr/X11R6/man/man1 \
		BINDIR=/usr/X11R6/bin \
		THEMESDIR=/usr/share/$package \
		SHLIBDIR=/usr/X11R6/lib \
		CDEBUGFLAGS="$RPM_OPT_FLAGS" \
		CXXDEBUGFLAGS="$RPM_OPT_FLAGS"
	    ;;
	
	asdm* )
	    # xmkmf'ed stuff...
	    xmkmf -a
            perl -pi -e "s,/etc/X11,/usr/X11R6/lib/X11,g"  *
            # patch -b --suffix .compile < %{PATCH7}
	    make CDEBUGFLAGS="$RPM_OPT_FLAGS" \
	         CXXDEBUGFLAGS="$RPM_OPT_FLAGS" \
		 XDMDIR=/usr/share/asdm BINDIR=/usr/X11R6/bin \
		 SHLIBDIR=/usr/lib
	    ;;
	asampcd* | asDrinks* | asampmenu* | randbg* )
	    # These are perl scripts and don't need to be compiled...
	    ;;

	asbutton* | miniCHESS* )
	    # Non-autoconf'ed C...
	    make CCFLAGS="$RPM_OPT_FLAGS" CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS"
	    ;;
	   
	aspbm* )
	    make CCFLAGS="$RPM_OPT_FLAGS" CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS"
	    make -C conf CCFLAGS="$RPM_OPT_FLAGS" CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS"
	    ;;
	asmon* )
	    cd asmon
	    make
	    cd ..
	    ;;

	ASFiles* | Tasks* | asfaces* | asfatm* | asppp* | astrash* |  astuner* |\
	xfascd* | asxmcd* | asftavm* | aswmtheme* )
	    # ASFiles: needs some odd DnD library
	    # Tasks: must be compiled inside AfterStep source tree
	    # asfaces: broken beyond repair
	    # asfatm: needs temperature measurement kernel patch
	    # asppp: missing dial.xpm file
	    # astrash: needs OffiX
	    # astuner: needs linux/radio.h
	    # xfascd: needs XForms
	    # asxmcd: needs Motif
            # asftavm: needs i2c& sensors not part of default 2.2 kernels
	    # aswmtheme: not a module per se.

	    ;;

	xiterm*)
	    # cough cough, hack hack -- ewt
	    CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr/X11R6 \
		--enable-xpm-background --enable-utmp --enable-wtmp \
		--enable-menubar --enable-next-scroll --enable-kanji
	    xmkmf
	    make Makefiles
	    cd src
	    sed -e "s/EXTRA_LIBRARIES =/EXTRA_LIBRARIES = -lutempter/" \
	       Makefile > Makefile.foo
	    sed -e "s/-lsocket //" Makefile.foo > Makefile
	    make
	    ;;
	asclock*)
            perl -pi -e "s,/etc/X11,/usr/X11R6/lib/X11,g"  *
	    CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr/X11R6 << EOF
classic

EOF
             make
	     ;;
	*)
	    #just about every other thing supports autoconf
	    #
	    # Look ma, I'm broken!  What a shock.
	    rm -f config.cache
	    CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr/X11R6 --datadir=/usr/share --with-gtk-prefix=/usr
	    make
	    ;;
    esac
    cd ..
done

%install

rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/X11R6/bin
mkdir -p $RPM_BUILD_ROOT/usr/X11R6/man/man1
mkdir -p $RPM_BUILD_ROOT/usr/share/afterstep/desktop/icons/16bpp

for package in `ls` ; do
    cd $package 
    case $package in
	ASFiles* | Tasks* | asfaces* | asfatm* | asppp* | astrash* | astuner* | \
	xfascd* | asxmcd* | asftavm* )
	    # We ignore broken stuff and stuff that simply doesn't make
	    # much sense...
	    ;;

	asDrinks* | asampmenu* | randbg* | aswmtheme* )
	    cp -a *.pl $RPM_BUILD_ROOT/usr/X11R6/bin
	    ;;

	ascd-* | xiterm*)
	    if test -d ./ascd; then
		mkdir -p $RPM_BUILD_ROOT/usr/share/$package
		cp -a ascd/themes/* $RPM_BUILD_ROOT/usr/share/$package
		perl -pi -e "s,/usr/local/include,$RPM_BUILD_ROOT/usr/include,g" libworkman/Makefile
		perl -pi -e "s,/usr/local/lib,$RPM_BUILD_ROOT/usr/lib,g" libworkman/Makefile
		fi

	    make install install.man \
		AFTER_BIN_DIR=$RPM_BUILD_ROOT/usr/X11R6/bin \
		AFTER_MAN_DIR=$RPM_BUILD_ROOT/usr/X11R6/man/man1 \
		MANDIR=$RPM_BUILD_ROOT/usr/X11R6/man/man1 \
		BINDIR=$RPM_BUILD_ROOT/usr/X11R6/bin \
		THEMESDIR=$RPM_BUILD_ROOT/usr/share/$package \
		SHLIBDIR=$RPM_BUILD_ROOT/usr/X11R6/lib
	    ;;
        ascp-* )
	    make install \
	        ASCP_BIN_DIR=$RPM_BUILD_ROOT/usr/X11R6/bin \
		ASCP_MAN_DIR=$RPM_BUILD_ROOT/usr/X11R6/man/man1 \
		prefx=$RPM_BUILD_ROOT \
		DESTDIR=$RPM_BUILD_ROOT
	    ;;
	asmon-* )
	    cd asmon
	    perl -pi -e "s,/usr/local/bin,$RPM_BUILD_ROOT/usr/X11R6/bin,g" Makefile
	    make install \
	        AFTER_BIN_DIR=$RPM_BUILD_ROOT/usr/X11R6/bin \
		AFTER_MAN_DIR=$RPM_BUILD_ROOT/usr/X11R6/man/man1 \
		BINDIR=$RPM_BUILD_ROOT/usr/X11R6/bin \
		DESTDIR=$RPM_BUILD_ROOT
	    cd ..
	    ;;
	asclock-* | asdm-* | sessreg-* | xpmroot-* )
		make install DESTDIR=$RPM_BUILD_ROOT \
		AFTER_BIN_DIR=/usr/X11R6/bin \
		BINDIR=/usr/X11R6/bin \
		AFTER_MAN_DIR=/usr/X11R6/man/man1 \
		XDMDIR=/usr/share/asdm \
		MANDIR=/usr/X11R6/man/man1 \
		SHLIBDIR=/usr/lib
		make install.man DESTDIR=$RPM_BUILD_ROOT \
		AFTER_BIN_DIR=/usr/X11R6/bin \
			 BINDIR=/usr/X11R6/bin \
			 AFTER_MAN_DIR=/usr/X11R6/man/man1 \
			 MANDIR=/usr/X11R6/man/man1 \
	    ;;
	    
	miniCHESS-*)
		make install DESTDIR=$RPM_BUILD_ROOT/usr/X11R6/bin \
		AFTER_BIN_DIR=/usr/X11R6/bin \
			 BINDIR=/usr/X11R6/bin \
			 AFTER_MAN_DIR=/usr/X11R6/man/man1
	    ;;

	*)
		make install \
		AFTER_BIN_DIR=$RPM_BUILD_ROOT/usr/X11R6/bin \
		AFTER_MAN_DIR=$RPM_BUILD_ROOT/usr/X11R6/man/man1 \
		MANDIR=$RPM_BUILD_ROOT/usr/X11R6/man/man1 \
		BINDIR=$RPM_BUILD_ROOT/usr/X11R6/bin \
		DESTDIR=$RPM_BUILD_ROOT \
		ICONDIR=$RPM_BUILD_ROOT/usr/share/afterstep/desktop/icons/16bpp
		make install.man \
		AFTER_BIN_DIR=$RPM_BUILD_ROOT/usr/X11R6/bin \
		AFTER_MAN_DIR=$RPM_BUILD_ROOT/usr/X11R6/man/man1 \
		MANDIR=$RPM_BUILD_ROOT/usr/X11R6/man/man1 \
		BINDIR=$RPM_BUILD_ROOT/usr/X11R6/bin \
		DESTDIR=$RPM_BUILD_ROOT || true # should work for non-install.man targets as well...
	    ;;
    esac
    cd ..
done

rm -f $RPM_BUILD_ROOT/usr/X11R6/{bin,man/man1}/{sessreg,xpmroot,qplot}*
rm -f $RPM_BUILD_ROOT/usr/X11R6/lib/X11/app-defaults/Chooser
chmod 0755 $RPM_BUILD_ROOT/usr/X11R6/bin/asbutton
chmod 0755 $RPM_BUILD_ROOT/usr/share/afterstep/ascp/icons
chmod 0644 $RPM_BUILD_ROOT/usr/X11R6/man/man1/*


# creating file list
rm -f $RPM_BUILD_DIR/master.list.%{name}

#find $RPM_BUILD_ROOT  -type d | sed '1,2d;s|^\.|\%attr(-,root,root) \%dir |' \
#	> $RPM_BUILD_DIR/master.list.%{name}

find $RPM_BUILD_ROOT -type f -o -type l >> $RPM_BUILD_DIR/master.list.%{name}

sed -e "s,$RPM_BUILD_ROOT,,g" $RPM_BUILD_DIR/master.list.%{name} \
	| sed -e "s,/man[0-9]/.*,&\*,g" \
	| sort > file.list.%{name}

%clean
rm -rf $RPM_BUILD_ROOT
rm -f $RPM_BUILD_DIR/master.list.%{name}

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files -f file.list.%{name}
%defattr(-,root,root)
%dir /usr/share/ascd-*
%dir /usr/share/asdm

%changelog
* Wed Jan 30 2002 Toru Sagami <sagami@vinelinux.org> 20001212-0vl3
- Requires for utempter instead of file dependent /usr/sbin/utempter
- s/Copyright/License/

* Wed May 23 2001 <sagami@vinelinux.org>
- 001212-0vl2: add BuildPreReq: WindowMaker-devel and actually use it(ascd)

* Mon May 14 2001 <sagami@vinelinux.org>
- 001212-0vl1 from connectiva 000909
- --enable-kanji for xiterm

* Mon Feb  7 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- remove /usr/X11R6/lib/X11/app-defaults/Chooser
  it is provided by XFree86.

* Sun Feb  6 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- fix some Makefile issues:
  asclock, asdm, sessreg and xpmroot got installed to
  $RPM_BUILD_ROOT/$RPM_BUILD_ROOT and were therefore not included in the
  RPM.
  minichess was installed to $RPM_BUILD_ROOT/minichess, and therefore wasn't
  included in the RPM.

* Fri Feb  4 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- Fix permissions on /usr/X11R6/bin/asbutton and /usr/share/afterstep/ascp/icons

* Thu Feb  3 2000 Bill Nottingham <notting@redhat.com>
- add %defattr

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

* Thu Jan 27 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- 20000124
- BuildPrereq WindowMaker (we need WINGs.h)

* Mon Nov 15 1999 Bernhard Rosenkraenzer <bero@redhat.com>
- fix various bugs
- update source archive
- compile/fix some more components

* Tue Aug 17 1999 Bill Nottingham <notting@redhat.com>
- update source archive.

* Mon Apr  5 1999 Bill Nottingham <notting@redhat.com>
- strip binaries

* Mon Mar 29 1999 Bill Nottingham <notting@redhat.com>
- update source archive
- fix ascp

* Wed Mar 24 1999 Erik Troan <ewt@redhat.com>
- utempter support
- got xiterm building again

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

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

* Wed Sep 30 1998 Cristian Gafton <gafton@redhat.com>
- updated source archive
- remove  conflicting files with XFree86

* Wed Sep 16 1998 Cristian Gafton <gafton@redhat.com>
- split from afterstep and packaged for RH 5.2
