# $Id$
# DNS Admin makefile

PKGNAME=dnsadmin
VERSION=0
RELEASE=1

# Include some boilerplate Gnu makefile definitions.
prefix = /usr/local

exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
libdir = ${exec_prefix}/lib
infodir = ${prefix}/info
includedir = ${prefix}/include
datadir = ${prefix}/share
localedir = $(datadir)/locale
sysconfdir = ${prefix}/etc
mandir = ${prefix}/man

INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_SCRIPT = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644
INSTALLMODE= -m 0755
INSTALLMODE2 = -m 0555

DESTDIR =

MANIFEST = \
	INSTALL COPYING TODO Makefile dnsadmin.spec new-dns.sql dns.sql dns.cgi DNSDB.pm \
	\
	index.shtml
	\
	images/trash2.png images/fwd.png images/ffwd.png images/frev.png \
	images/rev.png images/DESC.png images/ASC.png \
	\
	templates/fpnla.tmpl templates/updatesoa.tmpl templates/log.tmpl templates/newgrp.tmpl \
	templates/lettsearch.tmpl templates/delgrp.tmpl templates/deldom.tmpl templates/footer.tmpl \
	templates/header.tmpl templates/reclist.tmpl templates/adddomain.tmpl templates/deluser.tmpl \
	templates/editsoa.tmpl templates/pgcount.tmpl templates/dns.css templates/dnsq.tmpl \
	templates/grptree.tmpl templates/addgroup.tmpl templates/useradmin.tmpl templates/addrec.tmpl \
	templates/login.tmpl templates/adduser.tmpl templates/sbox.tmpl templates/record.tmpl \
	templates/whoisq.tmpl templates/domlist.tmpl templates/menu.tmpl \
	templates/soadata.tmpl templates/newdomain.tmpl templates/grpman.tmpl templates/axfr.tmpl \
	templates/newuser.tmpl templates/delrec.tmpl

DIRS = \
	images templates

##work
HTML = \
	addmaster.html alloctypes.html assign.html changes.html compsearch.html \
	confirm.html confirmRemove.html editDisplay.html fb-assign.html footer.inc \
	header.inc help.html index.shtml ipdb.css local.css \
	newcity.html newnode.html nodesearch.html startsn.html updated.html

IMAGES = images/logo.png

SCRIPTS = \
	cgi-bin/extras/db2rwhois.pl cgi-bin/combineblocks.pl cgi-bin/access-pwd-update.pl \
	cgi-bin/newnode.cgi cgi-bin/freespace.pl cgi-bin/admin.cgi \
	cgi-bin/main.cgi cgi-bin/newcity.cgi cgi-bin/allocate.pl \
	cgi-bin/search.cgi cgi-bin/consistency-check.pl

MODULES = cgi-bin/IPDB.pm

CONFIGMODULES = cgi-bin/MyIPDB.pm cgi-bin/CustIDCK.pm

all:
	# nullop

install:
	@for i in $(HTML) $(IMAGES); do \
		$(INSTALL_DATA) -D $$i $(DESTDIR)${libdir}/ipdb/$$i ; \
	done
	# munge in necessary 'use lib ...' bits so scripts can find MyIPDB.pm...
	@for i in $(SCRIPTS) $(MODULES); do \
		$(INSTALL_SCRIPT) -D $$i $(DESTDIR)${libdir}/ipdb/$$i ; \
		perl -pi -e 's|##uselib##|use lib "${sysconfdir}/ipdb/";|;' $(DESTDIR)${libdir}/ipdb/$$i ; \
	done
	$(INSTALL) -d $(DESTDIR)${sysconfdir}/ipdb/
	@for i in $(CONFIGMODULES) ; do \
		$(INSTALL_DATA) $$i $(DESTDIR)${sysconfdir}/ipdb/ ; \
	done
#	# and now munge MyIPDB.pm so it can find the core library
#	perl -pi -e 's|##uselib##|use lib "${libdir}/ipdb";|;' $(DESTDIR)${sysconfdir}/ipdb/MyIPDB.pm

#clean:
#	@for i in $(DIRS) ; do \
#		$(MAKE) -C $$i clean ; \
#	done

dist:
	mkdir $(PKGNAME)-$(VERSION)
	tar cf - $(MANIFEST) | (cd $(PKGNAME)-$(VERSION); tar xf -)
	/usr/bin/perl -p -e 's/#VERSION#/$(VERSION)/;s/#RELEASE#/$(RELEASE)/;s/#BETA#//g' < $(PKGNAME).spec > $(PKGNAME)-$(VERSION)/$(PKGNAME).spec
	/usr/bin/perl -p -e 's/#VERSION#/$(VERSION)/;s/#RELEASE#/$(RELEASE)/;s/#BETA#//g' < INSTALL > $(PKGNAME)-$(VERSION)/INSTALL
	perl -pi -e 's/[\d.]+;\s*##VERSION##/$(VERSION);/;' $(PKGNAME)-$(VERSION)/cgi-bin/IPDB.pm
	tar cf $(PKGNAME)-$(VERSION).tar $(PKGNAME)-$(VERSION)
	gzip -v -f -9 $(PKGNAME)-$(VERSION).tar
	rm -rf $(PKGNAME)-$(VERSION)
	# gpg --detach-sign $(PKGNAME)-$(VERSION).tar.gz
