#URL="http://bucket.mit.edu:8080/nilmdb"
URL="http://localhost/nilmdb"

all:
ifeq ($(INSIDE_EMACS), t)
	@make test
else
	@echo "Try 'make install'"
endif

test: test_cleanup

test_cleanup:
	src/cleanup.py -e extras/cleanup.cfg
	src/cleanup.py extras/cleanup.cfg

test_insert:
	@make install >/dev/null
	src/insert.py --file --dry-run  /test/foo </dev/null

test_copy:
	@make install >/dev/null
	src/copy_wildcard.py -U "http://nilmdb.com/bucket/" -D /lees*

test_prep:
	@make install >/dev/null
	-nilmtool destroy -R /test/raw
	-nilmtool destroy -R /test/sinefit
	-nilmtool destroy -R /test/prep
	nilmtool create /test/raw float32_2
	nilmtool create /test/sinefit float32_3
	nilmtool create /test/prep float32_8
	nilmtool insert -s '@0' -t -r 8000 /test/raw /tmp/raw.dat
	src/sinefit.py -c 1 /test/raw /test/sinefit
	src/prep.py -c 2 /test/raw /test/sinefit /test/prep
	nilmtool extract -s min -e max /test/prep | head -20

test_decimate:
	-@nilmtool destroy /lees-compressor/no-leak/raw/4 || true
	-@nilmtool destroy /lees-compressor/no-leak/raw/16 || true
	-@nilmtool create /lees-compressor/no-leak/raw/4 float32_18 || true
	-@nilmtool create /lees-compressor/no-leak/raw/16 float32_18 || true
	time python src/decimate.py -s '2013-02-04 18:10:00' -e '2013-02-04 18:11:00' /lees-compressor/no-leak/raw/1 /lees-compressor/no-leak/raw/4
	python src/decimate.py -s '2013-02-04 18:10:00' -e '2013-02-04 18:11:00' /lees-compressor/no-leak/raw/4 /lees-compressor/no-leak/raw/16

version:
	python setup.py version

dist: sdist
sdist:
	python setup.py sdist

install:
	python setup.py install

develop:
	python setup.py develop

clean::
	find . -name '*pyc' | xargs rm -f
	rm -rf nilmtools.egg-info/ build/ MANIFEST.in

gitclean::
	git clean -dXf

.PHONY: all version dist sdist install clean gitclean