 /*----------------------------------------------------
 * Makefile.proto - Tom Green   Sun Dec 05 10:54:13 1993
 *
 * Copyright 1993
 *
 * SUPER COMPUTER COMPUTATIONS RESEARCH INSTITUTE
 *            FLORIDA STATE UNIVERSITY
 *
 *
 * SCRI representatives make no claims about the
 * suitability of this software for any purpose.
 * It is provided "as is" without express or
 * implied warranty.
 * static char Makefile.proto_rcsid[]="Makefile.proto,v 3.18 1994/06/19 14:31:44 green Exp";
 *
 * $Log: Makefile.proto,v $
 * Revision 1.5  1998/11/03 15:43:03  green
 * removed the "CC=gcc" line as some makes apparently don't like to overide
 * at the command line...
 *
 * Revision 1.4  1998/10/21 18:51:59  green
 * line breaking with a '\' seems to make some compilers puke
 *
 * Revision 1.3  1998/10/13 15:08:47  green
 * Solaris 2.6 support - hopefully, as I don't have access to one...
 *
 * Revision 1.2  1998/09/18 13:52:15  green
 * *** empty log message ***
 *
 * Revision 1.1.1.1  1998/08/18 14:39:09  green
 * DQS 3.2.0.5 WIP Import
 *
 * Revision 1.9  1998/02/03 19:49:27  decker
 * Added note to log, concerning queue in alarm mode
 * Few minor changes for new revision 3.2 s
 *
 * Revision 1.4  1997/09/08 19:57:28  decker
 * Patch from Ron Lee, concerning qidle and HPUX
 *
 * Revision 1.3  1997/04/11 14:04:54  green
 * cleaning up
 *
 * Revision 1.2  1997/04/10 21:54:11  green
 * added removal of auto generated config.* and Makefile.* to "make clean"
 *
 * Revision 1.1.1.1  1997/04/10 15:10:30  green
 * DQS 3.1.3.4.1 Distribution
 *
 * Revision 3.19  1997/03/25 16:47:53  nrl
 * Stripped garbage from Makefile.proto.in
 *
 * Revision 3.18  1997/03/19 10:43:07  nrl
 * Reised configure script and makefile.proto.in from Ron Lee to
 * solve the Xwindows include and library problems
 *
# Revision 3.17  1996/08/03  14:08:49  nrl
# fixed problem in qconf -mq where several fields were not getting
# updated
#
# Revision 3.16  1996/07/19  17:05:54  nrl
# Added "-L" for XLIBPATH
#
# Revision 3.15  1996/07/18  15:02:29  nrl
# Added -DSOLRAIS24 to the sparc_solaris_2.5 stanza.. This
# needs to be replaced with a better fix later
#
# Revision 3.14  1996/07/15  12:56:15  nrl
# Added more GNU configure parameters to solve the
# "cannot contact qmaster" problem with some versions of
# the gcc compiler.
#
# Revision 3.13  1996/07/14  14:59:27  nrl
# Added DEFINES and INCLUDES to GNU configure output
#
# Revision 3.12  1996/07/11  17:30:29  nrl
# changed X defaults to accept GNU configure updates
#
# Revision 3.11  1996/07/11  12:10:22  nrl
# Replaced default XLIB parameter
#
# Revision 3.10  1996/07/09  22:05:49  nrl
# Added include path for openwin on SOLARIS platforms
#
# Revision 3.9  1996/07/09  19:49:23  nrl
# Added SOLARIS2.4 defines
#
# Revision 3.8  1996/07/09  17:20:24  nrl
# added XLIBPATH definition for SOLARIS courtesy of
# Maker Beall
#
# Revision 3.7  1996/07/09  16:59:44  nrl
# Solaris fix.. removed -Xs compile option as per Mark Beall
#
# Revision 3.6  1996/06/26  14:03:12  nrl
# Added pvmcleanup.sh to install.. added osf2.3 detection
#
# Revision 3.5  1996/06/26  01:18:49  nrl
# Moved pvmcleanup to ARCS
#
# Revision 3.4  1996/06/26  00:50:05  nrl
# added pvmcleanup.sh to the make process
#
# Revision 3.3  1996/06/23  22:16:12  nrl
# Updated INSTALL to try and catch errors
#
# Revision 3.2  1996/06/23  19:40:58  nrl
# added missing templates for dqs_write_consumable_list,
# added message types to log entries
# setup GNU base for makefile.proto.in
#
# Revision 3.1  1996/06/23  19:07:25  nrl
# added GNU config based makefile.proto source
#
# Revision 3.48  1996/06/17  02:28:27  nrl
# Updtaes from Guntram Wolski, Ron Lee, John Makosky and
# Bodo Beckebach
#
# Revision 3.47  1996/03/31  19:04:26  nrl
# updated to ensure passing configure parameters to
# other makefiles
#
# Revision 3.46  1996/03/31  02:11:11  nrl
# updated dqs_c_qidle.c in make
#
# Revision 3.45  1996/03/30  21:32:31  nrl
# Cleanup prior to tagging to 3.1.3
#
# Revision 3.44  1996/03/25  17:42:19  nrl
# Changed permissions for qrls, qhold, dqs_execd
#
# Revision 3.43  1996/03/22  21:45:00  nrl
# updates new utilities
#
# Revision 3.42  1996/03/21  20:45:20  nrl
# adding new utilities and moved qidle to mainline code
#
# Revision 3.41  1996/03/14  03:15:49  nrl
# merge in subordinate queues and consumable resource changes
#
# Revision 3.40  1996/02/19  19:01:49  nrl
# added a separate subpriority field, pluys scheduling_flags and
# job_seq_number to remove the 3.1.2.4 kludges , modified the
# scheduling algorith once again
#
# Revision 3.39  1996/02/07  13:07:29  nrl
# Added "process leader" and TMP_FILES link capability
#
# Revision 3.35  1995/06/26  12:03:45  nrl
# Replaced -lsun which was accidently left out of lflags for Irix 5
#
# Revision 3.34  1995/06/26  11:20:59  nrl
# Added load flags -mpis2 for IRIX64
#
# Revision 3.33  1995/06/23  12:54:50  nrl
# Updated for IRIX6.4
#
# Revision 3.32  1995/06/22  19:31:04  nrl
# Added kludgie "subpriority" field to differentiate jobs from the
# same user. Also fixed MAXUJOBS and added "MAXU" warning to
# the "qstat" command.
#
# Revision 3.31  1995/06/15  11:39:34  nrl
# Changed accounting info for Solaris and AIX.
#
# Revision 3.30  1995/05/29  18:08:43  nrl
# More solaris stuff GAGGHH had to differentiate more cases of
# solaris2.3 and solaris2.4 stuff
#
# Revision 3.29  1995/05/28  16:44:34  nrl
# Fixes for solaris2.3 and solaris 2.4 and mailer default recipients
#
# Revision 3.28  1995/05/26  19:07:22  nrl
# Cleaned up signal handling and the notify option with the
# help of Ron Lee.
#
# Revision 3.27  1995/05/14  18:28:44  nrl
# Plugged one hole in dqs_execd and qmaster handhsaking...
# added gethostbyname calls to overcome problems with some
# systems
#
# Revision 3.26  1995/03/14  13:13:11  nrl
# Forced defines for sun and SV4 for SOLARIS 2.3 to make sure
# get load average compiles correclty
#
# Revision 3.25  1995/02/20  00:55:02  nrl
# Added makedepend entries for dsq_start_PVM and dqs_start_TCGMSG
#
# Revision 3.24  1995/02/17  02:56:48  nrl
# Added formal skeletons for PVM and TCGMSG parallel modes
#
# Revision 3.23  1995/01/27  14:09:35  nrl
# Changed Supspend on completion to continue beyond an unsuspend operation
# so that jobs can be "stepped" thru the queues. Increased timout
# retries for connect to make the system more tolerant of network delyas.
#
# Revision 3.22  1994/11/14  14:23:57  green
# added Michael Gates Solaris patches: "The signal handling
# code in /usr/ucblib/libucb.a is quite broken. The dqs_execd did not ever
# get SIGCLD's from the jobs it started, and for some reason the qmaster
# could not recover queue's if it was restarted.
#
#         Since libucb.a provides wait3 and bcopy and such, what I did is
# change Makefile.proto in the CONFIG and SRC directories to ask for
# libc.a before libucb.a, so the signal handling routines for System V get
# linked. I had to put 2 spaces between -lc and /usr/ucblib/libucb.a
# because one of them gets stripped out."
#
# Revision 3.21  1994/07/29  22:04:47  green
# added Nathan Janette patch for NEXTSTEP
#
# Revision 3.20  1994/07/05  14:22:27  green
# added James MacKinnon's NeXT ports
#
# Revision 3.19  1994/06/23  20:32:22  green
# more Solaris fun
#
# Revision 3.18  1994/06/19  14:31:44  green
# introduced a bug in defining "RANLIB" whilest attempting to port
# to Sloaris that attacked SGI boxes - fixed
#
# Revision 3.17  1994/06/18  14:15:36  green
# make dqs_random use prognames.h like everybody else
#
# Revision 3.16  1994/06/16  20:21:51  green
# added dqs_random.c
#
# Revision 3.15  1994/06/15  19:16:36  green
# added dqs_start_generic.c
#
# nuked dqs_parse_exec_str.c
#
# Revision 3.14  1994/06/14  19:16:09  green
# added dqs_execd_rebuild_host_hash.c
#
# Revision 3.13  1994/06/12  02:32:39  green
# removed "dshd" and moved the functionality in the dqs_execd - this
# will allow for the dqs_execd to set queue/job resources and to
# reap/report rusage
#
# some really strange timing errors in the "dshd" connecting to the
# stderr port on "dsh" under Linux forced introduction of a sleep(1);
# this needs to be followed up on.
#
# dqs_dshd_service no longer needed
#
# allowed SIGCHLD to interrupt io_mask
#
# Revision 3.12  1994/06/09  14:25:02  green
# yanked PVM after further digging through the PVM code decided there
# might be potential problems(let somebody else worry with pvm if they
# want it...)
#
# pulled out some sloaris #defs - maybe one day SUN will ship me my
# compiler
#
# Revision 3.11  1994/06/06  23:29:30  green
# fixed bug in generating Makefile.h(actually not a bug - but AIX
# couldn't dijest it...)
#
# added dqs_parse_exec_str.c(and added in Makefile.proto)
#
# built a more "generic" conf_file and resolve_file
#
# updated dqs_execd.c and dqs_start_p4.c to utilize dqs_parse_exec_str()
#
# had DQS_DSHD_BIN and DQS_DSH_BIN misnamed in prognames.h
#
# Revision 3.10  1994/06/06  01:23:00  green
# added "dqs_dshd_service" to the DQS config
#
# add "-par pvm" - though we do NOT intend to support it
# (see dqs_start_pvm.c for a more thorough discussion)
#
# Revision 3.9  1994/06/04  17:38:28  green
# added support for dqs_start_p4()
#
# Revision 3.8  1994/06/02  18:49:29  green
# more portability headaches brought on by Sun Solaris
# now including "Makefile.h" which is generated by config.guess
# so we can stick in all sorts of #ifdefs in to handle Sloaris
#
# Revision 3.7  1994/06/02  13:44:24  green
# attempt to port to Sloaris...
# Work In Progress(WIPed)
#
# Revision 3.6  1994/05/31  00:52:40  green
# added dsh.c dshd.c to Makefile.proto
#
# added MAXNAMELEN and NCARGS to def.h
#
# type casting in dqs_reauth.c, dqs_sec.c, dqs_setup.c to hush gcc
# warnings
#
# added jmp_buf to globals.h, changed Revision number in globals.h
#
# added dsh and dshd tp prognames.h
#
# Revision 3.5  1994/05/28  15:43:06  green
# added dqs_c_dshd.c to Makefile.proto
#
# misc type casting to squalk cc warnings
#
# Revision 3.4  1994/05/28  01:37:04  green
# put qhold/qrls back
#
# Revision 3.3  1994/05/27  22:38:24  green
# yanked qhold and qrls temporarily - till i get mpi finished
#
# Revision 3.2  1994/04/20  23:25:52  green
# added qhold.c qrls.c
#
# Revision 3.1  1994/04/01  02:59:27  green
# added "qalter" support
#
# Revision 3.0  1994/03/07  04:12:58  green
# 3.0 freeze
#
# Revision 1.10  1994/03/02  18:41:30  green
# "make doc" now remakes ALL DQS docs, including the library mans/.ps'es
#
# Revision 1.9  1994/03/02  16:11:03  green
# moved all "installdoc" into their respective directories
#
# Revision 1.8  1994/03/01  19:23:34  green
# removed "test" from the default dependancy list in Makefile.proto.
#
# changed dqs_show_all_cofigurations() to dqs_show_all_configurations()
# in dqs_execd.c, qmaster.c and dqs_utility.c.
#
# fixed the broken comment exclusion feature in dqs_resolve.c.
#
# fixed bug in me.default_cell in dqs_setup.c where conf_file
# default_cell was not updating me.default_cell.
#
# getenv(DQS_CELL) mved out of dqs_getme() into dqs_setup()
# to allow dqs_getme() to be called on forks.
#
# remade func.h.
#
# pulled garbage out of test.c.
#
# added syntax instructions to resolve_file
#
# Revision 1.7  1994/02/24  01:41:19  green
# ranlib yanked for "__sgi"
#
# Revision 1.6  1994/02/24  01:09:59  green
# added default compile flags in Makefile.proto
#
# modified GETPGRP() and SETPGRP() in def.h for IRIX 5.1.1.1 support
#
# changed "st_mtime" to "st_m_time" in dqs_reauth.cand dqs_sec.c
# for IRIX 5.1.1.1 support
#
# Revision 1.5  1994/02/23  15:48:19  green
# Added "prognames.h" which defines the installed binary names.
#
# Modified "Makefile.proto" accordingly.
#
# Revision 1.4  1994/02/23  04:57:38  green
# yanked "random.c" out of Makefile.proto
#
# Revision 1.3  1994/02/23  03:25:03  green
# Cleaned up Makefile to allow all arc makes from head directory.
#
# "doc" will be moved to "dqs_doc"
#
# "dqs_doc.tex" not really needed in distribution as it is auto-generated.
#
# Revision 1.2  1994/02/09  20:38:16  green
# removed "installl" - should now use "installbin"
#
# temporarily nuked "installman" "installdoc" options
#
# Revision 1.1.1.1  1994/02/01  17:57:36  green
# DQS 3.0 ALPHA
#
 *
 *
 *--------------------------------------------------*/
 