# $Id: Makefile 417 2010-06-30 21:48:03Z kdeugau $
# DNS Admin makefile

PKGNAME=dnsadmin
VERSION=0
RELEASE=1

# Include some boilerplate Gnu makefile definitions.
prefix = /usr/local

exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
libdir = ${exec_prefix}/lib
infodir = ${prefix}/info
includedir = ${prefix}/include
datadir = ${prefix}/share
localedir = $(datadir)/locale
sysconfdir = ${prefix}/etc
mandir = ${prefix}/man

INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_SCRIPT = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644
INSTALLMODE= -m 0755
INSTALLMODE2 = -m 0555

DESTDIR =

MANIFEST = \
	INSTALL COPYING TODO Makefile dnsadmin.spec new-dns.sql dns.sql dns.cgi DNSDB.pm \
	\
	index.shtml
	\
	images/trash2.png images/fwd.png images/ffwd.png images/frev.png \
	images/rev.png images/DESC.png images/ASC.png \
	\
	templates/fpnla.tmpl templates/updatesoa.tmpl templates/log.tmpl templates/newgrp.tmpl \
	templates/lettsearch.tmpl templates/delgrp.tmpl templates/deldom.tmpl templates/footer.tmpl \
	templates/header.tmpl templates/reclist.tmpl templates/adddomain.tmpl templates/deluser.tmpl \
	templates/editsoa.tmpl templates/pgcount.tmpl templates/dns.css templates/dnsq.tmpl \
	templates/grptree.tmpl templates/addgroup.tmpl templates/useradmin.tmpl templates/addrec.tmpl \
	templates/login.tmpl templates/adduser.tmpl templates/sbox.tmpl templates/record.tmpl \
	templates/whoisq.tmpl templates/domlist.tmpl templates/menu.tmpl \
	templates/soadata.tmpl templates/newdomain.tmpl templates/grpman.tmpl templates/axfr.tmpl \
	templates/newuser.tmpl templates/delrec.tmpl

DIRS = \
	images templates

##work
HTML = \
	addmaster.html alloctypes.html assign.html changes.html compsearch.html \
	confirm.html confirmRemove.html editDisplay.html fb-assign.html footer.inc \
	header.inc help.html index.shtml ipdb.css local.css \
	newcity.html newnode.html nodesearch.html startsn.html updated.html

IMAGES = images/logo.png

SCRIPTS = \
	cgi-bin/extras/db2rwhois.pl cgi-bin/combineblocks.pl cgi-bin/access-pwd-update.pl \
	cgi-bin/newnode.cgi cgi-bin/freespace.pl cgi-bin/admin.cgi \
	cgi-bin/main.cgi cgi-bin/newcity.cgi cgi-bin/allocate.pl \
	cgi-bin/search.cgi cgi-bin/consistency-check.pl

MODULES = cgi-bin/IPDB.pm

CONFIGMODULES = cgi-bin/MyIPDB.pm cgi-bin/CustIDCK.pm

all:
	# nullop

install:
	@for i in $(HTML) $(IMAGES); do \
		$(INSTALL_DATA) -D $$i $(DESTDIR)${libdir}/ipdb/$$i ; \
	done
	# munge in necessary 'use lib ...' bits so scripts can find MyIPDB.pm...
	@for i in $(SCRIPTS) $(MODULES); do \
		$(INSTALL_SCRIPT) -D $$i $(DESTDIR)${libdir}/ipdb/$$i ; \
		perl -pi -e 's|##uselib##|use lib "${sysconfdir}/ipdb/";|;' $(DESTDIR)${libdir}/ipdb/$$i ; \
	done
	$(INSTALL) -d $(DESTDIR)${sysconfdir}/ipdb/
	@for i in $(CONFIGMODULES) ; do \
		$(INSTALL_DATA) $$i $(DESTDIR)${sysconfdir}/ipdb/ ; \
	done
#	# and now munge MyIPDB.pm so it can find the core library
#	perl -pi -e 's|##uselib##|use lib "${libdir}/ipdb";|;' $(DESTDIR)${sysconfdir}/ipdb/MyIPDB.pm

#clean:
#	@for i in $(DIRS) ; do \
#		$(MAKE) -C $$i clean ; \
#	done

dist:
	mkdir $(PKGNAME)-$(VERSION)
	tar cf - $(MANIFEST) | (cd $(PKGNAME)-$(VERSION); tar xf -)
	/usr/bin/perl -p -e 's/#VERSION#/$(VERSION)/;s/#RELEASE#/$(RELEASE)/;s/#BETA#//g' < $(PKGNAME).spec > $(PKGNAME)-$(VERSION)/$(PKGNAME).spec
	/usr/bin/perl -p -e 's/#VERSION#/$(VERSION)/;s/#RELEASE#/$(RELEASE)/;s/#BETA#//g' < INSTALL > $(PKGNAME)-$(VERSION)/INSTALL
	perl -pi -e 's/[\d.]+;\s*##VERSION##/$(VERSION);/;' $(PKGNAME)-$(VERSION)/cgi-bin/IPDB.pm
	tar cf $(PKGNAME)-$(VERSION).tar $(PKGNAME)-$(VERSION)
	gzip -v -f -9 $(PKGNAME)-$(VERSION).tar
	rm -rf $(PKGNAME)-$(VERSION)
	# gpg --detach-sign $(PKGNAME)-$(VERSION).tar.gz
