%define	name	AfterStep
%define	fver	@version@
%define	version	@version@
%define release 3
%define epoch   20
%define	prefix	/usr/X11R6
%define gdesk   /usr/share
%define generic 1
%define fedora 0
%{?_with_fedora:%define fedora 1}
%define mandrake 0
%{?_with_mandrake:%define mandrake 1}
%if %{fedora}
   %define generic 0
%endif
%if %{mandrake}
   %define generic 0
%endif

Summary:	AfterStep Window Manager (NeXTalike)
Name:		%{name}
Version:	%{version}
Release:	%{release}
Epoch:		%{epoch}
Copyright:	GPL
Group:		User Interface/Desktops
URL:		http://www.afterstep.org
Vendor:		The AfterStep Team (see TEAM in docdir)
Source0:	ftp://ftp.afterstep.org/stable/%{name}-%{fver}.tar.gz
Source1:	Xclients.afterstep
Source2:	afterstep
Source3: AfterStep.kdm
Source4: AfterStep.menu
Source5: AfterStep.menumethod
Distribution:	The AfterStep TEAM
Packager:	Sean Dague <sean at dague dot net>
BuildRoot:	%{_tmppath}/%{name}-%{version}-root
Requires:	%{name}-libs = %{version}
Requires: xloadimage

%description
  AfterStep is a Window Manager for X which started by emulating the
  NEXTSTEP look and feel, but which has been significantly altered
  according to the requests of various users. Many adepts will tell you
  that NEXTSTEP is not only the most visually pleasant interface, but
  also one of the most functional and intuitive out there. AfterStep
  aims to incorporate the advantages of the NEXTSTEP interface, and add
  additional useful features.

  The developers of AfterStep have also worked very hard to ensure
  stability and a small program footprint. Without giving up too many
  features, AfterStep still works nicely in environments where memory is
  at a premium.

%package libs
summary:	libraries required by afterstep 2.0
version:	%{version}
release:	%{release}
copyright:	GPL
group:		User Interface/Desktops
Provides: %{name}-libs = %{version}

%description libs
  Libraries neeeded by AfterStep 2.0

%package devel
summary:	AftterStep libs include files
version:	%{version}
release:	%{release}
copyright:	GPL
group:		User Interface/Desktops
Requires: %{name}-libs = %{version}

%description devel
  AftterStep libs include files

%prep
%setup -q -n %{name}-%{fver}

CFLAGS=$RPM_OPT_FLAGS \
./configure \
	--prefix=%{prefix}                        \
	--datadir=%{prefix}/share                 \
	--disable-staticlibs                      \
	--enable-sharedlibs                       \
	--with-xpm                                \
	--with-jpeg                               \
	--with-png                                \
	--with-ttf                                \
	--with-tiff                               \
	--with-gif                                \
	--with-jpeg                               \
	--enable-ascp                             \
	--enable-i18n                             \
	--with-helpcommand="aterm -e man"         \
	--with-desktops=1 --with-deskgeometry=2x3 \
	--with-imageloader="xsetbg"               \
	--disable-send-postcard-to-developer

%build
make

cd src/ASDocGen && ./ASDocGen -l log.html -t html && cd ../..

%install
if [[ -d $RPM_BUILD_ROOT ]]; then rm -rf $RPM_BUILD_ROOT; fi
mkdir -p $RPM_BUILD_ROOT

make DESTDIR=$RPM_BUILD_ROOT LDCONFIG=/bin/true install
rm -f $RPM_BUILD_ROOT%{prefix}/bin/{sessreg,xpmroot}
for f in libAfter{Base,Conf,Image,Step}; do
   cp -a $f/$f.so* %{buildroot}%{prefix}/lib
done