#include "../SRC/prognames.h"
#include "Makefile.h"

/**************************************************************************/

/* Set some defaults */
AFLAGS=rv
RANLIB=ranlib
DEFINES= 
LIBS=
INCLUDES= 
FC=f77
CFLAGS= -g 
LFLAGS=
AFS=
AFSSRC=

#ifdef AFSSYS
AFS= /usr/afsws/lib/afs/util.a -I/usr/afsws/include -ldes -llwp -lrxkad \
-lubik -lrx -L/usr/afsws/lib \
-lauth -laudit -lcom_err -lkauth -lprot -lsys -L/usr/afsws/lib/afs
AFSSRC= klogvalidation.c      
#endif      

#ifdef _AIX

CFLAGS= -g
LFLAGS=
#ifndef XNO
XLIB=-lXt -lX11
#endif
#endif

#ifdef alpha_dec_osf3_2
#define __os2__
#endif

#ifdef SVR3

CFLAGS=-g
LFLAGS=-lmld
AFLAGS=cuvs
RANLIB=file
#endif

#ifdef __sgi

CFLAGS=-g
/* If you do not want NIS support compiled into DQS under IRIX, remove*/
/* -lsun from the LFLAGS. */

LFLAGS=-lmld -lsun

#ifdef mips_sgi_irix64_6_0_1
CFLAGS= -g -mips2
LFLAGS= -mips2
#endif
AFLAGS=cuvs
#undef RANLIB
RANLIB=file
#endif

