TEST_VERBOSITY=4
SUBDIRS=libsres libval apps doc libval_shim
LIBSUBDIRS=libsres libval libval_shim
WINSUBDIRS=libsres libval apps 
BUILD_ARCH = build

INSTALLDIRS=$(prefix) $(exec_prefix) $(sysconfdir)/dnssec-tools $(bindir) $(sbindir) $(libdir) $(datadir) $(includedir) $(mandir) $(man1dir) $(man3dir) $(man5dir) $(man8dir)		

all: subdirmake

libs: libsubdirmake

help:
	@echo ""
	@echo "make (all|libs|test|leakchecks|install|clean)"

test: subdirmake
	@(cd apps; make test)

leakchecks: subdirmake
	@(cd apps; make leakchecks)

makeit: subdirmake

nextstepinstructions:
	@echo ""
	@echo "**********************************************************************"
	@echo "** Not automatically installing dnsval.conf" 
	@echo "** Please copy this file from validator/etc to $(VAL_CONFIGURATION_FILE)"
	@echo "**********************************************************************"
	@echo "** Not automatically installing resolv.conf" 
	@echo "** If needed, please copy this file from validator/etc to $(VAL_RESOLV_CONF)"
	@echo "**********************************************************************"
	@echo "** Not automatically installing root.hints" 
	@echo "** If needed, please copy this file from validator/etc to $(VAL_ROOT_HINTS)"
	@echo "**********************************************************************"
	@echo ""

install: makedirectories localinstall subdirinstall nextstepinstructions

clean: subdirclean

distclean: clean configclean

makedirectories:
	@for i in $(INSTALLDIRS) ; do \
		if test ! -d $(DESTDIR)$$i ; then \
			echo "creating directory $(DESTDIR)$$i/" ; \
			$(MKPATH) $(DESTDIR)$$i ; \
		fi \
	done
#
# Subdir build rules
#

subdirmake:
	@for i in $(SUBDIRS) ; do \
	  (cd $$i ; make ) ; \
	  if test $$? != 0 ; then \
	     exit 1 ; \
	  fi  \
         done

libsubdirmake:
	@for i in $(LIBSUBDIRS) ; do \
		(cd $$i ; make ) ; \
		if test $$? != 0 ; then \
			exit 1 ; \
		fi  \
	done


subdirinstall:
	@for i in $(SUBDIRS) ; do \
	  (cd $$i ; make install DESTDIR=$(DESTDIR) ) ; \
	  if test $$? != 0 ; then \
	     exit 1 ; \
	  fi  \
         done

localinstall:
	$(INSTALL) libval-config $(DESTDIR)$(bindir)
	$(INSTALL) include/validator/validator-config.h $(DESTDIR)$(includedir)
	$(INSTALL) include/validator/validator-compat.h $(DESTDIR)$(includedir)

subdirclean:
	@for i in $(SUBDIRS) ; do \
	  (cd $$i ; make clean ) ; \
         done

#
# Config system rules
#

configclean:
	$(RM) -f $(CONFIG_CACHE_FILE) config.status config.log \
		Makefile stamp-h *.core

universal: clean
	make "CC=$(CC) -mmacosx-version-min=10.5 -arch x86_64 -arch i386 -arch ppc -bundle -undefined dynamic_lookup"

windows:
	@for i in $(WINSUBDIRS) ; do \
	  (cd $$i ; make ) ; \
	  if test $$? != 0 ; then \
	     exit 1 ; \
	  fi  \
         done

windows-install:
	@for i in $(WINSUBDIRS) ; do \
	  (cd $$i ; make install DESTDIR=$(DESTDIR) ) ; \
	  if test $$? != 0 ; then \
	     exit 1 ; \
	  fi  \
         done

TAGS:
	find . -name '*.[ch]' -print | etags -
