# make file, linking with gsl
# Written by Frederic Bois
# 22 June 2014
# Copyright (c) 2014 Frederic Bois.
#  This code is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  For more details
#  see the GNU General Public License at <http://www.gnu.org/licenses/> 


LEX  = flex
YACC = bison -y -d

# you can adapt the optimization flag if fast is not supported
CC   = gcc -o graph_sampler

GS_C_CODE = graph_sampler.c \
            concordance.c \
            degree.c \
            edge_number.c \
            lex.yy.c \
            likelihoods.c \
            lists.c \
            matrices.c \
            motifs.c \
            outputs.c \
            random.c \
            topo_sort.c \
            y.tab.c

GS_DEP    = $(GS_C_CODE) \
            graph_sampler.h \
            concordance.h \
            degree.h \
            edge_number.h \
            lexerr.h \
            likelihoods.h \
            lists.h \
            matrices.h \
            motifs.h \
            outputs.h \
            random.h \
            topo_sort.h \
            y.tab.h

GS_DIST   = $(GS_DEP) \
            Makefile \
            gs_parser.y \
            gs_lexer.l \
            graph_sampler.texi \
            script.txt \
	    COPYING

:
graph_sampler: $(GS_DEP)
	       $(CC) -Ofast $(GS_C_CODE) -lm -lgsl -lgslcblas

y.tab.c y.tab.h: gs_parser.y
	         $(YACC) gs_parser.y

lex.yy.c: gs_lexer.l y.tab.h
	  $(LEX) gs_lexer.l

run:
	graph_sampler script.txt

debug:  $(GS_DEP)
	$(CC) -Wall -g -DDEBUG $(GS_C_CODE) -lm -lgsl -lgslcblas

info:   graph_sampler.texi
	makeinfo --force --no-split graph_sampler.texi

html:   graph_sampler.texi
	makeinfo --force --html --no-split graph_sampler.texi

pdf:    graph_sampler.texi
	makeinfo --force --pdf graph_sampler.texi

distrib:
	zip graph_sampler_v0.0.0.zip $(GS_DIST)

tarball: y.tab.c y.tab.h lex.yy.c
	makeinfo --force --pdf graph_sampler.texi
	tar cf graph_sampler_v0.0.0.tar $(GS_DIST) graph_sampler.pdf
	gzip graph_sampler_v0.0.0.tar