#ifdef sparc_sun_sunos4_1_1
#define sun
#endif

#ifdef sparc_sun_solaris2_3

CFLAGS=-g  -DSVR4 -DSOLARIS23
RANLIB=file
LFLAGS=-lc -lelf -lsocket -lnsl  -lthread -lkvm   /usr/ucblib/libucb.a
#define solaris
#define SVR4
#else 
/* SunOS */
#ifdef sun

CFLAGS=-g
LFLAGS=
RANLIB=ranlib
INCLUDES= -I/usr/openwin/include -I/usr/local/include
#endif
#endif

#ifdef sparc_sun_solaris2_4

CFLAGS=-g  -DSOLARIS24
RANLIB=file
LFLAGS=-lelf -lsocket -lnsl  -lthread -lkvm
INCLUDES= -I/usr/openwin/include -I/usr/local/include
#define solaris
#endif

#if (defined(sparc_sun_solaris2_5) || defined(sparc_sun_solaris2_5_1) || defined(sparc_sun_solaris2_5_2) || defined(sparc_sun_solaris2_5_3) || defined(sparc_sun_solaris2_5_4) || defined(sparc_sun_solaris2_5_5))

CFLAGS=-g  -DSOLARIS25 -DSOLARIS24
RANLIB=file
LFLAGS=-lelf -lsocket -lnsl  -lthread -lkvm
INCLUDES= -I/usr/openwin/include -I/usr/local/include
#define solaris
#endif


