#
# $Id: Makefile.in,v 2.0 1998/10/14 23:22:45 hender Exp $
#
#
#       Makefile for the PBS tools
#
# This program is confidential and proprietary to MRJ Technology Solutions
# and may not be reproduced, published or disclosed to others without
# written authorization from MRJ.
# 
# Copyright (c) 1998 MRJ Technology Solutions, Inc. All Rights Reserved.
# 
# This program is derived from prior work some of which was originally
# written as a joint project between the Numerical Aerospace Simulation
# (NAS) Systems Division of NASA Ames Research Center and the National
# Energy Research Supercomputer Center (NERSC) of Lawrence Livermore
# National Laboratory.
#
# the first non-comment line must be .POSIX to assure POSIX make behavior
#
@MAKE_POSIX_TARGET@


srcdir = @srcdir@
top_srcdir = @top_srcdir@
MK_VPATH = @srcdir@:@srcdir@/../scheduler.tcl
INSTALL = @INSTALL@

@mk_head@
@mk_dirs@
@mk_tcl@

BUILD_INCS = -I@top_builddir@/src/include
INCS = $(BUILD_INCS) -I$(PBS_SRCINC) $(TCL_INCS)
CFLAGS = @CFLAGS@ $(INCS) @DEFS@


OBJS_COMMON = hostn.o chk_tree.o printjob.o tracejob.o
OBJS_TCLTK = pbs_tclWrap.o site_tclWrap.o
OBJS_TCL = pbsTclInit.o
OBJS_TK = pbsTkInit.o

OBJS_TCLSH = $(OBJS_TCLTK) $(OBJS_TCL)
OBJS_WISH = $(OBJS_TCLTK) $(OBJS_TK)


TOOLS_TARGETS = @TOOLS_TARGETS@
COMMON_TARGETS = chk_tree hostn printjob tracejob

OBJS = @TOOLS_OBJS@ $(OBJS_COMMON)
TARGETS = @TOOLS_TARGETS@ $(COMMON_TARGETS)

PBSLIBS = ../lib/Liblog/liblog.a ../lib/Libcmds/libcmds.a \
          ../lib/Libnet/libnet.a ../lib/Libpbs/libpbs.a

LIBRARIES = $(LDFLAGS) $(PBSLIBS) $(TCL_LIBS) $(LIBS)
NO_TCL_LIBS = $(LDFLAGS) $(PBSLIBS) $(LIBS)



all: autodepend
	@MAKE_POSIX_PLUS@@$(MAKE) build
	@MAKE_POSIX_PLUS@@if test -n "$(TK_VER)"; then { cd xpbsmon && $(MAKE) all;} ; fi

build: $(TARGETS)

install: build
	test -d $(bindir) || $(INSTALL) -m 755 -d $(bindir)
	for f in $(TARGETS); do \
		$(INSTALL) -m 755 $$f $(bindir); \
	done
	@MAKE_POSIX_PLUS@@if test -n "$(TK_VER)"; then { cd xpbsmon && $(MAKE) install;} ; fi

pbs_tclsh: $(OBJS_TCLSH)
	$(CC) $(CFLAGS) -o $@ $(OBJS_TCLSH) $(LIBRARIES)

pbs_wish: $(OBJS_WISH)
	$(CC) $(CFLAGS) -o $@ $(OBJS_WISH) $(LIBRARIES)

# clean up the C files that we created
distclean clean::
	@MAKE_POSIX_PLUS@@test -f xpbsmon/Makefile && cd xpbsmon && $(MAKE) $@; exit 0


DFLT_ACTION = $(CC) $(CFLAGS) $@.o -o $@ $(NO_TCL_LIBS)

chk_tree: chk_tree.o; $(DFLT_ACTION)
printjob: printjob.o; $(DFLT_ACTION)
hostn: hostn.o;       $(DFLT_ACTION)
tracejob: tracejob.o; $(DFLT_ACTION)

@mk_cleanup@
@mk_tail@

