#
# Makefile for firebricks
#
#Copyleft:
#    firebricks provides firewall modules that can be integrated into
#    an existing firewall.
#    Copyright (C) 2002-2003 William Stearns <wstearns@pobox.com>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#    The author can also be reached at:
#        William Stearns
#email:  wstearns@pobox.com              (preferred)
#web:    http://www.stearns.org
#snail:  6 Manchester Dr.
#        Lebanon, NH 03766, USA
#

# Modified for Debian GNU/Linux.
DESTDIR =

#Make sure samlib has SAMVER updated when this changes
FIREBRICKSVER = 0.1.3

#No quotes around multi file specs.
LIBDIR=$(DESTDIR)/usr/lib/firebricks/
LIBFILES=address banfor30 blockfwdports bogons catchmapper catchmapreply checkbans established firebricks-template firebrickslib histogram icmpchk icmpfwdchk identreject ipopts kernel local-forward-accept local-input-accept local-output-accept lockdown mapssh pasvmap plength punishmapper scrutinize scrutinizedst scrutinizesrc tcpchk udpchk sample-script
DOCDIR=$(DESTDIR)/usr/share/doc/firebricks-${FIREBRICKSVER}/
DOCFILES=COPYING README.bricksummary.html README.firebricks.html firebricks.txt quickstart.txt
CONFDIR=$(DESTDIR)/etc/firebricks/
CONFFILES=blockfwdports.conf firebricks.conf
DATADIR=$(DESTDIR)/var/lib/firebricks/
DATAFILES=bogon-hosts bogon-bn-agg.txt
SYSVDIR=$(DESTDIR)/etc/init.d/
SYSVFILES=firebricks
#Others: bricksummary extract-pmap logserver

install:
	@echo -n "Installing files... "
	@echo -n "lib directory... "
	@install -o root -g root -m 0750 -d ${LIBDIR}
	@echo -n "${LIBFILES}... "
	@install -p -o root -g root -m 0644 ${LIBFILES} ${LIBDIR}
	@echo -n "doc directory... "
	@install -o root -g root -m 0750 -d ${DOCDIR}
	@echo -n "${DOCFILES}... "
	@install -p -o root -g root -m 0644 ${DOCFILES} ${DOCDIR}
	@echo -n "conf directory... "
	@install -o root -g root -m 0750 -d ${CONFDIR}
	@echo -n "${CONFFILES}... "
	@install -p -o root -g root -m 0644 ${CONFFILES} ${CONFDIR}
	@echo -n "data directory... "
	@install -o root -g root -m 0750 -d ${DATADIR}
	@echo -n "${DATAFILES}... "
	@install -p -o root -g root -m 0644 ${DATAFILES} ${DATADIR}
	@echo -n "SysV directory... "
	@install -o root -g root -m 0750 -d ${SYSVDIR}
	@echo -n "${SYSVFILES}... "
	@install -p -o root -g root -m 0644 ${SYSVFILES} ${SYSVDIR}
	@echo done!

#regress:
#	@if ./freedups-regression-test ; then \
#	echo Regression test succeeded. ; \
#	else \
#	echo Regression test failed, exiting. ; \
#	exit 1 ; \
#	fi

#regress
distribs: 
	@echo This should only need to be used by the author in 
	@echo packing up the firebricks package.
	cd .. \
	&& tar cf - firebricks-${FIREBRICKSVER}/ | \
	gzip -9 > firebricks-${FIREBRICKSVER}.tar.gz \
	&& rm -f firebricks-current \
	&& ln -sf firebricks-${FIREBRICKSVER} firebricks-current \
	&& tar cf - firebricks-current/* | \
	gzip -9 > firebricks-current.tar.gz \
	&& cp firebricks-${FIREBRICKSVER}.tar.gz /usr/src/redhat/SOURCES/ \
	&& cd firebricks-${FIREBRICKSVER} \
	&& cp -f redhat/firebricks.spec /usr/src/redhat/SPECS/ \
	&& rpm --sign -ba /usr/src/redhat/SPECS/firebricks.spec \
	&& cp -p /usr/src/firebricks-*.tar.gz /usr/src/mysource/ \
	&& cp -p /usr/src/redhat/RPMS/noarch/firebricks-*.noarch.rpm /usr/src/mysource/ \
	&& cp -p /usr/src/redhat/SRPMS/firebricks-*.src.rpm /usr/src/mysource/

#mini-install:
#	@if [ ! -f ${LIBDIR} ]; then \
#	mkdir -p ${LIBDIR} ; \
#	fi
#	cp -pf samlib /usr/lib/samlib