#if (defined(sparc_sun_solaris2_6) || defined(sparc_sun_solaris2_6_1) || defined(sparc_sun_solaris2_6_2) || defined(sparc_sun_solaris2_6_3) || defined(sparc_sun_solaris2_6_4) || defined(sparc_sun_solaris2_6_5))

CFLAGS=-g  -DSOLARIS26 -DSOLARIS25 -DSOLARIS24
RANLIB=file
LFLAGS=-lelf -lsocket -lnsl  -lthread -lkvm
INCLUDES= -I/usr/openwin/include -I/usr/local/include
#define solaris
#endif


#ifdef ultrix
#ifndef vax

CFLAGS=-g
LFLAGS=
#endif
#endif

#ifdef ultrix
#ifdef vax

CFLAGS=-g
LFLAGS=
#endif
#endif

#ifdef _UNICOS
CFLAGS=-g -I/usr/local/include
LFLAGS=-L/usr/local/lib -lalloca

AFLAGS=cuv
RANLIB=file
#endif

/*Fix*/
#ifdef __hpux
#ifdef hpux10.20
CFLAGS=-g -Dhpux10
#else
CFLAGS=-Dhpux
#endif
LFLAGS=
XCFLAGS= -I/usr/X11R6/include
#endif

#ifdef NeXT

CFLAGS = -posix
LFLAGS = -posix
#endif

#ifdef SPEW

#endif

/**************************************************************************/
/* shouldn't need to change anything below here */

SHELL=/bin/sh
SDIR=../SRC
INSTALL=	../UTIL/install
CB=		../UTIL/cb

/***************************************************************************/

HDRS=$(SDIR)/h.h  $(SDIR)/def.h $(SDIR)/dqs.h $(SDIR)/func.h \
	$(SDIR)/globals.h $(SDIR)/dqs_errno.h 

LSRC=	dqs_getloadavg.c dqs_ddes.c dqs_setup.c dqs_wildmat.c dqs_c_qmod.c	\
	dqs_select_queue.c dqs_free.c dqs_c_qdel.c dqs_start_p4.c 		\
	dqs_log.c dqs_schedule.c dqs_add_del.c dqs_dshd.c			\
	dqs_pack.c dqs_unpack.c	dqs_load_avg.c dqs_c_dqs_execd.c		\
	dqs_parse.c dqs_io.c dqs_list.c dqs_utility.c dqs_resolve.c 		\
	dqs_sec.c dqs_hash.c dqs_daemonize.c  dqs_mail.c dqs_ck_to_do_list.c	\
	dqs_parse_qconf.c dqs_replicate.c dqs_sig_handlers.c 			\
	dqs_c_qconf.c dqs_queue.c dqs_shutdown.c dqs_c_qmaster.c		\
	dqs_c_qsub.c dqs_tmpdir.c dqs_exec_job.c dqs_setenv.c dqs_reauth.c	\
	dqs_show.c dqs_job_exit.c dqs_send_receive.c dqs_c_qstat.c		\
	dqs_tid.c dqs_c_qalter.c dqs_start_generic.c				\
	dqs_execd_rebuild_host_hash.c dqs_start_PVM.c dqs_start_TCGMSG.c  \
	dqs_c_qmove.c dqs_c_qhold.c dqs_c_qrls.c dqs_c_qidle.c usleep.c


