#
# $Id: Makefile.in,v 2.0 1998/10/14 22:47:30 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@
INSTALL = @INSTALL@

@mk_head@
@mk_dirs@


# Makefile for External Reference Spec (ERS)
#
# Targets:
#	build:	Makes separate postscript docuements for each chapther.
#
#	all:	Makes a single postscript file for entire document.
#
#	install: installs man pages for sections 1, 3, 7, and 8.
#

DOCSRC  = $(srcdir)/..
DOCTRG  = .

SOELIM  = ../soelim
FONTS = $(srcdir)/../doc_fonts

ERS =	$(DOCSRC)/ers/title_ers.ms \
	$(DOCSRC)/ers/intro_ers.ms \
	$(DOCSRC)/ers/general_ers.ms \
	$(DOCSRC)/ers/server_ers.ms \
	$(DOCSRC)/ers/ifl_ers.ms \
	$(DOCSRC)/ers/usercmds_ers.ms \
	$(DOCSRC)/ers/opcmds_ers.ms \
	$(DOCSRC)/ers/scheduler_ers.ms \
	$(DOCSRC)/ers/resmom_ers.ms \
	$(DOCSRC)/ers/network_ers.ms \
	$(DOCSRC)/ers/tools_ers.ms \
	$(DOCSRC)/ers/taskmgr_ers.ms

APPENDIX = 

AUXERS =	$(DOCSRC)/ers/ers_setup.ms \
		$(DOCSRC)/ers/ers.macros 

AUXRESC =	$(DOCSRC)/ers/pbs_resources_all.so \
		$(DOCSRC)/man1/pbs_resources_aix4.7B \
		$(DOCSRC)/man1/pbs_resources_digitalunix.7B \
		$(DOCSRC)/man1/pbs_resources_freebsd.7B \
		$(DOCSRC)/man1/pbs_resources_fujitsu.7B \
		$(DOCSRC)/man1/pbs_resources_irix5.7B \
		$(DOCSRC)/man1/pbs_resources_irix6array.7B \
		$(DOCSRC)/man1/pbs_resources_irix6.7B \
		$(DOCSRC)/man1/pbs_resources_linux.7B \
		$(DOCSRC)/man1/pbs_resources_netbsd.7B \
		$(DOCSRC)/man1/pbs_resources_solaris5.7B \
		$(DOCSRC)/man1/pbs_resources_sp2.7B \
		$(DOCSRC)/man1/pbs_resources_sunos4.7B \
		$(DOCSRC)/man1/pbs_resources_unicos8.7B \
		$(DOCSRC)/man1/pbs_resources_unicosmk2.7B

MAN1 = $(DOCSRC)/man1/qalter.1B \
	$(DOCSRC)/man1/qdel.1B \
	$(DOCSRC)/man1/qhold.1B \
	$(DOCSRC)/man1/qmove.1B \
	$(DOCSRC)/man1/qmsg.1B \
	$(DOCSRC)/man1/qorder.1B \
	$(DOCSRC)/man1/qrerun.1B \
	$(DOCSRC)/man1/qrls.1B \
	$(DOCSRC)/man1/qselect.1B \
	$(DOCSRC)/man1/qsig.1B \
	$(DOCSRC)/man1/qstat.1B \
	$(DOCSRC)/man1/qsub.1B \
	$(DOCSRC)/man1/pbs.1B \
	$(DOCSRC)/man1/pbsdsh.1B \
	$(DOCSRC)/man1/nqs2pbs.1B \
	$(DOCSRC)/man1/basl2c.1B \
	$(DOCSRC)/man1/xpbs.1B \
	$(DOCSRC)/man1/xpbsmon.1B

