###############################################################################
# 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__
CULLLIB_DIR   = $(SDIR)/libs/cull

CULLLIB 	= libcull$(LIBEXT)

CULLLIB_SRC 	= cull_list.c \
                cull_hash.c \
                cull_where.c \
                cull_parse.c \
                cull_what.c \
                cull_what_print.c \
                cull_multitype.c \
                cull_db.c \
                cull_sort.c \
                cull_dump_scan.c \
                cull_lerrno.c \
                cull_pack.c \
                cull_tree.c \
                cull_file.c \
                cull_state.c \
                pack.c

CULLTEST_SRC   = example1.c example2.c \
                 test_cull_list.c test_cull_pack.c test_cull_hash.c test_enumeration.c

CULLLIB_OBJS = $(CULLLIB_SRC:.c=.o)

CULLTEST_OBJS = $(CULLTEST_SRC:.c=.o)

CULL_ALL 	= example1 example2 test_cull_list test_cull_pack test_cull_hash test_enumeration

###############################################################################
# global rules: all, clean, depend, messages
###############################################################################
culllib: $(CULLLIB) 

culllib_all: $(CULL_ALL)
	
culllib_clean: 
	$(RM) $(CULL_ALL) $(CULLLIB_OBJS) libcull.a libcull$(SHAREDEXT) $(CULLTEST_OBJS) $(CULL_ALL)

