#==============================================================================
#      probal (as default) refresh clean edit example install
#==============================================================================

PROBAL = probal
PROBAL_DIR = $(PROBAL)
PROBAL_SRC = probal.c
PROBAL_HDR = 
PROBAL_OBJ = probal.o
PROBAL_LIB = -lm -lpng
PROBAL_EXE = $(PROBAL).x

CO = gcc
LD = $(CO)

CFLAGS = -DUNIX -pedantic -ansi -ffast-math -Wfloat-equal 
LDFLAGS = -Wall -O3

%.o: %.c %.h
	$(CO) $(CFLAGS) -c $<

.PHONY: probal default refresh edit clean example

default: probal

refresh:
	touch *.c
	make $(PROBAL)
	
$(PROBAL): $(PROBAL_OBJ) $(PROBAL_LIB) 
	$(LD) -o $(PROBAL_EXE) $(LDFLAGS) $(PROBAL_OBJ) $(PROBAL_LIB)
	echo "#!/bin/bash" > clean-results
	echo "rm -f needleman-*" >> clean-results
	echo "rm -f plot-*" >> clean-results
	echo "rm -f *.ppm *.png" >> clean-results
	chmod +x clean-results
	make example

clean:
	rm -f *.o *.x ~* *~ core* *.out *.png *.ppm
	rm clean-results
	rm example

edit:
	vi $()
	
example:
	echo "./$(PROBAL_EXE) seq/HUMMETIPG seq/AF348994 --freq freqmx/nfreq --matrix submx/DNA --tau 11200 --pixmap ppm --aligns 3 --gap-open 0 --gap-extend 0" > example
	chmod +x example

install:
	sudo cp $(PROBAL_EXE) /usr/bin/
