#
# $Id: Makefile.in,v 2.0 1998/10/14 22:55:25 hender Exp $
#
#
#       Makefile for the PBS GUI
#
# 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@
INSTALL = @INSTALL@

@mk_head@
@mk_dirs@
@mk_tcl@

XPBS_LIB = $(libdir)/xpbs
XPBS_SCRIPTS = $(PBS_SRC)/gui

TARGETS = xpbs xpbsrc buildindex

all: build

build: $(TARGETS) ccode


#
# need to fix the problem of where the libraries are. This is because
# they are in a different place after installation, yet we want to be able to
# run before installation.
#
xpbs: $(srcdir)/xpbs.src
	@echo Processing xpbs
	@sed -e 's,#\!.*wish.*$$,#\!${WISH_PATH} -f,;' \
            -e 's,set  *libdir.*$$,set libdir $(srcdir),' \
	    -e 's,set  *appdefdir.*$$,set appdefdir .,' \
            $? > $@
	@chmod +x $@

xpbsrc: $(srcdir)/xpbsrc.src
	@echo Processing xpbsrc
	@sed -e 's,\*serverHosts:.*$$,\*serverHosts: $(PBS_DEFAULT_SERVER),;' \
            -e ' s,\*selectHosts:.*$$,\*selectHosts: $(PBS_DEFAULT_SERVER),' \
             $? > $@

buildindex: $(srcdir)/buildindex.src
	@echo Processing buildindex
	@sed -e 's,#\!.*tclsh.*$$,#\!${TCLSH_PATH},' $? > $@
	@chmod +x $@
	@echo Running buildindex \(locally\)
	@./buildindex $(srcdir) .

ccode:
	@MAKE_POSIX_PLUS@@echo Making in Ccode for xpbs; cd Ccode; $(MAKE) all

install: build
	test -d $(XPBS_LIB) || $(INSTALL) -m 755 -d $(XPBS_LIB)
	test -d $(XPBS_LIB)/bitmaps || $(INSTALL) -m 755 -d $(XPBS_LIB)/bitmaps
	test -d $(XPBS_LIB)/help || $(INSTALL) -m 755 -d $(XPBS_LIB)/help
	#
	for f in $(srcdir)/bitmaps/*; do \
	    test -f $$f && $(INSTALL) -m 644 $$f $(XPBS_LIB)/bitmaps; \
	done
	#
	for f in $(srcdir)/help/*.hlp; do \
	    $(INSTALL) -m 644 $$f $(XPBS_LIB)/help; \
	done
	#
	@cd Ccode; $(MAKE) install
	#
	for f in $(srcdir)/*.tcl $(srcdir)/*.tk; do \
	    $(INSTALL) -m 644 $$f $(XPBS_LIB); \
	done
	#
	# install xpbs changing the location of libdir and appdefdir
	#
	@echo Install xpbs
	@sed -e 's,set  *libdir.*$$,set libdir ${XPBS_LIB},' \
	    -e 's,set  *appdefdir.*$$,set appdefdir ${XPBS_LIB},' \
	    xpbs > $(bindir)/xpbs
	@chmod 755 $(bindir)/xpbs 2> /dev/null
	#
	$(INSTALL) -m 755 buildindex $(XPBS_LIB)
	$(INSTALL) -m 644 xpbsrc $(XPBS_LIB)
	#
	cd $(XPBS_LIB) && ./buildindex $(XPBS_LIB) && chmod 644 tclIndex


distclean clean::
	-@(test -f Ccode/Makefile && cd Ccode && $(MAKE) $@; exit 0)

depend::

clean::
	$(RM) tclIndex; exit 0

@mk_cleanup@