culllib_depend:
	$(DEPEND) -f$(CULLLIB_DIR)/cull_dependencies $(CULLLIB_DIR)/*.c

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

###############################################################################
# rules to build library
###############################################################################
libcull.a:  $(CULLLIB_OBJS)
	$(AR) $(ARFLAGS) libcull.a $(CULLLIB_OBJS)
	$(RANLIB) libcull.a 

libcull$(SHAREDEXT): $(CULLLIB_OBJS) $(UTILIB) $(RMONLIB)
	$(SHAREDLD) $(SHARED_LFLAGS) -o libcull$(SHAREDEXT) $(CULLLIB_OBJS) -luti -lrmon -llck $(LIBS) -lc

###############################################################################
# include dependencies for object files generated by sge_depend
###############################################################################
include $(CULLLIB_DIR)/cull_dependencies

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

cull_hash.o: $(CULLLIB_DIR)/cull_hash.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(CULLLIB_DIR)/cull_hash.c

cull_where.o: $(CULLLIB_DIR)/cull_where.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(CULLLIB_DIR)/cull_where.c

cull_what.o: 	$(CULLLIB_DIR)/cull_what.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(CULLLIB_DIR)/cull_what.c

cull_what_print.o: 	$(CULLLIB_DIR)/cull_what_print.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(CULLLIB_DIR)/cull_what_print.c

cull_sort.o: 	$(CULLLIB_DIR)/cull_sort.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(CULLLIB_DIR)/cull_sort.c

cull_parse.o: $(CULLLIB_DIR)/cull_parse.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(CULLLIB_DIR)/cull_parse.c 

cull_multitype.o: $(CULLLIB_DIR)/cull_multitype.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(CULLLIB_DIR)/cull_multitype.c

cull_db.o:  $(CULLLIB_DIR)/cull_db.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(CULLLIB_DIR)/cull_db.c

cull_dump_scan.o:	$(CULLLIB_DIR)/cull_dump_scan.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(CULLLIB_DIR)/cull_dump_scan.c

cull_lerrno.o: $(CULLLIB_DIR)/cull_lerrno.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(CULLLIB_DIR)/cull_lerrno.c

cull_pack.o: $(CULLLIB_DIR)/cull_pack.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(CULLLIB_DIR)/cull_pack.c

cull_tree.o:  $(CULLLIB_DIR)/cull_tree.c
	$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(CULLLIB_DIR)/cull_tree.c

cull_file.o:   $(CULLLIB_DIR)/cull_file.c
	$(CC) $(CFLAGS) $(MEMCFLAG) $(SHARED_CFLAGS) -c $(CULLLIB_DIR)/cull_file.c

cull_state.o:   $(CULLLIB_DIR)/cull_state.c
	$(CC) $(CFLAGS) $(MEMCFLAG) $(SHARED_CFLAGS) -c $(CULLLIB_DIR)/cull_state.c
   
pack.o:		$(CULLLIB_DIR)/pack.c
		$(CC) $(CFLAGS) $(SHARED_CFLAGS) -c $(CULLLIB_DIR)/pack.c

#---------------------------------------------------------------------
# example1

EXAMPLE1_DEPS = example1.o $(CULLLIB) $(UTILIB) $(WINGRIDLIB_DEP) $(RMONLIB) $(COMMLISTSLIB) $(LCKLIB)
EXAMPLE1_OBJS = example1.o $(CULLLIB) $(UTILIB) $(WINGRIDLIB) $(RMONLIB) $(COMMLISTSLIB) $(LCKLIB)

example1: $(EXAMPLE1_DEPS)
	$(LD_WRAPPER) $(CC) $(CFLAGS) -o example1 $(LFLAGS) $(EXAMPLE1_OBJS) $(LIBS)

example1.o: $(CULLLIB_DIR)/example1.c
	$(CC) $(CFLAGS) -c $(CULLLIB_DIR)/example1.c

#---------------------------------------------------------------------
# example2

EXAMPLE2_DEPS = example2.o $(CULLLIB) $(WINGRIDLIB_DEP) $(UTILIB) $(RMONLIB) $(COMMLISTSLIB) $(LCKLIB)
EXAMPLE2_OBJS = example2.o $(CULLLIB) $(WINGRIDLIB) $(UTILIB) $(RMONLIB) $(COMMLISTSLIB) $(LCKLIB)

example2: $(EXAMPLE2_DEPS)
	$(LD_WRAPPER) $(CC) $(CFLAGS) -o example2 $(LFLAGS) $(EXAMPLE2_OBJS) $(LIBS)

example2.o: $(CULLLIB_DIR)/example2.c
	$(CC) $(CFLAGS) -c $(CULLLIB_DIR)/example2.c

#---------------------------------------------------------------------
# test programs
test_cull_list: test_cull_list.o $(CULLLIB) $(WINGRIDLIB_DEP) $(UTILIB) $(RMONLIB) $(COMMLISTSLIB) $(LCKLIB)
	$(LD_WRAPPER) $(CC) $(CFLAGS) -o test_cull_list $(LFLAGS) test_cull_list.o $(CULLLIB) $(WINGRIDLIB) $(UTILIB) $(RMONLIB) $(COMMLISTSLIB) $(LCKLIB) $(LIBS)

test_cull_list.o: $(CULLLIB_DIR)/test_cull_list.c
	$(CC) $(CFLAGS) -c $(CULLLIB_DIR)/test_cull_list.c

#---
test_cull_pack: test_cull_pack.o $(CULLLIB) $(WINGRIDLIB_DEP) $(UTILIB) $(RMONLIB) $(COMMLISTSLIB) $(LCKLIB)
	$(LD_WRAPPER) $(CC) $(CFLAGS) -o test_cull_pack $(LFLAGS) test_cull_pack.o $(CULLLIB) $(WINGRIDLIB) $(UTILIB) $(RMONLIB) $(COMMLISTSLIB) $(LCKLIB) $(LIBS)

test_cull_pack.o: $(CULLLIB_DIR)/test_cull_pack.c
	$(CC) $(CFLAGS) -c $(CULLLIB_DIR)/test_cull_pack.c

#---
test_cull_db_pack: test_cull_db_pack.o $(SGELIB) $(CULLLIB) $(WINGRIDLIB_DEP) $(UTILIB) $(RMONLIB) $(COMMLISTSLIB) $(LCKLIB)
	$(LD_WRAPPER) $(CC) $(CFLAGS) -o test_cull_db_pack $(LFLAGS) test_cull_db_pack.o $(SGELIB) $(CULLLIB) $(WINGRIDLIB) $(UTILIB) $(RMONLIB) $(COMMLISTSLIB) $(LCKLIB) $(LIBS)

test_cull_db_pack.o: $(CULLLIB_DIR)/test_cull_db_pack.c
	$(CC) $(CFLAGS) -c $(CULLLIB_DIR)/test_cull_db_pack.c

#---
test_cull_hash: test_cull_hash.o $(CULLLIB) $(WINGRIDLIB_DEP) $(UTILIB) $(RMONLIB) $(COMMLISTSLIB) $(LCKLIB)
	$(LD_WRAPPER) $(CC) $(CFLAGS) -o test_cull_hash $(LFLAGS) test_cull_hash.o $(CULLLIB) $(WINGRIDLIB) $(UTILIB) $(RMONLIB) $(COMMLISTSLIB) $(LCKLIB) $(LIBS)

test_cull_hash.o: $(CULLLIB_DIR)/test_cull_hash.c
	$(CC) $(CFLAGS) -c $(CULLLIB_DIR)/test_cull_hash.c

#---
test_enumeration: test_enumeration.o $(CULLLIB) $(WINGRIDLIB_DEP) $(UTILIB) $(RMONLIB) $(COMMLISTSLIB) $(LCKLIB)
	$(LD_WRAPPER) $(CC) $(CFLAGS) -o test_enumeration $(LFLAGS) test_enumeration.o $(CULLLIB) $(WINGRIDLIB) $(UTILIB) $(RMONLIB) $(COMMLISTSLIB) $(LCKLIB) $(LIBS) 

test_enumeration.o: $(CULLLIB_DIR)/test_enumeration.c
	$(CC) $(CFLAGS) -c $(CULLLIB_DIR)/test_enumeration.c