MAN3 =	$(DOCSRC)/man3/pbs_alterjob.3B \
	$(DOCSRC)/man3/pbs_connect.3B \
	$(DOCSRC)/man3/pbs_deljob.3B \
	$(DOCSRC)/man3/pbs_default.3B \
	$(DOCSRC)/man3/pbs_disconnect.3B \
	$(DOCSRC)/man3/pbs_geterrmsg.3B \
	$(DOCSRC)/man3/pbs_holdjob.3B \
	$(DOCSRC)/man3/pbs_manager.3B \
	$(DOCSRC)/man3/pbs_movejob.3B \
	$(DOCSRC)/man3/pbs_msgjob.3B \
	$(DOCSRC)/man3/pbs_orderjob.3B \
	$(DOCSRC)/man3/pbs_rescreserve.3B \
	$(DOCSRC)/man3/pbs_rescquery.3B \
	$(DOCSRC)/man3/pbs_rerunjob.3B \
	$(DOCSRC)/man3/pbs_rlsjob.3B \
	$(DOCSRC)/man3/pbs_runjob.3B \
	$(DOCSRC)/man3/pbs_selectjob.3B \
	$(DOCSRC)/man3/pbs_sigjob.3B \
	$(DOCSRC)/man3/pbs_stagein.3B \
	$(DOCSRC)/man3/pbs_statjob.3B \
	$(DOCSRC)/man3/pbs_statque.3B \
	$(DOCSRC)/man3/pbs_statserver.3B \
	$(DOCSRC)/man3/pbs_submit.3B \
	$(DOCSRC)/man3/pbs_terminate.3B \
	$(DOCSRC)/man3/rpp.3 \
	$(DOCSRC)/man3/tm.3

MAN7 =	$(DOCSRC)/man1/pbs_job_attributes.7B \
	$(DOCSRC)/man1/pbs_queue_attributes.7B \
	$(DOCSRC)/man1/pbs_server_attributes.7B \
	${AUXRESC}

MAN8 =	$(DOCSRC)/man8/qdisable.8B \
	$(DOCSRC)/man8/qenable.8B \
	$(DOCSRC)/man8/pbs_mom.8B \
	$(DOCSRC)/man8/pbs_server.8B \
	$(DOCSRC)/man8/qmgr.8B \
	$(DOCSRC)/man8/qrun.8B \
	$(DOCSRC)/man8/qstart.8B \
	$(DOCSRC)/man8/qstop.8B \
	$(DOCSRC)/man8/qterm.8B \
	$(DOCSRC)/man8/pbsnodes.8B \
	$(DOCSRC)/man8/pbs_sched_cc.8B \
	$(DOCSRC)/man8/pbs_sched_basl.8B \
	$(DOCSRC)/man8/pbs_sched_tcl.8B


PARTS =	$(DOCTRG)/ers_ch0.ps \
	$(DOCTRG)/ers_ch1.ps \
	$(DOCTRG)/ers_ch2.ps \
	$(DOCTRG)/ers_ch3.ps \
	$(DOCTRG)/ers_ch4.ps \
	$(DOCTRG)/ers_ch5.ps \
	$(DOCTRG)/ers_ch6_7.ps \
	$(DOCTRG)/ers_ch8.ps \
	$(DOCTRG)/ers_ch9.ps \
	$(DOCTRG)/ers_ch10_11.ps \
	$(DOCTRG)/ers_ch12.ps \
	$(DOCTRG)/ers_ch13.ps \
	$(DOCTRG)/ers_chA.ps

TARGET = $(DOCTRG)/ers_all.ps

build:	${SOELIM} $(DOCTRG)/ers_toc.input ${PARTS}

no_toc:	${PARTS}

all:	$(TARGET)

$(TARGET):	${SOELIM} ${ERS} ${MAN1} ${MAN3} ${MAN7} ${MAN8} \
	${AUXERS} ${APPENDIX} $(DOCTRG)/ers_toc.input
	${SOELIM} -d $(DOCSRC)/ers $(FONTS) ${ERS} ${APPENDIX} | ${PIC} | ${TBL} | ${ROFF} -ms | ${POSTPS} > $(DOCTRG)/ers_all.ps

print:	build
	for F in ${PARTS} ; do ${PRTCMD} ${PRTFLG} $$F ; done

install:	${SOELIM} install1 install3 install7 install8

distclean:: clean
	-$(RM) Makefile

clean::
	-$(RM) $(TARGET) $(PARTS) *.input


$(SOELIM): $(srcdir)/../soelim.c
	cd ..; $(MAKE) soelim


#
# Install Various Man pages
#

install1:	${MAN1}
	@echo Installing section 1 man pages
	@$(INSTALL) -d -m 755 $(PBS_MAN1) && \
	for t in $?; do \
		tt=`basename $$t B`; \
		${SOELIM} -d $(DOCSRC)/ers $$t | sed -e 's/^\.Sh/.SH/' >${PBS_MAN1}/$${tt}$(MAN_SUFFIX); \
		chmod 644 ${PBS_MAN1}/$${tt}$(MAN_SUFFIX); \
	done

