###############################################################################
# Variable definitions for targets to build
###############################################################################
#___INFO__MARK_BEGIN__
##########################################################################
#
#  The Contents of this file are made available subject to the terms of
#  the Sun Industry Standards Source License Version 1.2
#
#  Sun Microsystems Inc., March, 2001
#
#
#  Sun Industry Standards Source License Version 1.2
#  =================================================
#  The contents of this file are subject to the Sun Industry Standards
#  Source License Version 1.2 (the "License"); You may not use this file
#  except in compliance with the License. You may obtain a copy of the
#  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
#  Software provided under this License is provided on an "AS IS" basis,
#  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
#  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
#  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
#  See the License for the specific provisions governing your rights and
#  obligations concerning the Software.
#
#  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
#  Copyright: 2001 by Sun Microsystems, Inc.
#
#  All Rights Reserved.
#
##########################################################################
#___INFO__MARK_END__
SCHEDLIB_DIR = $(SDIR)/libs/sched

SCHEDLIB    = libsched$(LIBEXT)
 
SCHEDLIB_SRC = sge_select_queue.c \
              valid_queue_user.c \
              sort_hosts.c \
              sge_complex_schedd.c \
              sge_job_schedd.c \
              sge_range_schedd.c \
              sge_pe_schedd.c \
              sge_qeti.c \
              debit.c \
              subordinate_schedd.c \
              load_correction.c \
              suspend_thresholds.c \
              schedd_monitor.c \
              sgeee.c \
              sge_urgency.c \
              sge_resource_utilization.c \
              sge_serf.c \
              sge_support.c \
              schedd_message.c \
              sge_orders.c \
              sge_schedd_text.c \
              sge_ssi.c \
              sge_sharetree_printing.c \
              sge_interactive_sched.c \
              sge_resource_quota_schedd.c

SCHEDLIB_OBJS = $(SCHEDLIB_SRC:.c=.o)

SCHEDLIB_TEST_PROGS = \
              test_eval_performance\
              test_resource_utilization \
              test_sge_load_formula

SCHEDLIB_TEST_PROGS_OBJS = \
              test_resource_utilization.o \
              sge_resource_utilization_test.o\
              test_eval_performance.o \
              test_sge_load_formula.o
              
###############################################################################
# global rules: all, clean, depend, messages
###############################################################################
schedlib_all:  $(SCHEDLIB) $(SCHEDLIB_TEST_PROGS)

schedlib: $(SCHEDLIB)

schedlib_clean:
	$(RM) libsched.a libsched$(SHAREDEXT) $(SCHEDLIB_OBJS) $(SCHEDLIB_TEST_PROGS) $(SCHEDLIB_TEST_PROGS_OBJS)

