################################################################################
# Filename: ./src/plugins/dhcpd/Makefile
# 
# The contents of this file are subject to the Qlusters Public License
# Version 1.1 (the License); you may not use this file except in compliance
# with the License.
# You may obtain a copy of the License at
# http://www.openqrm.org/content/view/33/69/.
# 
# Software distributed under the License is distributed on an AS IS basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
# the specific language governing rights and limitations under the License.
# 
# The Original Code is openQRM.
# 
# The Initial Developer of the Original Code is Qlusters Corporation. Portions
# created by Qlusters Corporation are Copyright (C) 2003-2005. All Rights
# Reserved.
# 
# Contributor(s):
# 
# Description:
# 
# Comments:
################################################################################
#
# Qrm dhcpd Makefile
#

ifndef SOURCEDDIR
	export SOURCEDDIR=../..
endif

ifndef OUTDIR
	export OUTDIR=../../../out/
endif

PACKAGE_CONFIG_FILE_DHCPD=$(SOURCEDDIR)/plugins/dhcpd/build/dhcpd.conf
QRM_CACHE_DIR=$(shell $(SOURCEDDIR)/make_helper get_cache_dir)
QRM_ROOT_DIR=$(shell $(SOURCEDDIR)/make_helper get_root_dir)


all:	check
	@echo "making the dhcpd-plugin"
	/bin/cp -f build/qrm-dhcpd-patch /tmp/
	chmod +x /tmp/qrm-dhcpd-patch
	QRM_PRE_MAKE_CMD="/tmp/qrm-dhcpd-patch" \
	QRM_POST_MAKE_CMD="/bin/rm -f /tmp/qrm-dhcpd-patch" \
	$(SOURCEDDIR)/make_helper build_package $(PACKAGE_CONFIG_FILE_DHCPD)

install:
	@echo "installing dhcpd for Qrm"
	mkdir -p $(OUTDIR)/qrm/plugins/dhcpd/sbin $(OUTDIR)/qrm/plugins/dhcpd/var/state/dhcp/ $(OUTDIR)/qrm/plugins/dhcpd/etc/init.d/ $(OUTDIR)/qrm/plugins/dhcpd/include
	/bin/cp -f $(QRM_CACHE_DIR)/dhcpd/work.linux-2.2/server/dhcpd $(OUTDIR)/qrm/plugins/dhcpd/sbin/
	/bin/cp -f etc/dhcpd.conf.qrm $(OUTDIR)/qrm/plugins/dhcpd/etc/
	/bin/cp -f etc/init.d/dhcpd $(OUTDIR)/qrm/plugins/dhcpd/etc/init.d/
	/bin/cp -u etc/dhcpd.ini $(OUTDIR)/qrm/plugins/dhcpd/etc
	/bin/cp -f include/*-functions $(OUTDIR)/qrm/plugins/dhcpd/include
	chmod +x $(OUTDIR)/qrm/plugins/dhcpd/etc/init.d/*
	touch $(OUTDIR)/qrm/plugins/dhcpd/var/state/dhcp/dhcpd.leases

clean:	check
	@echo "cleaning up dhcpd"
	/bin/rm -rf $(OUTDIR)/qrm/plugins/dhcpd
		
realclean:	clean
	@echo "making realclean for the dhcpd plugin"
	/bin/rm -rf $(QRM_CACHE_DIR)/src/dhcp-3.0.3.tar.gz \
	  $(QRM_CACHE_DIR)/dhcpd \
	  $(QRM_ROOT_DIR)/build/dhcpd
		
check:
	@if [ -z $(QRM_CACHE_DIR) ]; then echo "ERROR: QRM_CACHE_DIR not set!"; exit 1; fi
	@if [ -z $(QRM_ROOT_DIR) ]; then echo "ERROR: QRM_ROOT_DIR not set!"; exit 1; fi

			
		
