# This file is part of the Coral project.
# Please read the copyright notice in the LICENSE file.
ifeq ($(CORAL_VERSION),)
CORAL_VERSION:=0.$(shell date '+%Y%m%d')
endif
export CORAL_VERSION

rpmdir=/usr/src/redhat

.PHONY: coral.spec

coral.spec: coral.spec.in
	sed -e 's/@coral_version@/$(CORAL_VERSION)/g;' $< > $@

build: coral.spec
	(cd ../..; \
	 b=$$(basename $$(pwd)); \
	 cd ..; \
	 mv $$b coral-$(CORAL_VERSION); \
	 tar zcf $(rpmdir)/SOURCES/coral-$(CORAL_VERSION).tar.gz \
	 --exclude .svn \
	 --exclude "*.exe" \
	 --exclude "*.o" \
	 --exclude "*.log" \
	 --exclude "*.so" \
	 --exclude "*.pyc" \
	 --exclude "*~" \
	 coral-$(CORAL_VERSION); \
	 mv coral-$(CORAL_VERSION) $$b)
	r=/usr/src/redhat/BUILD/coral-$(CORAL_VERSION) \
	PYTHONPATH=$$r \
	LD_LIBRARY_PATH=$$r:$$r/coral \
	rpmbuild -ba coral.spec

