###############################################################################
# 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__

SPOOLLIB = libspool$(LIBEXT)

SPOOLLIB_DIR = $(SDIR)/libs/spool

SPOOLLIB_SRC = \
         sge_spooling.c \
         sge_spooling_utilities.c \
         sge_dirent.c

SPOOLLIB_OBJS = $(SPOOLLIB_SRC:.c=.o)

SPOOLLIB_TEST_PROGS_OBJ = \
         test_performance.o \
         test_sge_spooling.o \
         test_sge_spooling_utilities.o \
         test_spooling_mt.o

SPOOLLIB_TEST_PROGS = \
         test_performance \
         test_sge_spooling \
         test_sge_spooling_utilities \
         test_spooling_mt

###############################################################################
# global rules: all, clean, depend, messages
###############################################################################
spoollib: $(SPOOLLIB) spoolclib $(SPOOLLIB_TEST_PROGS)

spoollib_clean: spoolloaderlib_clean spooldlib_clean spoolblib_clean spoolclib_clean spoolclib_old_clean
		$(RM) $(SPOOLLIB_OBJS) libspool.a libspool$(SHAREDEXT) $(SPOOLLIB_TEST_PROGS) $(SPOOLLIB_TEST_PROGS_OBJ)

spoollib_depend: spoolloaderlib_depend spoolblib_depend spoolclib_depend spoolclib_old_depend
		$(DEPEND) -f$(SPOOLLIB_DIR)/spool_dependencies $(SPOOLLIB_DIR)/*.c

spoollib_messages: spoolloaderlib_messages spoolblib_messages spoolclib_messages spoolclib_old_messages
	@echo Creating $@
	@for i in `ls $(SPOOLLIB_DIR)/*.c`; do \
	   $(CC) $(CFLAGS) -DEXTRACT_MESSAGES -E $$i | $(XGETTEXT) - ;\
	done

###############################################################################
# rules to build library
###############################################################################
libspool.a:	$(SPOOLLIB_OBJS) 
	$(AR) $(ARFLAGS) libspool.a $(SPOOLLIB_OBJS)
	$(RANLIB) libspool.a

libspool$(SHAREDEXT): $(SPOOLLIB_OBJS) $(SGEOBJLIB) $(SGEOBJDLIB) $(COMMLIB) $(COMMLISTSLIB) $(CULLLIB) $(UTILIB) $(RMONLIB)
	$(SHAREDLD) $(SHARED_LFLAGS) -o libspool$(SHAREDEXT) $(SPOOLLIB_OBJS) -lsgeobj -lsgeobjd -lcomm -lcommlists -lcull -luti -lrmon $(LIBS) -lc

###############################################################################
# include dependencies for object files generated by sge_depend
###############################################################################
include $(SPOOLLIB_DIR)/spool_dependencies

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

sge_spooling_utilities.o: $(SPOOLLIB_DIR)/sge_spooling_utilities.c 
		$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SPOOLLIB_DIR)/sge_spooling_utilities.c

sge_dirent.o   : $(SPOOLLIB_DIR)/sge_dirent.c
		$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(SPOOLLIB_DIR)/sge_dirent.c

#---------------------------------------------------------------------
# test programs
test_performance: test_performance.o sig_handlers.o $(SPOOLING_DEPS) $(SPOOLLIB) $(SGEOBJLIB) $(SGEOBJDLIB) $(SCHEDLIB) $(LCKLIB) $(CULLLIB) $(COMMLIB) $(COMMLISTSLIB) $(UTILIB) $(RMONLIB) $(WINGRIDLIB_DEP)
	$(CC) -o test_performance $(LFLAGS) test_performance.o sig_handlers.o $(SPOOLING_LIBS) $(SPOOLLIB) $(SGEOBJLIB) $(SGEOBJDLIB) $(SCHEDLIB) $(LCKLIB) $(CULLLIB) $(COMMLIB) $(COMMLISTSLIB) $(UTILIB) $(RMONLIB) $(WINGRIDLIB) $(DLLIB) $(LIBS)

test_performance.o: $(SPOOLLIB_DIR)/test_performance.c
	$(CC) $(CFLAGS) -c $(SPOOLLIB_DIR)/test_performance.c

test_sge_spooling: test_sge_spooling.o sig_handlers.o $(SPOOLING_DEPS) $(SGEOBJLIB) $(SGEOBJDLIB) $(MIRLIB) $(EVCLIB) $(GDILIB) $(SCHEDLIB) $(LCKLIB) $(CULLLIB) $(COMMLIB) $(COMMLISTSLIB) $(UTILIB) $(RMONLIB) $(WINGRIDLIB_DEP)
	$(CC) -o test_sge_spooling $(LFLAGS) test_sge_spooling.o sig_handlers.o $(SPOOLING_LIBS) $(SCHEDLIB)  $(MIRLIB) $(EVCLIB) $(GDILIB) $(SGEOBJLIB) $(SGEOBJDLIB) $(COMMLIB) $(COMMLISTSLIB) $(CULLLIB) $(UTILIB) $(RMONLIB) $(WINGRIDLIB) $(LCKLIB) $(SECLIB) $(SLIBS) $(LIBS) $(DLLIB) 

test_sge_spooling.o: $(SPOOLLIB_DIR)/test_sge_spooling.c
	$(CC) $(CFLAGS) -c $(SPOOLLIB_DIR)/test_sge_spooling.c

test_sge_spooling_utilities: test_sge_spooling_utilities.o $(SPOOLING_DEPS) $(SGEOBJLIB) $(SGEOBJDLIB) $(MIRLIB) $(EVCLIB) $(GDILIB) $(SCHEDLIB) $(LCKLIB) $(CULLLIB) $(COMMLIB) $(COMMLISTSLIB) $(UTILIB) $(RMONLIB) $(WINGRIDLIB_DEP)
	$(LD_WRAPPER) $(CC) $(CFLAGS) -o test_sge_spooling_utilities $(LFLAGS) test_sge_spooling_utilities.o $(SPOOLING_LIBS) $(SPOOLLIB) $(SCHEDLIB)  $(MIRLIB) $(EVCLIB) $(GDILIB) $(SGEOBJLIB) $(SGEOBJDLIB) $(COMMLIB) $(COMMLISTSLIB) $(CULLLIB) $(UTILIB) $(RMONLIB) $(WINGRIDLIB) $(LCKLIB) $(SECLIB) $(SLIBS) $(LIBS) $(DLLIB)

test_sge_spooling_utilities.o: $(SPOOLLIB_DIR)/test_sge_spooling_utilities.c
	$(CC) $(CFLAGS) -c $(SPOOLLIB_DIR)/test_sge_spooling_utilities.c

test_spooling_mt: test_spooling_mt.o $(SPOOLING_DEPS) $(SGEOBJLIB) $(SGEOBJDLIB) $(MIRLIB) $(EVCLIB) $(GDILIB) $(SCHEDLIB) $(LCKLIB) $(CULLLIB) $(COMMLIB) $(COMMLISTSLIB) $(UTILIB) $(RMONLIB) $(WINGRIDLIB_DEP)
	$(CC) $(CFLAGS) -o test_spooling_mt $(LFLAGS) test_spooling_mt.o $(SPOOLING_LIBS) $(SCHEDLIB)  $(MIRLIB) $(EVCLIB) $(GDILIB) $(SGEOBJLIB) $(SGEOBJDLIB) $(COMMLIB) $(COMMLISTSLIB) $(CULLLIB) $(UTILIB) $(RMONLIB) $(WINGRIDLIB) $(LCKLIB) $(SECLIB) $(SLIBS) $(LIBS) $(DLLIB)

test_spooling_mt.o: $(SPOOLLIB_DIR)/test_spooling_mt.c
	$(CC) $(CFLAGS) -c $(SPOOLLIB_DIR)/test_spooling_mt.c

#---------------------------------------------------------------------
# include Makefiles for sublibs
include $(SDIR)/libs/spool/loader/Makefile

# spooling methods
include $(SDIR)/libs/spool/berkeleydb/Makefile
include $(SDIR)/libs/spool/classic/Makefile
include $(SDIR)/libs/spool/dynamic/Makefile
include $(SDIR)/libs/spool/flatfile/Makefile
