LIBVAL_MAN=libval.3
LIBVAL_ASYNC_MAN=libval_async.3
LIBVAL_SHIM_MAN=libval_shim.3
GHBN_MAN=val_gethostbyname.3
GADDR_MAN=val_getaddrinfo.3
QUERY_MAN=val_res_query.3
GETRRSET_MAN=val_get_rrset.3
POLICY_MAN=dnsval.conf.3
DANE_MAN=val_getdaneinfo.3

LIBVAL_SYMLINKS=\
    val_resolve_and_check.3	\
	val_create_context.3	\
	val_context_setqflags.3	\
	val_free_context.3	\
	val_istrusted.3	\
	val_isvalidated.3	\
	val_does_not_exist.3	\
	val_free_result_chain.3	\
	resolv_conf_set.3	\
	root_hints_set.3	\
	dnsval_conf_set.3	\
	resolv_conf_get.3	\
	root_hints_get.3	\
	dnsval_conf_get.3	\
	p_ac_status.3	\
	p_val_status.3

LIBVAL_ASYNC_SYMLINKS=\
	val_async_submit.3\
	val_async_select_info.3\
	val_async_check_wait.3\
	val_async_cancel.3\
	val_async_cancel_all.3

GHBN_SYMLINKS=\
	val_gethostbyname2.3 \
	val_gethostbyname_r.3 \
	val_gethostbyname2_r.3 \
    val_gethostbyaddr.3 \
    val_gethostbyaddr_r.3 

GADDR_SYMLINKS=\
    val_freeaddrinfo.3 \
    val_getnameinfo.3

QUERY_SYMLINKS=\
    val_free_response.3 \
    val_res_search.3 

GETRRSET_SYMLINKS=\
    val_free_answer_chain.3 

POLICY_SYMLINKS=\
	val_add_valpolicy.3

DANE_SYMLINKS=\
	val_dane_submit.3\
	val_dane_match.3\
	val_dane_check.3\
	val_free_dane.3\
	p_dane_error.3

MAN3PAGES=\
	  $(GADDR_MAN) \
	  $(GHBN_MAN) \
	  $(QUERY_MAN) \
	  $(GETRRSET_MAN) \
	  $(POLICY_MAN) \
	  $(LIBVAL_MAN) \
	  $(LIBVAL_ASYNC_MAN) \
	  $(LIBVAL_SHIM_MAN) \
	  $(DANE_MAN) \
	  libsres.3

MAN1PAGES=\
	dt-validate.1 \
	dt-getaddr.1 \
	dt-gethost.1 \
	dt-getname.1 \
	dt-getquery.1 \
	dt-getrrset.1 \
    dt-danechk.1 \
    dt-libval_check_conf.1

all: $(MAN1PAGES) $(MAN3PAGES) 

validator_api: validator_api.txt

checks:
	@for x in `grep VAL validator_api.xml | sed -e 's/.*VAL_\([A-Z_]*\).*/VAL_\1/'|sort -u`; \
	do \
	echo $$x; \
	find ../include/validator/ -name "*.h" | xargs -r grep $$x; \
	done


install:
	$(MKPATH) $(DESTDIR)/$(man1dir)
	for i in $(MAN1PAGES) ; do		\
	  $(DOCINSTALL) $$i $(DESTDIR)/$(man1dir) ;	\
	done
	$(MKPATH) $(DESTDIR)/$(man3dir)
	for i in $(MAN3PAGES) ; do		\
	  $(DOCINSTALL) $$i $(DESTDIR)/$(man3dir) ;	\
	done
	for i in $(LIBVAL_SYMLINKS) ; do		\
	  $(RM) -f $(DESTDIR)/$(man3dir)/$$i ;	\
	  echo ".so $(LIBVAL_MAN)" > $(DESTDIR)/$(man3dir)/$$i  ;	\
	done
	for i in $(LIBVAL_ASYNC_SYMLINKS) ; do		\
	  $(RM) -f $(DESTDIR)/$(man3dir)/$$i ;	\
	  echo ".so $(LIBVAL_ASYNC_MAN)" > $(DESTDIR)/$(man3dir)/$$i  ;	\
	done
	for i in $(GHBN_SYMLINKS) ; do		\
	  $(RM) -f $(DESTDIR)/$(man3dir)/$$i ;	\
	  echo ".so $(GHBN_MAN)" > $(DESTDIR)/$(man3dir)/$$i  ;	\
	done
	for i in $(GADDR_SYMLINKS) ; do		\
	  $(RM) -f $(DESTDIR)/$(man3dir)/$$i ;	\
	  echo ".so $(GADDR_MAN)" > $(DESTDIR)/$(man3dir)/$$i  ;	\
	done
	for i in $(QUERY_SYMLINKS) ; do		\
	  $(RM) -f $(DESTDIR)/$(man3dir)/$$i ;	\
	  echo ".so $(QUERY_MAN)" > $(DESTDIR)/$(man3dir)/$$i  ;	\
	done
	for i in $(GETRRSET_SYMLINKS) ; do		\
	  $(RM) -f $(DESTDIR)/$(man3dir)/$$i ;	\
	  echo ".so $(GETRRSET_MAN)" > $(DESTDIR)/$(man3dir)/$$i  ;	\
	done
	for i in $(POLICY_SYMLINKS) ; do		\
	  $(RM) -f $(DESTDIR)/$(man3dir)/$$i ;	\
	  echo ".so $(POLICY_MAN)" > $(DESTDIR)/$(man3dir)/$$i  ;	\
	done
	for i in $(DANE_SYMLINKS) ; do		\
	  $(RM) -f $(DESTDIR)/$(man3dir)/$$i ;	\
	  echo ".so $(DANE_MAN)" > $(DESTDIR)/$(man3dir)/$$i  ;	\
	done


# we don't clean up the man pages as they're normally distributed with
# the package and the generation rules are for the developers.
clean:


