################################################################################
# Filename: ./src/base/tftpboot/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 pxe Makefile
#

ifndef SOURCEDDIR
	export SOURCEDDIR=../..
endif

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

PACKAGE_CONFIG_FILE_SYSLINUX=$(SOURCEDDIR)/base/tftpboot/build/syslinux.conf
PACKAGE_CONFIG_FILE_NASM=$(SOURCEDDIR)/base/tftpboot/build/nasm.conf
QRM_CACHE_DIR=$(shell $(SOURCEDDIR)/make_helper get_cache_dir)
QRM_ROOT_DIR=$(shell $(SOURCEDDIR)/make_helper get_root_dir)


all:	check
	$(SOURCEDDIR)/make_helper build_package $(PACKAGE_CONFIG_FILE_NASM)
	install -D $(QRM_CACHE_DIR)/nasm/nasm $(QRM_ROOT_DIR)/bin/nasm
	$(SOURCEDDIR)/make_helper build_package $(PACKAGE_CONFIG_FILE_SYSLINUX)

install:
	@echo "installing syslinux/pxelinux for Qrm"
	mkdir -p $(OUTDIR)/qrm/tftpboot/pxelinux/com32/modules $(OUTDIR)/qrm/tftpboot/pxelinux.cfg/ $(OUTDIR)/qrm/tftpboot/boot/
	/bin/cp -f $(QRM_CACHE_DIR)/syslinux/pxelinux.0 $(OUTDIR)/qrm/tftpboot/
	/bin/cp -f $(QRM_CACHE_DIR)/syslinux/com32/modules/mboot.c32 $(OUTDIR)/qrm/tftpboot/pxelinux/com32/modules/


clean:	check
	@echo "cleaning up syslinux/pxelinux"
	/bin/rm -rf $(OUTDIR)/qrm/tftpboot

realclean: clean
	@echo "running realclean for pxelinux"
	/bin/rm -rf $(QRM_CACHE_DIR)/src/syslinux-* \
	  $(QRM_CACHE_DIR)/src/nasm-* \
	  $(QRM_CACHE_DIR)/syslinux \
	  $(QRM_CACHE_DIR)/nasm \
	  $(QRM_ROOT_DIR)/build/syslinux \
	  $(QRM_ROOT_DIR)/bin \
	  $(QRM_ROOT_DIR)/build/nasm


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
	@if [ -z $(OUTDIR) ]; then echo "ERROR: OUTDIR not set!"; exit 1; fi

	  
