# @configure_input@

# Package-related substitution variables
package	= @PACKAGE_NAME@
version	= @PACKAGE_VERSION@
tarname	= @PACKAGE_TARNAME@
distdir	= $(tarname)-$(version)

# Prefix-related substitution variables
prefix	 = @prefix@
exec_prefix    = @exec_prefix@
bindir	 = @bindir@

# VPATH-related substitution variables
srcdir         = @srcdir@
VPATH          = @srcdir@

all clean install uninstall lib somoclu python python_doc python_clean python_install r r_clean matlab matlab_clean:
	$(MAKE) -C src $@

dist: $(distdir).tar.gz

$(distdir).tar.gz: FORCE $(distdir)
	tar chof - $(distdir) | gzip -9 -c >$(distdir).tar.gz
	rm -rf $(distdir)

$(distdir):
	mkdir -p $(distdir)/src
	mkdir -p $(distdir)/data
	cp $(srcdir)/configure $(distdir)
	cp $(srcdir)/config.h.in $(distdir)
	cp $(srcdir)/install-sh $(distdir)
	cp $(srcdir)/Makefile.in $(distdir)
	cp $(srcdir)/README.md $(distdir)
	cp $(srcdir)/LICENSE $(distdir)  
	cp $(srcdir)/CHANGES $(distdir)
	cp $(srcdir)/src/Makefile.in $(distdir)/src
	cp $(srcdir)/src/*.c* $(srcdir)/src/*.h $(distdir)/src
	cp $(srcdir)/data/rgbs.* $(distdir)/data
	cp -r $(srcdir)/src/MATLAB $(distdir)/src/
	cp -r $(srcdir)/src/Python $(distdir)/src/
	cp -r $(srcdir)/src/R $(distdir)/src/

distcheck: $(distdir).tar.gz
	gzip -cd $+ | tar xvf -
	$(MAKE) -C $(distdir) all check
	$(MAKE) -C $(distdir) DESTDIR=$${PWD}/$(distdir)/_inst install uninstall
	$(MAKE) -C $(distdir) clean
	rm -rf $(distdir)
	@echo "*** Package $(distdir).tar.gz is ready for distribution."

Makefile: Makefile.in config.status
	./config.status $@

config.status: configure
	./config.status --recheck

FORCE:
	-rm -rf $(distdir) &>/dev/null
	-rm $(distdir).tar.gz &>/dev/null

.PHONY: FORCE all clean check dist distcheck install uninstall
