GHCMAKE    = ghc --make -O
RUNHASKELL = runhaskell

default: 
	@echo "Make 'user_install' or 'install'"

clean:
	find . -name *.o -o -name *.hi -o -name *.p_o -o -name *.p_hi | xargs rm

user_install: user_conf build haddock user_inst

install: conf build haddock inst

user_conf:
	$(RUNHASKELL) Setup.hs configure -p --user --prefix=${HOME}

build:
	$(RUNHASKELL) Setup.hs build 

haddock: 
	$(RUNHASKELL) Setup.hs haddock

user_inst:
	$(RUNHASKELL) Setup.hs install --user

conf:
	$(RUNHASKELL) Setup.hs configure -p 

inst:
	sudo $(RUNHASKELL) ./Setup.hs install

test:
	$(GHCMAKE) Bio/Test.hs -o qc
	./qc

test_hpc:
	$(GHCMAKE) -fhpc Bio/Test.hs -o qc.hpc
	./qc.hpc
	hpc report qc.hpc

bench:
	$(GHCMAKE) Bio/Bench.hs -o qb
	@echo ==================== >> benchmark.log
	@echo -n Start: >> benchmark.log
	@date >> benchmark.log
	@uname -a >> benchmark.log
	@echo ghc version: `strings qb | grep '^[6-9]\.[0-9]'` >> benchmark.log
	@echo $(GHCMAKE) >> benchmark.log
	./qb +RTS -sbenchmark.gc | tee -a benchmark.log
	@echo -n End: >> benchmark.log
	@date >> benchmark.log

bench_hpc:
	$(GHCMAKE) Bio/Bench.hs -o qb.hpc
	./qb.hpc
	hpc report qb.hpc

update:
	darcs pull http://malde.org/~ketil/bio
