#-----------------------------------------------------------------------------
#
#  POPular -- A POP3 server and proxy for large mail systems
#
#  $Id: Makefile.am,v 1.15 2001/08/10 14:01:22 sqrt Exp $
#
#  http://www.remote.org/jochen/mail/popular/
#
#-----------------------------------------------------------------------------
#
#  Copyright 1999-2001 by Jochen Topf <jochen@remote.org>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
#
#-----------------------------------------------------------------------------

EXTRA_DIST = auth conf debian scripts

SUBDIRS = lib src pdm @MAKE_TEST@ doc redhat

DIST_SUBDIRS = lib src pdm test doc redhat

RELEASE ?= 1

#
# use 'make rpm'
# or  'make rpm RELEASE=n'
# to build RedHat package
#
.PHONY: rpm
rpm: dist
	rm -rf redhat/rpm
	for i in BUILD INSTALL RPMS; do                             \
	  mkdir -p redhat/rpm/$$i;                                  \
	done
	echo "macrofiles: /usr/lib/rpm/macros:`pwd`/redhat/rpm/rpmmacros" >redhat/rpm/rpmrc
	echo "%_topdir `pwd`/redhat/rpm"    >redhat/rpm/rpmmacros
	if test -f .cvsignore; then                                 \
	  echo "%_sourcedir `pwd`"         >>redhat/rpm/rpmmacros;  \
	else                                                        \
	  echo "%_sourcedir `pwd`/.."      >>redhat/rpm/rpmmacros;  \
	fi
	echo "%_srcrpmdir `pwd`"           >>redhat/rpm/rpmmacros
	sed -e "s/__VERSION__/$(VERSION)/" <redhat/popular.spec | \
	  sed -e "s/__RELEASE__/$(RELEASE)/" >redhat/popular-$(VERSION).spec
	rpm --rcfile=/usr/lib/rpm/rpmrc:redhat/rpm/rpmrc -ba --buildroot=`pwd`/redhat/rpm/INSTALL redhat/popular-$(VERSION).spec
	mv redhat/rpm/RPMS/*/popular-*.rpm .
	rm -rf redhat/rpm

#
# use 'make deb'
# or  'make deb RELEASE=n'
# to build Debian package
#
.PHONY: deb
deb:
	( echo "popular ($(VERSION)-$(RELEASE)) unstable; urgency=low"; \
	echo; echo '  * see package changelog for details'; echo; \
	echo -n ' -- Jochen Topf <jochen@remote.org>  '; \
	date -R; echo; ) >debian/changelog
	EXTRA_CONF_OPTIONS="--with-cdb=/home/sqrt/src/cdb/cdb-0.75" dpkg-buildpackage -rfakeroot


.PHONY: test
test:
	cd test && $(MAKE) test

dist-hook:
	find $(distdir) -name CVS -print | xargs rm -fr
	find $(distdir) -name .cvsignore -print | xargs rm -f
	rm -fr $(distdir)/redhat/rpm


#-- THE END ------------------------------------------------------------------


syntax highlighted by Code2HTML, v. 0.9.1