%if %{fedora}
#fedora-config prep
install -d $RPM_BUILD_ROOT%{gdesk}/switchdesk/
install -m 0644 %{SOURCE1} $RPM_BUILD_ROOT%{gdesk}/switchdesk/
install -d $RPM_BUILD_ROOT/etc/X11/gdm/Sessions/
install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT/etc/X11/gdm/Sessions/
install -d %{buildroot}%{gdesk}/xsessions/
install -m 0644 AfterStep.desktop.final %{buildroot}%{gdesk}/xsessions/afterstep.desktop
install -d %{buildroot}%{gdesk}/gnome/wm-properties/
install -m 0644 AfterStep.desktop.final %{buildroot}%{gdesk}/gnome/wm-properties/afterstep.desktop
rm -f %{buildroot}%{prefix}/share/xsessions/AfterStep.desktop
rmdir %{buildroot}%{prefix}/share/xsessions/
%endif
%if %{mandrake}
# mandrake menu items
install -d $RPM_BUILD_ROOT/etc/X11/wmsession.d/
install -m 0644 %{SOURCE3} $RPM_BUILD_ROOT/etc/X11/wmsession.d/42AfterStep
install -d $RPM_BUILD_ROOT/usr/lib/menu/afterstep
install -m 0644 %{SOURCE4} $RPM_BUILD_ROOT/usr/lib/menu/afterstep
install -d $RPM_BUILD_ROOT/etc/menu-methods/
install -m 0755 %{SOURCE5} $RPM_BUILD_ROOT/etc/menu-methods/AfterStep
rm -f %{buildroot}%{prefix}/share/xsessions/AfterStep.desktop
rmdir %{buildroot}%{prefix}/share/xsessions/
%endif

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root)
%doc ChangeLog NEW README* TEAM UPGRADE doc/languages doc/licences doc/code TODO doc/*.html
%doc src/ASDocGen/html/*html

%{prefix}/bin/*
%dir %{prefix}/share/afterstep
%{prefix}/share/afterstep/*
%{prefix}/man/man1/*
%if %{fedora}
/etc/X11/gdm/Sessions/afterstep
%{gdesk}/switchdesk/Xclients.afterstep
%{gdesk}/xsessions/afterstep.desktop
%{gdesk}/gnome/wm-properties/afterstep.desktop
%endif
%if %{mandrake}
/etc/X11/wmsession.d/42AfterStep
/usr/lib/menu/afterstep
/etc/menu-methods/AfterStep
%endif
%if %{generic}
%{prefix}/share/xsessions/AfterStep.desktop
%endif

%files libs
%defattr(-,root,root)
%doc libAfterImage/README 
%{prefix}/lib/*

%files devel
%defattr(-,root,root)
%dir %{prefix}/include/libAfterBase
%dir %{prefix}/include/libAfterConf
%dir %{prefix}/include/libAfterImage
%dir %{prefix}/include/libAfterStep
%{prefix}/include/libAfterBase/*
%{prefix}/include/libAfterConf/*
%{prefix}/include/libAfterImage/*
%{prefix}/include/libAfterStep/*
%{prefix}/man/man3/*
%doc src/ASDocGen/html/API/*html

%pre
for i in /usr /usr/local /usr/X11R6 ; do
	if [ -d $i/share/afterstep_old ]; then
		rm -r $i/share/afterstep_old;
	fi
	# %config /usr/share/afterstep should take care of this.
	#if [ -d $i/share/afterstep ]; then
	#	cp -pr $i/share/afterstep $i/share/afterstep_old;
	#	exit;
	#fi
done

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%changelog
* Mon Mar  7 2005 Sean Dague <sean@dague.net> 20:2.00.03-3
- set provides manually on libs, move some docs to main and devel

* Sun Mar  6 2005 Sean Dague <sean@dague.net> 2.00.03-2
- add with tagging to fedora vs. mandrake issues

* Thu Mar 03 2005 J.Krebs <rpm_speedy@yahoo.com> 2.00.03-1
- brought up to 2.00.03 release
- separated Fedora desktop config files into a separate rpm

* Sat Feb 26 2005 Sean Dague <sean@dague.net> 2.00.02-2
- brought up to 2.00.02 release

* Wed Sep 28 2004 Graydon Saunders <graydon@epiphyte.net> 2.00.00
- added %%{prefix}
- added the man pages to the -libs package

* Sun Dec 14 2003 Andre Costa <acosta@ar.microlink.com.br>
- split into three different RPMs
- AfterStep-libs is now required for AfterStep
- use qiv instead of xv for root image
- removed check for buildroot location on %clean
- removed references to RH startmenu

* Mon Dec 6 1999 David Mihm <webmaster@afterstep.org>
  [AfterStep-1.7.149-1]
- Updated to current version

* Wed Jun 9 1999 David Mihm <webmaster@afterstep.org>
  [AfterStep-1.7.111-1]
- Now this spec file is included in the distribution.
- Upgrade to latest snaphost 1.7.111
- Many thanks to Ryan Weaver for this spec file to include!!

* Tue Jun  8 1999 Ryan Weaver <ryanw@infohwy.com>
  [AfterStep-1.7.108-2]
- Made changes to spec to configure and install more like RedHat
  installations.
- Added %config to the /usr/share/afterstep listing to allow rpm to
  backup this dir if needed.

* Tue Jun  8 1999 Ryan Weaver <ryanw@infohwy.com>
  [AfterStep-1.7.108-1]
- Added patches 16-18 to make version 1.7.108

* Fri May 28 1999 Ryan Weaver <ryanw@infohwy.com>
  [AfterStep-1.7.105-1]
- Upgraded to 1.7.90 and added patches 1-15 to make it version 1.7.105.
- Made RPM relocatable.
- Building dynamic libs instead of static.

* Mon Feb  8 1999 Ryan Weaver <ryanw@infohwy.com>
  [AfterStep-1.6.10-1]
- Upgraded to 1.6.10

* Mon Jan  4 1999 Ryan Weaver <ryanw@infohwy.com>
  [AfterStep-1.6.6-3]
- Added a pre-install script to check to see if a previous versions
  share directory exists... If one does, it will copy it to afterstep_old.

* Thu Dec 31 1998 Ryan Weaver <ryanw@infohwy.com>
  [AfterStep-1.6.6-2]
- Configuring with no special settings and installing into
  default dirs as per David Mihm <davemann@ionet.net>