MSRC=	dqs_execd.c dsh.c qconf.c test.c dqs_doc.c dqs_options.c		\
	qsub.c qdel.c qmaster.c qstat.c qrls.c qhold.c qmove.c qalter.c

LOBJS=$(LSRC:.c=.o) $(AFSSRC:.c=.o)

MOBJS=$(MSRC:.c=.o)



.c.o		: 
		$(CC) -c $(CFLAGS) $(DEFINES) $(INCLUDES)  $< 

all		: dqs.a dqs_execd dqs_options qalter qconf qdel 		\
		qmaster qmod qstat qsub dsh dqs_random qhold qrls qmove 

dqs		: all

ALL		: all ckpt doc
 
/* my machine does not have fortran - RMB
ckpt		: dqs_ckpt.a dqs_check_pt fdqs_check_pt
*/

ckpt		: dqs_ckpt.a dqs_check_pt

$(LOBJS)	: $(HDRS) 

$(MOBJS)	: $(HDRS) 

dqs.a		: $(LOBJS)
		rm -f dqs.a
		ar $(AFLAGS) dqs.a $(LOBJS)
		$(RANLIB) dqs.a

dqs_ckpt.a	: dqs_ckpt.o
		rm -f dqs_ckpt.a 
		ar rv dqs_ckpt.a dqs_ckpt.o dqs_ckpt.o
		$(RANLIB) dqs_ckpt.a

dqs_check_pt	: dqs_check_pt.o
		$(CC) $(CFLAGS) -o dqs_check_pt dqs_check_pt.o dqs_ckpt.a $(LFLAGS)

dqs_execd	: dqs_execd.o dqs.a
		$(CC) -o dqs_execd dqs_execd.o dqs.a $(LFLAGS) $(SYSLIBS) $(AFS)

dqs_options	: dqs_options.o dqs.a
		$(CC) -o dqs_options dqs_options.o dqs.a $(LFLAGS) $(SYSLIBS)

dsh		: dsh.o dqs.a
		$(CC) -o dsh dsh.o dqs.a $(LFLAGS) $(SYSLIBS)

dqs_random	: dqs_random.o dqs.a
		$(CC) -o dqs_random dqs_random.o dqs.a $(LFLAGS) $(SYSLIBS)

proto		: proto.o
		$(CC) -o ../SRC/proto proto.o $(LFLAGS)

prototype	: proto
		(cd ../SRC; rm -f func.h;cat $(LSRC) | ./proto > func.h)

pt		: proto
		(cd ../SRC; rm -f func.h;cat $(LSRC) | ./proto >func.h)
		(cd ../SRC; rm -f func.h;cat $(LSRC) | ./proto -short > funcs.h)

qacct		: qacct.o dqs.a
		$(CC) -o qacct qacct.o dqs.a $(LFLAGS) $(SYSLIBS)

qalter		: qalter.o dqs.a
		$(CC) -o qalter qalter.o dqs.a $(LFLAGS) $(SYSLIBS) $(AFS)

qconf		: qconf.o dqs.a
		$(CC) -o qconf qconf.o dqs.a $(LFLAGS) $(SYSLIBS)

qdel		: qdel.o dqs.a
		$(CC) -o qdel qdel.o dqs.a $(LFLAGS) $(SYSLIBS)

qhold		: qhold.o dqs.a
		$(CC) -o qhold qhold.o dqs.a $(LFLAGS) $(SYSLIBS)


qmaster		: qmaster.o dqs.a
		$(CC) -o qmaster qmaster.o dqs.a $(LFLAGS) $(SYSLIBS) $(AFS)

qmod		: qmod.o dqs.a
		$(CC) -o qmod qmod.o dqs.a $(LFLAGS) $(SYSLIBS)

qmon		: qmon.o dqs.a
		$(CC) -o qmon qmon.o dqs.a $(LFLAGS) $(SYSLIBS)

qmove		: qmove.o dqs.a
		$(CC) -o qmove qmove.o dqs.a $(LFLAGS) $(SYSLIBS)

qmsg		: qmsg.o dqs.a
		$(CC) -o qmsg qmsg.o dqs.a $(LFLAGS) $(SYSLIBS)

qrerun		: qrerun.o dqs.a
		$(CC) -o qrerun qrerun.o dqs.a $(LFLAGS) $(SYSLIBS)

qrls		: qrls.o dqs.a
		$(CC) -o qrls qrls.o dqs.a $(LFLAGS) $(SYSLIBS)

qselect		: qselect.o dqs.a
		$(CC) -o qselect qselect.o dqs.a $(LFLAGS) $(SYSLIBS)

qsh		: qsh.o dqs.a
		$(CC) -o qsh qsh.o dqs.a $(LFLAGS) $(SYSLIBS)

