#
# $Id: Makefile.in,v 2.0 1998/10/14 22:59:21 hender Exp $
#
# 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@

USERH = pbs_error.h pbs_ifl.h

HT= site_job_attr_def.h \
    site_job_attr_enum.h \
    site_qmgr_node_print.h \
    site_qmgr_que_print.h \
    site_qmgr_svr_print.h \
    site_que_attr_def.h \
    site_que_attr_enum.h \
    site_svr_attr_def.h \
    site_svr_attr_enum.h

TARGETS = $(HT)

all build: stamp site_h

#
# make sure that you never try to copy a file over itself
# since we are copying into the local directory, make sure that
# we do not try to copy if the srcdir is '.', this copes with all
# sorts of things including chains of symlinks that would otherwise
# trick it. Do this by following any links and then comparing inode
# numbers with that of the cwd
#
stamp: $(srcdir)/pbs_error.h $(srcdir)/pbs_ifl.h
	@srcinode=`(cd $(srcdir) && set \`ls -di .\` && echo $$1)` && \
	set `ls -di .` && destinode=$$1 && \
	if [ "$$srcinode" -ne "$$destinode" ]; then \
	    cp $? . && chmod a+r $(USERH) && touch stamp ;\
	    echo 'cp $? . && chmod a+r $(USERH) && touch stamp' ;\
	else \
	    touch stamp ; \
	    echo touch stamp ; \
	fi

#
# in there are a number of include files that the site administrator
# might want to modify. These need to be copied over to the include
# directory in the build tree if they do not already exist there. If they
# do exist then they need not be copied. Warn if the site*.ht file in
# the srcdir is newer than the matching file in the local dir.
#
site_h:
	@for f in $(HT); do \
	    if [ -f "$$f" ]; then \
	        find $(srcdir) -name "$$f"t -newer ./$$f -exec \
		echo Warning: $(srcdir)/"$$f"t newer than `/bin/pwd`/$$f \; ; \
	    else \
		cp $(srcdir)/"$$f"t ./$$f ; \
		echo cp $(srcdir)/"$$f"t ./$$f ; \
	    fi; \
	done


install:
	@$(INSTALL) -d -m 755 $(includedir) && \
	for f in $(USERH); do \
	    $(INSTALL) -m 444 $$f $(includedir); \
	done

clean::
	-($(RM) BATCH-types.h stamp; exit 0) > /dev/null 2>&1

distclean::
	-($(RM) pbs_config.h; exit 0) > /dev/null 2>&1

@mk_tail@
@mk_cleanup@