install3: $(MAN3)
	@echo Installing section 3 man pages
	@$(INSTALL) -d -m 755 $(PBS_MAN3) && \
	for t in $?; do \
		tt=`basename $$t B`; \
		${SOELIM} -d $(DOCSRC)/ers $$t | sed -e 's/^\.Sh/.SH/' >${PBS_MAN3}/$${tt}$(MAN_SUFFIX); \
		chmod 644 ${PBS_MAN3}/$${tt}$(MAN_SUFFIX); \
	done

install7: $(MAN7)
	@echo Installing section 7 man pages
	@$(INSTALL) -d -m 755 $(PBS_MAN7) && \
	for t in $?;  do \
		tt=`basename $$t B`; \
		${SOELIM} -d $(DOCSRC)/ers $$t | sed -e 's/^\.Sh/.SH/' >${PBS_MAN7}/$${tt}$(MAN_SUFFIX); \
		chmod 644 ${PBS_MAN7}/$${tt}$(MAN_SUFFIX); \
	done
	@rm -f ${PBS_MAN7}/pbs_resources.7$(MAN_SUFFIX)
	@ln ${PBS_MAN7}/pbs_resources_$(DEFAULT_MAN_RESOURCE_TYPE).7$(MAN_SUFFIX) ${PBS_MAN7}/pbs_resources.7$(MAN_SUFFIX)

install8: $(MAN8)
	@echo Installing section 8 man pages
	@$(INSTALL) -d -m 755 $(PBS_MAN8) && \
	for t in $?; do \
		tt=`basename $$t B`; \
		${SOELIM} -d $(DOCSRC)/ers $$t | sed -e 's/^\.Sh/.SH/' >${PBS_MAN8}/$${tt}$(MAN_SUFFIX); \
		chmod 644 ${PBS_MAN8}/$${tt}$(MAN_SUFFIX); \
	done

#
# Generate each (chapter) Part
#

$(DOCTRG)/ers_ch0.ps:	$(DOCSRC)/ers/title_ers.ms ${AUXERS} \
				$(DOCTRG)/ers_toc.input \
			$(DOCSRC)/ers/release.ms \
			$(DOCSRC)/ers/rel_history.ms
	${SOELIM} -d $(DOCSRC)/ers $(FONTS) $(DOCSRC)/ers/title_ers.ms | ${ROFF} -ms | ${POSTPS} > $(DOCTRG)/ers_ch0.ps

$(DOCTRG)/ers_ch1.ps:	$(DOCSRC)/ers/intro_ers.ms \
			$(DOCSRC)/ers/stagein.pic  \
			$(DOCSRC)/ers/glossary.ms ${AUXERS}
	${SOELIM} -d $(DOCSRC)/ers $(FONTS) $(DOCSRC)/ers/intro_ers.ms | ${PIC} | ${ROFF} -ms | ${POSTPS} > $(DOCTRG)/ers_ch1.ps

$(DOCTRG)/ers_ch2.ps:	$(DOCSRC)/ers/general_ers.ms ${AUXERS} \
			$(DOCSRC)/man1/pbs_job_attributes.7B \
			$(DOCSRC)/man1/pbs_queue_attributes.7B \
			$(DOCSRC)/man1/pbs_server_attributes.7B \
			$(DOCSRC)/ers/dir_struct.pic \
			$(DOCSRC)/ers/svr_dir.pic \
			$(DOCSRC)/ers/sched1.pic \
			$(DOCSRC)/ers/sched2.pic
	${SOELIM} -d $(DOCSRC)/ers $(FONTS) $(DOCSRC)/ers/general_ers.ms | ${PIC} | ${ROFF} -ms | ${POSTPS} > $(DOCTRG)/ers_ch2.ps

$(DOCTRG)/ers_ch3.ps:	$(DOCSRC)/ers/server_ers.ms ${AUXERS} \
			$(DOCSRC)/man1/pbs_resources_aix4.7B \
			$(DOCSRC)/man1/pbs_resources_irix5.7B \
			$(DOCSRC)/man1/pbs_resources_irix6.7B \
			$(DOCSRC)/man1/pbs_resources_sp2.7B \
			$(DOCSRC)/man1/pbs_resources_sunos4.7B \
			$(DOCSRC)/man1/pbs_resources_unicos8.7B
	 ${SOELIM} -d $(DOCSRC)/ers $(FONTS) $(DOCSRC)/ers/server_ers.ms | ${TBL} | ${ROFF} -ms | ${POSTPS} > $(DOCTRG)/ers_ch3.ps

