# vim:ft=automake

rpm-build: rpm/spec dist
	@rm -f *.rpm
	@rm -f ~/rpmbuild/RPMS/x86_64/$(PACKAGE)-$(VERSION)*.rpm
	@rm -f ~/rpmbuild/SRPMS/$(PACKAGE)-$(VERSION)*.rpm
	@mkdir -p ~/rpmbuild/BUILD/
	@mkdir -p ~/rpmbuild/RPMS/i386/
	@mkdir -p ~/rpmbuild/RPMS/i686/
	@mkdir -p ~/rpmbuild/RPMS/noarch/
	@mkdir -p ~/rpmbuild/RPMS/x86_64/
	@mkdir -p ~/rpmbuild/SOURCES/
	@mkdir -p ~/rpmbuild/SPECS/
	@mkdir -p ~/rpmbuild/SRPMS/
	@cp $(PACKAGE)-$(VERSION).tar.gz ~/rpmbuild/SOURCES/
	@rpmbuild -ba --clean rpm/spec
	@cp ~/rpmbuild/RPMS/x86_64/$(PACKAGE)-$(VERSION)*.rpm .
	@cp ~/rpmbuild/RPMS/x86_64/$(PACKAGE)-devel-$(VERSION)*.rpm .
	@cp ~/rpmbuild/RPMS/x86_64/$(PACKAGE)-debuginfo-$(VERSION)*.rpm .
	@cp ~/rpmbuild/SRPMS/$(PACKAGE)-$(VERSION)*.rpm .

rpm-sign: rpm-build
	@rpm --addsign *.rpm
	@rpm --checksig *.rpm

clean-rpm:
	@rm -f *.tar.gz
	@rm -f *.src.rpm
	@rm -f *.rpm

rpm: rpm-build

release: rpm-sign

auto-rpmbuild:
	@auto-br-rpmbuild -ba rpm/spec