# CONFIGURE HERE
# (no trailing slashes on directories)

PREFIX = /tmp
DOMAIN = myseasons.com
TINYDNSPATH = /tmp
DNSCACHEPATH = /tmp
LEASEFILE = /var/db/dhcpd.leases


# END CONFIGURE
# Makefile for dhcp_dns by Mike Stella <kazin@thismetalsky.org>

all:
	@echo "Maybe you want to run 'make install' instead?"
	@echo "Make sure you edited the paths at the top of the makefile."

install: 

	@if [ ! -d $(PREFIX)/bin ]; then \
	   echo "Error: $(PREFIX)/bin is not a valid path - check makefile" ; \
	   exit 1 ; \
	fi
	@if [ ! -d $(TINYDNSPATH)/root ]; then \
	   echo "Error: $(TINYDNSPATH)/root is not a valid path - check makefile" ; \
	   exit 1 ;\
	fi
	@if [ ! -d $(DNSCACHEPATH)/root ]; then \
	   echo "Error: $(DNSCACHEPATH)/root is not a valid path - check makefile" ; \
	   exit 1 ;\
	fi

	@# the main perl program
	@echo installing djb_update.pl
	@sed 's!TINYDNSPATH!$(TINYDNSPATH)!g' < djb_update.pl | sed 's!MYDOMAIN!$(DOMAIN)!' | sed 's!LEASEFILEPATH!$(LEASEFILE)!g' >  $(PREFIX)/bin/djb_update.pl
	@chmod 755 $(PREFIX)/bin/djb_update.pl

	@# the djbdns makefile
	@if [ -f $(TINYDNSPATH)/root/Makefile ] ; then \
	   cp $(TINYDNSPATH)/root/Makefile $(TINYDNSPATH)/root/orig.Makefile ; \
	   echo "saving old $(TINYDNSPATH)/root/Makefile" ; \
	fi
	@echo installing Makefile
	@sed 's!MYDOMAIN!$(DOMAIN)!g' < djbmakefile | sed 's!DNSCACHEPATH!$(DNSCACHEPATH)!g' > $(TINYDNSPATH)/root/Makefile


