prefix=@prefix@
exec_prefix=@exec_prefix@
sysconfdir=@sysconfdir@
bindir=@bindir@
sbindir=@sbindir@
libdir=@libdir@
datarootdir=@datarootdir@
datadir=@datadir@
includedir=@includedir@
mandir=@mandir@
top_srcdir=@top_srcdir@
man1dir=man1
#man3dir=@man3dir@
#man5dir=@man5dir@
#man8dir=@man8dir@
BUILDDIR=@abs_top_builddir@
PERLDIRS=tools/modules tools/donuts tools/mapper tools/scripts tools/convertar \
         tools/dnspktflow tools/maketestzone tools/etc tools/drawvalmap
PERLARGS=@PERLARGS@
SUBDIRS=@DNSSEC_SUBDIRS@
MKPATH=$(top_srcdir)/mkinstalldirs
INSTALLDIRS=$(prefix) $(exec_prefix) $(bindir) $(sbindir) $(libdir) $(datadir) $(includedir) $(mandir) $(mandir)/$(man1dir) $(mandir)/$(man3dir) $(mandir)/$(man5dir) $(mandir)/$(man8dir)
DOCINSTALL=@INSTALL@ @INSTALL_DATA@		
QUIET=@
MAN1PAGES=\
	dnssec-tools.1

all: makeit

libs: subdirmake

makeit: subdirmake perlmake

install: all makedirectories perlinstall subdirinstall maninstall nextstepinstructions

clean: perlclean subdirclean

distclean: subdirdistclean clean configclean 

nextstepinstructions: subdirinstall
	$(QUIET)echo ""
	$(QUIET)echo "**********************************************************************"
	$(QUIET)echo "** NEXT: Please run 'dtinitconf' in order to set up the required"
	$(QUIET)echo "**       $(sysconfdir)/dnssec-tools/dnssec-tools.conf file"
	$(QUIET)echo "**********************************************************************"
	$(QUIET)echo ""

maninstall:
	$(MKPATH) $(mandir)/$(man1dir)
	for i in $(MAN1PAGES) ; do		\
	  $(DOCINSTALL) docs/$$i $(DESTDIR)/$(mandir)/$(man1dir) ;	\
	done


makedirectories:
	$(QUIET)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:
	$(QUIET)if test "x$(SUBDIRS)" != "xnone" ; then \
	  for i in $(SUBDIRS) ; do \
	    (cd $$i ; make ) ; \
	    if test $$? != 0 ; then \
	       exit 1 ; \
	    fi  \
          done \
	fi

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

subdirclean:
	$(QUIET)if test "x$(SUBDIRS)" != "xnone" ; then \
	  for i in $(SUBDIRS) ; do \
	    (cd $$i ; make clean ) ; \
          done \
	fi

subdirdistclean:
	$(QUIET)if test "x$(SUBDIRS)" != "xnone" ; then \
	  for i in $(SUBDIRS) ; do \
	    (cd $$i ; make distclean ) ; \
          done \
	fi

#
# Perl system build rules
#

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

perlmakefiles:
	$(QUIET)for i in $(PERLDIRS) ; do \
	  if test ! -f $$i/Makefile ; then \
	    (cd $$i ; perl Makefile.PL $(PERLARGS) --topdir $(BUILDDIR) --sysconfdir $(sysconfdir)); \
          fi ; \
         done

perlinstall: makedirectories
	$(QUIET)for i in $(PERLDIRS) ; do \
	  (cd $$i ; make install ) ; \
	  if test $$? != 0 ; then \
	     exit 1 ; \
	  fi  \
         done

perlclean:
	$(QUIET)for i in $(PERLDIRS) ; do \
	  (cd $$i ; make clean ; ) ; \
         done

#
# Config system rules
#

configclean:
	rm -f config.cache config.status config.log \
		Makefile stamp-h *.core

.PHONY: all libs makeit install clean distclean nextstepinstructions makedirectories subdirmake subdirinstall subdirclean perlmake perlmakefiles perlinstall perlclean configclean