qsig		: qsig.o dqs.a
		$(CC) -o qsig qsig.o dqs.a $(LFLAGS) $(SYSLIBS)

qstat		: qstat.o dqs.a
		$(CC) -o qstat qstat.o dqs.a $(LFLAGS) $(SYSLIBS)

qsub		: qsub.o dqs.a
		$(CC) -o qsub qsub.o dqs.a $(LFLAGS) $(SYSLIBS) $(AFS)

qusage		: qusage.o dqs.a
		$(CC) -o qusage qusage.o dqs.a $(LFLAGS) $(SYSLIBS)

/*********************************************************************************/

clean:
		-rm -f *.o *.a *.tar *~ core a.out .em* rmme RMME
		-rm -f qacct qalter qconf qdel qhold qmod qmon
		-rm -f qmove qmsg qrerun qrls qselect qsh qsig qstat
		-rm -f qsub qusage dqs_options dqs_execd qmaster
		-rm -f *.tmp defined OUT ERR dsh Makefile.h
		-rm -f config.status config.cache
		-rm -f qusage Makefile.c Makefile.typ dqs_random
		-rm -f dqs_doc *.dvi *.toc *.log *.aux dqs_doc.tex
		-rm -f .nfs* .NFS* proto qacct .bind* bind.*
		-rm -f typescript *.bind *.BIND *[0-9] fdqs_check_pt dqs_check_pt
		-rm -f $(OBJS) dqs_ckpt fdqs_ckpt dqs_ckpt.a DQS.CKPT DQS.OUT

clobber:	clean
		-rm -f $(BIN_DIR)/QACCT_BIN     $(BIN_DIR)/QALTER_BIN
		-rm -f $(BIN_DIR)/QCONF_BIN     $(BIN_DIR)/QDEL_BIN
		-rm -f $(BIN_DIR)/QHOLD_BIN     
		-rm -f $(BIN_DIR)/QMOD_BIN      $(BIN_DIR)/QMON_BIN
		-rm -f $(BIN_DIR)/QMOVE_BIN     $(BIN_DIR)/QMSG_BIN
		-rm -f $(BIN_DIR)/QRERUN_BIN    $(BIN_DIR)/QRLS_BIN
		-rm -f $(BIN_DIR)/QSELECT_BIN   $(BIN_DIR)/QSH_BIN
		-rm -f $(BIN_DIR)/QSIG_BIN      $(BIN_DIR)/QSTAT_BIN
		-rm -f $(BIN_DIR)/QSUB_BIN      $(BIN_DIR)/QUSAGE_BIN
		-rm -f $(BIN_DIR)/DQS_EXECD_BIN $(BIN_DIR)/DQS_OPTIONS_BIN
		-rm -f $(BIN_DIR)/QMASTER_BIN   $(BIN_DIR)/DSH_BIN
		-rm -f $(BIN_DIR)/PVM_CLEAN 

installbin::    $(BIN_DIR)/QMASTER_BIN $(BIN_DIR)/QSUB_BIN $(BIN_DIR)/QSTAT_BIN

installbin::	$(BIN_DIR)/DQS_EXECD_BIN $(BIN_DIR)/QDEL_BIN $(BIN_DIR)/QCONF_BIN

installbin::	$(BIN_DIR)/QMOD_BIN $(BIN_DIR)/DQS_OPTIONS_BIN $(BIN_DIR)/QALTER_BIN

installbin::	$(BIN_DIR)/DSH_BIN $(BIN_DIR)/DQS_RANDOM_BIN

installbin::    $(BIN_DIR)/QHOLD_BIN $(BIN_DIR)/QRLS_BIN $(BIN_DIR)/QMOVE_BIN $(BIN_DIR)/PVM_CLEAN

installlib::	$(LIB_DIR)/dqs_ckpt.a

wc :		
		wc -l $(LSRC) $(MSRC) $(HDRS) Makefile Makefile.proto

$(BIN_DIR)/QACCT_BIN:		qacct
	$(INSTALL) -o $(DQS_ROOT) -g $(DQS_SYSGRP) -m 755 qacct $(BIN_DIR)/QACCT_BIN

$(BIN_DIR)/QALTER_BIN:		qalter
	$(INSTALL) -o $(DQS_ROOT) -g $(DQS_SYSGRP) -m 4755 qalter $(BIN_DIR)/QALTER_BIN

$(BIN_DIR)/QMASTER_BIN:	qmaster
	$(INSTALL) -o $(DQS_ROOT) -g $(DQS_SYSGRP) -m 0700 qmaster $(BIN_DIR)/QMASTER_BIN
	
$(BIN_DIR)/QHOLD_BIN: qhold
	$(INSTALL) -o $(DQS_ROOT) -g $(DQS_SYSGRP) -m 4755 qhold $(BIN_DIR)/QHOLD_BIN

$(BIN_DIR)/QRLS_BIN: qrls
	$(INSTALL) -o $(DQS_ROOT) -g $(DQS_SYSGRP) -m 4755 qrls $(BIN_DIR)/QRLS_BIN

