################################################################################
# Filename: ./src/base/sbin/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:
################################################################################
#
# sbin directory Makefile
#
OUTDIR=../../../out

INSTALL_FILES := qrm-*,\
		exec_*,\
		interpolate.sh,\
		abs2rel,\
		rel2abs,\
		admin

INSTALL_FILES_IGNORE := *.c *.h
INSTALL_FILES_DEST := $(OUTDIR)/qrm/sbin
INSTALL ?= $(INSTALL_CMD) -D -m 0700

INC_NAME := ../Makefile.inc
include $(INC_NAME)

GCC += gcc
QRM_INFOD_SOURCES=qrminfod.c qutils_lite.c
QRM_TCP_MONITOR_SOURCES=qrm-tcp-monitor.c
QRM_FCNTL_TEST_SOURCES=qrm-fcntl-test.c

all:	check
	@echo "running make in sbin directory"


install: check qrm-infod qrm-tcp-monitor qrm-fcntl-test  

qrm-infod:
	@mkdir -p $(OUTDIR)/qrm/sbin
	$(GCC) -o $(OUTDIR)/qrm/sbin/qrm-infod -Wall -g $(QRM_INFOD_SOURCES)

qrm-tcp-monitor:
	@mkdir -p $(OUTDIR)/qrm/sbin
	$(GCC) -o $(OUTDIR)/qrm/sbin/qrm-tcp-monitor -Wall -g $(QRM_TCP_MONITOR_SOURCES)

qrm-fcntl-test:
	@mkdir -p $(OUTDIR)/qrm/sbin
	$(GCC) -o $(OUTDIR)/qrm/sbin/qrm-fcntl-test -O2 -Wall -g $(QRM_FCNTL_TEST_SOURCES)

clean:	check
	@echo "cleaning up sbin directory"
	rm -rf $(OUTDIR)/qrm/sbin

realclean: clean
	@echo "running realclean for the sbin directory"

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

.PHONY: all install clean realclean fix_files $(SUB_MAKEFILES) 
