# 2013/3/6
.PHONY:help all calculation movie clean
help:
	echo "make help, all, calculation, movie, clean, or reset"
	echo "all=calculation+movie"
all:calculation movie
calculation:wf000.dat
movie:wf.m1v
wf.m1v:wf000.png
	@rm -f wf.m1v
	ffmpeg -i wf%03d.png -r 30 -s 640x480 -sameq wf.m1v
wf000.png:wf000.dat wf.plt
	for i in wf*.dat;\
	do \
	cp $$i _wf.dat; \
	gnuplot wf.plt; \
	mv _wf.png $${i%dat}png ;\
	rm -f _wf.dat ;\
	done
BAK=wf.dat.tar.gz
wf000.dat:a.out
	if [ -e wf000.dat ]; \
	then \
	  if [ -e $(BAK) ]; \
	  then \
	    if [ -e $(BAK).1 ]; then  mv -f $(BAK).1 $(BAK).2; fi;\
	    mv -f $(BAK) $(BAK).1; \
	  fi;\
	  tar -czf $(BAK) wf*.dat ;\
	  rm -f wf*.dat ;\
	fi
	@echo "This calculation takes 0.2sec with CPU Intel Core-i7 3.3GHz"
	./a.out >& wf.log
a.out:wf.c
	gcc -O3 wf.c -lm
clean:
	@rm -f wf.log pot*.dat wf*.dat wf*.png a.out _wf.dat _wf.png
reset:clean
	@rm -f wf.m1v wf.dat.tar.gz* *~