$(BIN_DIR)/QSUB_BIN:		qsub
	$(INSTALL) -o $(DQS_ROOT) -g $(DQS_SYSGRP) -m 4755 qsub $(BIN_DIR)/QSUB_BIN

$(BIN_DIR)/QSTAT_BIN:		qstat
	$(INSTALL) -o $(DQS_ROOT) -g $(DQS_SYSGRP) -m 4755 qstat $(BIN_DIR)/QSTAT_BIN

$(BIN_DIR)/QCONF_BIN:		qconf
	$(INSTALL) -o $(DQS_ROOT) -g $(DQS_SYSGRP) -m 4755 qconf $(BIN_DIR)/QCONF_BIN

$(BIN_DIR)/DQS_EXECD_BIN:	dqs_execd
	$(INSTALL) -o $(DQS_ROOT) -g $(DQS_SYSGRP) -m 0755 dqs_execd $(BIN_DIR)/DQS_EXECD_BIN

$(BIN_DIR)/PVM_CLEAN:	../UTIL/pvmcleanup.sh
	cp ../UTIL/pvmcleanup.sh .
	$(INSTALL) -o $(DQS_ROOT) -g $(DQS_SYSGRP) -m 0755 pvmcleanup.sh $(BIN_DIR)/PVM_CLEAN

$(BIN_DIR)/DSH_BIN:		dsh
	$(INSTALL) -o $(DQS_ROOT) -g $(DQS_SYSGRP) -m 4755 dsh $(BIN_DIR)/DSH_BIN

$(BIN_DIR)/QMOD_BIN:		qmod
	$(INSTALL) -o $(DQS_ROOT) -g $(DQS_SYSGRP) -m 4755 qmod $(BIN_DIR)/QMOD_BIN

$(BIN_DIR)/QDEL_BIN:		qdel
	$(INSTALL) -o $(DQS_ROOT) -g $(DQS_SYSGRP) -m 4755 qdel $(BIN_DIR)/QDEL_BIN

$(BIN_DIR)/QMOVE_BIN:		qmove
	$(INSTALL) -o $(DQS_ROOT) -g $(DQS_SYSGRP) -m 4755 qmove $(BIN_DIR)/QMOVE_BIN

$(BIN_DIR)/DQS_OPTIONS_BIN:	dqs_options
	$(INSTALL) -o $(DQS_ROOT) -g $(DQS_SYSGRP) -m 4755 dqs_options $(BIN_DIR)/DQS_OPTIONS_BIN

$(BIN_DIR)/DQS_RANDOM_BIN:	dqs_random
	$(INSTALL) -o $(DQS_ROOT) -g $(DQS_SYSGRP) -m 0755 dqs_random $(BIN_DIR)/DQS_RANDOM_BIN

$(LIB_DIR)/dqs_ckpt.a: dqs_ckpt.a
	$(INSTALL) -o $(ROOT) -g $(SYSGRP) -m 644 dqs_ckpt.a $(LIB_DIR)/dqs_ckpt.a

/*************************************************************************/

c_sub_int.o	: $(SDIR)/c_sub_int.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/c_sub_int.c

dqs_sig_handlers.o	: $(SDIR)/dqs_sig_handlers.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_sig_handlers.c

proto.o		: $(SDIR)/proto.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/proto.c

qmaster.o	: $(SDIR)/qmaster.c 
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/qmaster.c

qconf.o		: $(SDIR)/qconf.c 
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/qconf.c

dqs_options.o	: $(SDIR)/dqs_options.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_options.c

qsub.o		: $(SDIR)/qsub.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/qsub.c

dqs_execd.o	: $(SDIR)/dqs_execd.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_execd.c

dsh.o		: $(SDIR)/dsh.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dsh.c

dqs_random.o	: $(SDIR)/dqs_random.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_random.c

qdel.o		: $(SDIR)/qdel.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/qdel.c

qhold.o		: $(SDIR)/qhold.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/qhold.c

