CC = gcc
CFLAGS = -O3 -std=gnu99
#CFLAGS = -Wall -O4 -mtune=native -funroll-loops -DNDEBUG -fomit-frame-pointer -std=gnu99 -msse2 
#CFLAGS = -std=c99 -Wall -g -std=gnu99 -fstack-protector-all -D_FORTIFY_SOURCE=2
#CFLAGS = -pg -std=gnu99   -O2 -funroll-loops 

LD = ld
LDFLAGS = -lm -lz -lbz2
INCFLAGS = 
DEFINES =
MANDIR = ../man
objects = base.o sequence.o qual.o gf4.o mats.o syndrome.o trellis.o probe.o

all: solidCaller
test: test-sequence test-gf4 test-syndrome

solidCaller: $(objects) caller.o
	$(CC) $(CFLAGS) $(DEFINES) $(INCFLAGS) -o ../bin/$@ $(LDFLAGS) $^

test-sequence: base.o qual.o
	$(CC) $(DEFINES) $(CFLAGS) $(INCFLAGS) $(LDFLAGS) -o ../bin/$@ -DTEST sequence.c $^

test-gf4: base.o mats.o
	$(CC) $(DEFINES) $(CFLAGS) $(INCFLAGS) $(LDFLAGS) -o ../bin/$@ -DTEST gf4.c $^

test-syndrome: base.o qual.o sequence.o gf4.o mats.o
	$(CC) $(DEFINES) $(CFLAGS) $(INCFLAGS) $(LDFLAGS) -o ../bin/$@ -DTEST syndrome.c $^

%.o : %.c
	$(CC) $(CFLAGS) $(DEFINES) $(INCFLAGS) -o $@ -c $<

.f.o:
	g77 -O3 -o $@ -c $<

%.1.html : %.1.txt
	cd $(MANDIR) && asciidoc -d manpage $<

%.1 : %.1.txt
	cd $(MANDIR) && a2x -d manpage -f manpage $<

clean:
	rm -f ../bin/solidCaller *~ *.o  *.obj  *.exe *.lib $(MANDIR)/*.1 $(MANDIR)/*.1.html

archive: clean 
	cd ../.. && tar zcf solid-caller.tgz --exclude=.git --exclude=archive --exclude=test solid-caller

man: man_troff man_html

man_troff: $(MANDIR)/solid-caller.1 

man_html: $(MANDIR)/ayb-recal.1.html