schedlib_depend:
		$(DEPEND) -f$(SCHEDLIB_DIR)/sched_dependencies $(SCHEDLIB_DIR)/*.c

schedlib_messages:
	@echo Creating $@
	@for i in `ls $(SCHEDLIB_DIR)/*.c`; do \
	   $(CC) $(CFLAGS) -DEXTRACT_MESSAGES -E $$i | $(XGETTEXT) - ;\
	done


###############################################################################
# rules to build library
###############################################################################
libsched.a: $(SCHEDLIB_OBJS)
	$(AR) $(ARFLAGS) libsched.a $(SCHEDLIB_OBJS)
	$(RANLIB) libsched.a

libsched$(SHAREDEXT): $(SCHEDLIB_OBJS) $(GDILIB) $(SGEOBJLIB) $(SGEOBJDLIB) $(COMMLIB) $(COMMLISTSLIB) $(CULLLIB) $(UTILIB) 
	$(SHAREDLD) $(SHARED_LFLAGS) -o libsched$(SHAREDEXT) $(SCHEDLIB_OBJS) -lgdi -lsgeobj -lsgeobjd -lcomm -lcommlists -lcull -luti $(LIBS) -lc

###############################################################################
# include dependencies for object files generated by sge_depend
###############################################################################
include $(SCHEDLIB_DIR)/sched_dependencies

###############################################################################
# rules to build object codes
###############################################################################
sge_orders.o : $(SCHEDLIB_DIR)/sge_orders.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/sge_orders.c

sge_schedd_text.o:	$(SCHEDLIB_DIR)/sge_schedd_text.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/sge_schedd_text.c

sge_select_queue.o : $(SCHEDLIB_DIR)/sge_select_queue.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/sge_select_queue.c
      
sge_complex_schedd.o : $(SCHEDLIB_DIR)/sge_complex_schedd.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/sge_complex_schedd.c

sge_job_schedd.o : $(SCHEDLIB_DIR)/sge_job_schedd.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/sge_job_schedd.c

sge_pe_schedd.o : $(SCHEDLIB_DIR)/sge_pe_schedd.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/sge_pe_schedd.c

sge_qeti.o : $(SCHEDLIB_DIR)/sge_qeti.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/sge_qeti.c

sge_range_schedd.o : $(SCHEDLIB_DIR)/sge_range_schedd.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/sge_range_schedd.c

debit.o : $(SCHEDLIB_DIR)/debit.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/debit.c

sort_hosts.o : $(SCHEDLIB_DIR)/sort_hosts.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/sort_hosts.c

subordinate_schedd.o : $(SCHEDLIB_DIR)/subordinate_schedd.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/subordinate_schedd.c

valid_queue_user.o : $(SCHEDLIB_DIR)/valid_queue_user.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/valid_queue_user.c

load_correction.o: $(SCHEDLIB_DIR)/load_correction.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/load_correction.c

suspend_thresholds.o: $(SCHEDLIB_DIR)/suspend_thresholds.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/suspend_thresholds.c

schedd_monitor.o: $(SCHEDLIB_DIR)/schedd_monitor.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/schedd_monitor.c

sgeee.o: $(SCHEDLIB_DIR)/sgeee.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/sgeee.c

sge_resource_utilization.o: $(SCHEDLIB_DIR)/sge_resource_utilization.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/sge_resource_utilization.c

sge_urgency.o: $(SCHEDLIB_DIR)/sge_urgency.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/sge_urgency.c

sge_serf.o: $(SCHEDLIB_DIR)/sge_serf.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/sge_serf.c

sge_support.o: $(SCHEDLIB_DIR)/sge_support.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/sge_support.c

schedd_message.o: $(SCHEDLIB_DIR)/schedd_message.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/schedd_message.c

sge_ssi.o: $(SCHEDLIB_DIR)/sge_ssi.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/sge_ssi.c

sge_sharetree_printing.o: $(SCHEDLIB_DIR)/sge_sharetree_printing.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/sge_sharetree_printing.c

sge_interactive_sched.o : $(SCHEDLIB_DIR)/sge_interactive_sched.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/sge_interactive_sched.c

sge_resource_quota_schedd.o : $(SCHEDLIB_DIR)/sge_resource_quota_schedd.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/sge_resource_quota_schedd.c

###############################################################################
# rules to build test applications 
###############################################################################

simple_scheduler: simple_scheduler.o sig_handlers.o $(SCHEDLIB) $(GDILIB) $(CULLLIB) $(COMMLIB) $(COMMLISTSLIB) $(UTILIB) 
	$(LD_WRAPPER) $(CC) $(CFLAGS) -o simple_scheduler $(LFLAGS) simple_scheduler.o sig_handlers.o $(SCHEDLIB) $(GDILIB) $(CULLLIB) $(COMMLIB) $(COMMLISTSLIB) $(UTILIB) $(LIBS)

test_resource_utilization: test_resource_utilization.o sge_mt_init.o $(SCHEDLIB) $(SGEOBJDLIB) $(SGEOBJLIB) $(GDILIB) $(CULLLIB) $(UTILIB) $(WINGRIDLIB_DEP) $(COMMLIB) $(COMMLISTSLIB)  
	$(LD_WRAPPER) $(CC) $(CFLAGS) -o test_resource_utilization $(LFLAGS) test_resource_utilization.o sge_mt_init.o $(SCHEDLIB) $(GDILIB) $(SGEOBJLIB) $(SGEOBJDLIB) $(CULLLIB) $(COMMLIB) $(DLLIB) $(COMMLISTSLIB) $(UTILIB) $(WINGRIDLIB) $(LIBS) $(SECLIB)

test_eval_performance: test_eval_performance.o $(SCHEDLIB) $(SGEOBJLIB) $(SGEOBJDLIB) $(CULLLIB) $(UTILIB) $(WINGRIDLIB_DEP) $(COMMLIB) $(COMMLISTSLIB) 
	$(LD_WRAPPER) $(CC) $(CFLAGS) -o test_eval_performance $(LFLAGS) test_eval_performance.o $(SCHEDLIB) $(SGEOBJLIB) $(SGEOBJDLIB) $(CULLLIB) $(COMMLIB) $(COMMLISTSLIB) $(UTILIB) $(WINGRIDLIB) $(DLLIB) $(SECLIB) $(LIBS)

simple_scheduler.o: $(SCHEDLIB_DIR)/simple_scheduler.c
	$(CC) $(CFLAGS) -c $(SCHEDLIB_DIR)/simple_scheduler.c

test_resource_utilization.o: $(SCHEDLIB_DIR)/test_resource_utilization.c
	$(CC) $(CFLAGS) -c $(SCHEDLIB_DIR)/test_resource_utilization.c

test_eval_performance.o: $(SCHEDLIB_DIR)/test_eval_performance.c 
	$(CC) -o test_eval_performance.o $(CFLAGS) $(SHARED_CFLAGS) -c $(SCHEDLIB_DIR)/test_eval_performance.c

test_sge_load_formula: test_sge_load_formula.o $(SCHEDLIB) $(SGEOBJLIB) $(SGEOBJDLIB) $(CULLLIB) $(UTILIB) $(WINGRIDLIB_DEP) $(COMMLIB) $(COMMLISTSLIB) 
	$(LD_WRAPPER) $(CC) $(CFLAGS) -o test_sge_load_formula $(LFLAGS) test_sge_load_formula.o $(SCHEDLIB) $(SGEOBJLIB) $(SGEOBJDLIB) $(CULLLIB) $(COMMLIB) $(COMMLISTSLIB) $(UTILIB) $(WINGRIDLIB) $(DLLIB) $(SECLIB) $(LIBS)

test_sge_load_formula.o: $(SCHEDLIB_DIR)/test_sge_load_formula.c
	$(CC) $(CFLAGS) -c $(SCHEDLIB_DIR)/test_sge_load_formula.c