$(DOCTRG)/ers_ch4.ps:	$(DOCSRC)/ers/ifl_ers.ms ${AUXERS} ${MAN3} \
			$(DOCSRC)/ers/iff.pic
	${SOELIM} -d $(DOCSRC)/ers $(FONTS) $(DOCSRC)/ers/ifl_ers.ms | $(PIC) | ${ROFF} -ms | ${POSTPS} > $(DOCTRG)/ers_ch4.ps

$(DOCTRG)/ers_ch5.ps:	$(DOCSRC)/ers/usercmds_ers.ms ${MAN1} ${AUXERS} \
			$(DOCSRC)/ers/basl_datatype.pic
	${SOELIM} -d $(DOCSRC)/ers $(FONTS) $(DOCSRC)/ers/usercmds_ers.ms | ${PIC} | ${ROFF} -ms | ${POSTPS} > $(DOCTRG)/ers_ch5.ps


$(DOCTRG)/ers_ch6_7.ps:	$(DOCSRC)/ers/opcmds_ers.ms ${MAN8} ${AUXERS}
	${SOELIM} -d $(DOCSRC)/ers $(FONTS) $(DOCSRC)/ers/opcmds_ers.ms | ${ROFF} -ms | ${POSTPS} > $(DOCTRG)/ers_ch6_7.ps

$(DOCTRG)/ers_ch8.ps:	$(DOCSRC)/ers/scheduler_ers.ms ${AUXERS}
	${SOELIM} -d $(DOCSRC)/ers/ $(FONTS) $(DOCSRC)/ers/scheduler_ers.ms | ${TBL} | ${ROFF} -ms | ${POSTPS} > $(DOCTRG)/ers_ch8.ps

$(DOCTRG)/ers_ch9.ps:	$(DOCSRC)/ers/resmom_ers.ms ${AUXERS}
	${SOELIM} -d $(DOCSRC)/ers/ $(FONTS) $(DOCSRC)/ers/resmom_ers.ms | $(TBL) | ${ROFF} -ms | ${POSTPS} > $(DOCTRG)/ers_ch9.ps

$(DOCTRG)/ers_ch10_11.ps:	$(DOCSRC)/ers/network_ers.ms \
			$(DOCSRC)/ers/twophase.pic \
			${AUXERS}
	${SOELIM} -d $(DOCSRC)/ers/ $(FONTS) $(DOCSRC)/ers/network_ers.ms | $(PIC) | $(TBL) | ${ROFF} -ms | ${POSTPS} > $(DOCTRG)/ers_ch10_11.ps

$(DOCTRG)/ers_ch12.ps:	$(DOCSRC)/ers/tools_ers.ms ${AUXERS}
	${SOELIM} -d $(DOCSRC)/ers/ $(FONTS) $(DOCSRC)/ers/tools_ers.ms | ${ROFF} -ms | ${POSTPS} > $(DOCTRG)/ers_ch12.ps

$(DOCTRG)/ers_ch13.ps:	$(DOCSRC)/ers/taskmgr_ers.ms ${AUXERS}
	${SOELIM} -d $(DOCSRC)/ers/ $(FONTS) $(DOCSRC)/ers/taskmgr_ers.ms | ${ROFF} -ms | ${POSTPS} > $(DOCTRG)/ers_ch13.ps

$(DOCTRG)/ers_chA.ps:	${APPENDIX}
	${SOELIM} -d $(DOCSRC)/ers $(FONTS) ${APPENDIX} | ${ROFF} -ms | ${POSTPS} >> $(DOCTRG)/ers_chA.ps


$(DOCTRG)/ers_toc.input:	${ERS}
	@echo Remaking ERS Table of Contents, please wait ...
	@rm -f $(DOCTRG)/ers_toc.input
	@touch $(DOCTRG)/ers_toc.input
	@for f in ${ERS} ; do \
	${SOELIM} -d $(DOCSRC)/ers $(FONTS) $$f | ${PIC} | ${ROFF} -ms -rI2 > /dev/null 2>>$(DOCTRG)/ers_toc.input ; done
	@echo TOC remake complete


# The following should go away in the product version

spell:
	${SOELIM} ${ERS} | spell +$(DOCSRC)/ers/local_spell
