# GF-Complete 'tools' AM file

AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
AM_CFLAGS = -O3 -fPIC

bin_PROGRAMS = gf_mult gf_div gf_add gf_time gf_methods gf_poly gf_inline_time

gf_mult_SOURCES = gf_mult.c
#gf_mult_LDFLAGS = -lgf_complete
gf_mult_LDADD = ../src/libgf_complete.la

gf_div_SOURCES = gf_div.c
#gf_div_LDFLAGS = -lgf_complete
gf_div_LDADD = ../src/libgf_complete.la

gf_add_SOURCES = gf_add.c
#gf_add_LDFLAGS = -lgf_complete
gf_add_LDADD = ../src/libgf_complete.la

gf_time_SOURCES = gf_time.c
#gf_time_LDFLAGS = -lgf_complete
gf_time_LDADD = ../src/libgf_complete.la

gf_methods_SOURCES = gf_methods.c
#gf_methods_LDFLAGS = -lgf_complete
gf_methods_LDADD = ../src/libgf_complete.la

gf_poly_SOURCES = gf_poly.c
#gf_poly_LDFLAGS = -lgf_complete
gf_poly_LDADD = ../src/libgf_complete.la

gf_inline_time_SOURCES = gf_inline_time.c
#gf_inline_time_LDFLAGS = -lgf_complete
gf_inline_time_LDADD = ../src/libgf_complete.la

# gf_unit 8 A -1 -m LOG_ZERO_EXT is excluded until http://lab.jerasure.org/jerasure/gf-complete/issues/13 is resolved
if ENABLE_VALGRIND
VALGRIND = | perl -p -e 's|^|../libtool --mode=execute valgrind --quiet --error-exitcode=1 --tool=memcheck | if(!/gf_unit 8 A -1 -m LOG_ZERO_EXT/)'
endif

# gf_unit tests as generated by gf_methods
gf_unit_w%.sh: gf_methods
	./$^ $(@:gf_unit_w%.sh=%) -A -U ${VALGRIND} > $@ || rm $@

TESTS = gf_unit_w128.sh \
        gf_unit_w64.sh  \
        gf_unit_w32.sh  \
        gf_unit_w16.sh  \
        gf_unit_w8.sh   \
        gf_unit_w4.sh

TEST_EXTENSIONS = .sh
SH_LOG_COMPILER = $(SHELL)
AM_SH_LOG_FLAGS = -e

CLEANFILES = $(TESTS)