usleep.o	: $(SDIR)/usleep.c
		$(CC) $(CFLAGS) $(XCFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/usleep.c

qmove.o		: $(SDIR)/qmove.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/qmove.c

qrls.o		: $(SDIR)/qrls.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/qrls.c

qmod.o		: $(SDIR)/qmod.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/qmod.c

qalter.o	: $(SDIR)/qalter.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/qalter.c

qstat.o		: $(SDIR)/qstat.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/qstat.c

dqs_parse.o	: $(SDIR)/dqs_parse.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_parse.c

dqs_parse_qconf.o	: $(SDIR)/dqs_parse_qconf.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_parse_qconf.c

dqs_daemonize.o	: $(SDIR)/dqs_daemonize.c $(SDIR)/$(HDRS)
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_daemonize.c

dqs_setup.o	: $(SDIR)/dqs_setup.c $(SDIR)/$(HDRS)
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_setup.c

dqs_log.o	: $(SDIR)/dqs_log.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_log.c

dqs_io.o	: $(SDIR)/dqs_io.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_io.c

dqs_queue.o		: $(SDIR)/dqs_queue.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_queue.c

dqs_job_exit.o	: $(SDIR)/dqs_job_exit.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_job_exit.c

dqs_list.o	: $(SDIR)/dqs_list.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_list.c

dqs_pack.o	: $(SDIR)/dqs_pack.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_pack.c

dqs_dshd.o	: $(SDIR)/dqs_dshd.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_dshd.c

dqs_unpack.o	: $(SDIR)/dqs_unpack.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_unpack.c

dqs_shutdown.o		: $(SDIR)/dqs_shutdown.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_shutdown.c

dqs_add_del.o	: $(SDIR)/dqs_add_del.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_add_del.c

dqs_utility.o	: $(SDIR)/dqs_utility.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_utility.c

dqs_c_qalter.o	: $(SDIR)/dqs_c_qalter.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_c_qalter.c

dqs_c_qhold.o	: $(SDIR)/dqs_c_qhold.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_c_qhold.c

dqs_c_qconf.o		: $(SDIR)/dqs_c_qconf.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_c_qconf.c

dqs_c_qidle.o		: $(SDIR)/dqs_c_qidle.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_c_qidle.c

dqs_c_qmove.o		: $(SDIR)/dqs_c_qmove.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_c_qmove.c

dqs_c_qrls.o	: $(SDIR)/dqs_c_qrls.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_c_qrls.c

dqs_c_qsub.o	: $(SDIR)/dqs_c_qsub.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_c_qsub.c

dqs_select_queue.o	: $(SDIR)/dqs_select_queue.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_select_queue.c

dqs_sec.o	: $(SDIR)/dqs_sec.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_sec.c

dqs_exec_job.o	: $(SDIR)/dqs_exec_job.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(AFS) $(DEBUG) -c $(SDIR)/dqs_exec_job.c

dqs_mail.o		: $(SDIR)/dqs_mail.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_mail.c

dqs_setenv.o	: $(SDIR)/dqs_setenv.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_setenv.c

dqs_tid.o	:	$(SDIR)/dqs_tid.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_tid.c

dqs_wildmat.o	: $(SDIR)/dqs_wildmat.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_wildmat.c

dqs_c_qstat.o	: $(SDIR)/dqs_c_qstat.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_c_qstat.c

dqs_show.o	: $(SDIR)/dqs_show.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_show.c

dqs_send_receive.o		: $(SDIR)/dqs_send_receive.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_send_receive.c

dqs_getloadavg.o	: $(SDIR)/dqs_getloadavg.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_getloadavg.c

dqs_c_qmod.o	: $(SDIR)/dqs_c_qmod.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_c_qmod.c

dqs_doc.o	: $(SDIR)/dqs_doc.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_doc.c

dqs_free.o	: $(SDIR)/dqs_free.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_free.c

dqs_c_qdel.o	: $(SDIR)/dqs_c_qdel.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_c_qdel.c

dqs_resolve.o	: $(SDIR)/dqs_resolve.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_resolve.c

dqs_ck_to_do_list.o	: $(SDIR)/dqs_ck_to_do_list.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_ck_to_do_list.c

dqs_reauth.o	: $(SDIR)/dqs_reauth.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_reauth.c

dqs_schedule.o	: $(SDIR)/dqs_schedule.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_schedule.c

dqs_c_dqs_execd.o		: $(SDIR)/dqs_c_dqs_execd.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_c_dqs_execd.c

dqs_replicate.o	: $(SDIR)/dqs_replicate.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_replicate.c

dqs_load_avg.o	: $(SDIR)/dqs_load_avg.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_load_avg.c

dqs_hash.o	: $(SDIR)/dqs_hash.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_hash.c

dqs_tmpdir.o	: $(SDIR)/dqs_tmpdir.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_tmpdir.c

dqs_c_qmaster.o	: $(SDIR)/dqs_c_qmaster.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_c_qmaster.c

dqs_ddes.o	: $(SDIR)/dqs_ddes.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_ddes.c

dqs_start_p4.o	: $(SDIR)/dqs_start_p4.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_start_p4.c

dqs_start_PVM.o	: $(SDIR)/dqs_start_PVM.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_start_PVM.c

dqs_start_TCGMSG.o	: $(SDIR)/dqs_start_TCGMSG.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_start_TCGMSG.c

dqs_start_generic.o	: $(SDIR)/dqs_start_generic.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_start_generic.c

dqs_execd_rebuild_host_hash.o	: $(SDIR)/dqs_execd_rebuild_host_hash.c
		$(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(DEBUG) -c $(SDIR)/dqs_execd_rebuild_host_hash.c

dqs_ckpt.o:	$(SDIR)/dqs_ckpt.c
		$(CC) $(CFLAGS) -c $(SDIR)/dqs_ckpt.c

dqs_check_pt.o	: $(SDIR)/dqs_check_pt.c
		$(CC) $(CFLAGS) -c $(SDIR)/dqs_check_pt.c

fdqs_check_pt.o	: $(SDIR)/fdqs_check_pt.f
		$(FC) -c $(SDIR)/fdqs_check_pt.f

#ifdef AFSSYS
klogvalidation.o: $(SDIR)/klogvalidation.c
                $(CC) $(CFLAGS)  $(DEFINES) $(INCLUDES)  $(AFS) $(DEBUG) -c $(SDIR)/klogvalidation.c
#endif

