
LIBS=@LIBS@
INCL= ../include
LIB= ../include
CFLAGS_EX=-I$(INCL) -I.. -I../libsres -I../libval -D_GNU_SOURCE
LOCALLIBS=../libval/libval$(LIBVAL_SUFFIX).la ../libsres/libsres.la
LDFLAGS_EX=$(LOCALLIBS) $(EXTRALIBS)

VAL_OBJ= validator_driver.o \
	validator_selftest.o 
VAL_LOBJ= validator_driver.lo \
	validator_selftest.lo

ALL_OBJ= $(VAL_OBJ) \
	getaddr.o \
	getrrset.o \
	getquery.o \
	gethost.o \
	getname.o \
	libsres_test.o \
    libval_check_conf.o \
    dane_check.o

ALL_LOBJ= $(VAL_LOBJ) \
	getaddr.lo \
	getrrset.lo \
	getquery.lo \
	gethost.lo \
	getname.lo \
	libsres_test.lo \
    libval_check_conf.lo \
    dane_check.lo

LT_DIR= .libs

VALIDATOR=dt-validate$(EXEEXT)
GETHOST=dt-gethost$(EXEEXT)
GETADDR=dt-getaddr$(EXEEXT)
GETRRSET=dt-getrrset$(EXEEXT)
GETQUERY=dt-getquery$(EXEEXT)
GETNAME=dt-getname$(EXEEXT)
CHECK_CONF=dt-libval_check_conf$(EXEEXT)
SRES_TEST=libsres_test$(EXEEXT)
DANECHK=dt-danechk$(EXEEXT)

all: $(VALIDATOR) $(GETHOST) $(GETADDR) $(GETRRSET) $(GETQUERY) $(GETNAME) $(CHECK_CONF) $(SRES_TEST) $(DANECHK)

clean:
	$(RM) -f $(ALL_LOBJ) $(ALL_OBJ) $(VALIDATOR) $(GETHOST) $(GETADDR) $(GETRRSET) $(GETQUERY) $(GETNAME) $(CHECK_CONF) $(SRES_TEST) $(DANECHK)
	$(RM) -rf $(LT_DIR)

$(VALIDATOR): $(VAL_OBJ) $(LOCALLIBS)
	$(LIBTOOLLD) -o $@ $(VAL_OBJ) $(LDFLAGS) $(LIBS)

$(GETHOST): gethost.lo $(LOCALLIBS)
	$(LIBTOOLLD) -o $@ gethost.lo $(LDFLAGS) $(LIBS)

$(GETADDR): getaddr.lo $(LOCALLIBS)
	$(LIBTOOLLD) -o $@ getaddr.lo $(LDFLAGS) $(LIBS)

$(GETRRSET): getrrset.lo $(LOCALLIBS)
	$(LIBTOOLLD) -o $@ getrrset.lo $(LDFLAGS) $(LIBS)

$(GETQUERY): getquery.lo $(LOCALLIBS)
	$(LIBTOOLLD) -o $@ getquery.lo $(LDFLAGS) $(LIBS)

$(GETNAME): getname.lo $(LOCALLIBS)
	$(LIBTOOLLD) -o $@ getname.lo $(LDFLAGS) $(LIBS)

$(CHECK_CONF): libval_check_conf.lo $(LOCALLIBS)
	$(LIBTOOLLD) -o $@ libval_check_conf.lo $(LDFLAGS) $(LIBS)

$(SRES_TEST): libsres_test.lo $(LOCALLIBS)
	$(LIBTOOLLD) -o $@ libsres_test.lo $(LDFLAGS) $(LIBS)

dnssec_checks: dnssec_checks.lo  $(LOCALLIBS)
	$(LIBTOOLLD) -o $@ dnssec_checks.lo $(LDFLAGS) $(LIBS)

$(DANECHK): dane_check.lo $(LOCALLIBS)
	$(LIBTOOLLD) -o $@ dane_check.lo $(LDFLAGS) $(LIBS)

test: $(VALIDATOR)
	./$(VALIDATOR) -o $(TEST_VERBOSITY):stderr -r /dev/null -v ../etc/dnsval.conf -i ../etc/root.hints -F selftests.dist -S :

leakchecks: $(VALIDATOR)
	valgrind --tool=memcheck --leak-check=full --show-reachable=yes ./$(VALIDATOR) -o 6:stderr -r /dev/null -i ../etc/root.hints -s

install:
	$(MKPATH) $(DESTDIR)$(bindir)
	$(LIBTOOLIN) $(VALIDATOR) $(DESTDIR)$(bindir)
	$(LIBTOOLIN) $(GETHOST) $(DESTDIR)$(bindir)
	$(LIBTOOLIN) $(GETADDR) $(DESTDIR)$(bindir)
	$(LIBTOOLIN) $(GETRRSET) $(DESTDIR)$(bindir)
	$(LIBTOOLIN) $(GETQUERY) $(DESTDIR)$(bindir)
	$(LIBTOOLIN) $(GETNAME) $(DESTDIR)$(bindir)
	$(LIBTOOLIN) $(CHECK_CONF) $(DESTDIR)$(bindir)
	$(LIBTOOLIN) $(DANECHK) $(DESTDIR)$(bindir)
	$(MKPATH) `echo $(DESTDIR)@VALIDATOR_TESTCASES@ | sed 's#/[^/]*$$##'`
	$(CP) selftests.dist $(DESTDIR)@VALIDATOR_TESTCASES@
