#######################################################################
#
#  Copyright (C) 2006 Novell, Inc.
#
#  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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
#######################################################################

SUBDIRS =
DIST_SUBDIRS =

EXTRA_DIST = CASA_auth_token_svc.changes CASA_auth_token_svc.spec.in CASA_auth_token_svc_4zen.spec.in check-build.sh

RPM_FILE = $(PACKAGE)-$(VERSION)-$(RELEASE).$(target_cpu).rpm
#SRPM_FILE = $(PACKAGE)-$(VERSION)-$(RELEASE).src.rpm
SRPM_FILE = $(PACKAGE)-$(VERSION)*.src.rpm

SPEC_FILE = CASA_auth_token_svc.spec

.PHONY: package package-clean package-install package-uninstall casa

#all: $(RPM_FILE)

package: $(RPM_FILE)

all clean:

$(RPM_FILE):
	cd $(top_srcdir); make dist-bzip2
	rm -rf RPM
	mkdir RPM
	echo %_topdir `pwd`/RPM > $(HOME)/.rpmmacros
	mkdir -p RPM/BUILD
	mkdir -p RPM/RPMS
	mkdir -p RPM/SOURCES
	mkdir -p RPM/SPECS
	mkdir -p RPM/SRPMS
	cp $(SPEC_FILE) RPM/SPECS
	cp $(top_srcdir)/$(PACKAGE)-*.tar.bz2 RPM/SOURCES
	mv $(top_srcdir)/$(PACKAGE)-$(VERSION).tar.bz2 $(PACKAGE)-$(VERSION).tar.bz2 
	rpmbuild -ba -v -vv --target=$(target_triplet) RPM/SPECS/$(SPEC_FILE)
	cp RPM/RPMS/*/*.rpm .
	cp RPM/SRPMS/$(SRPM_FILE) .

package-install: package
	su -c "rpm -Uvh $(RPM_FILE)"
	
package-uninstall:
	su -c "rpm -e $(PACKAGE)"

package-clean clean-local:
	rm -rf *.rpm RPM *.bz2

distclean-local: package-clean
	rm -f Makefile $(SPEC_FILE)

maintainer-clean-local:
	rm -f Makefile.in

