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


#
# Makefile for Internal Design Spec (IDS)
#
# Targets:
#	build:	makes individual postscript files for each chapter.
#		Useful in printing one or more chapters.
#	all:	makes a single postscript file for the entire document.
#	no_toc:	makes individual chapters without updating the table of 
#		contents or index.
#
srcdir = @srcdir@
top_srcdir = @top_srcdir@
MK_VPATH = @srcdir@

@mk_head@
@mk_dirs@


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

IDSDIR	= $(srcdir)
DOCTRG	= .

IDS_PS = \
	$(DOCTRG)/ids_01_intro.ps \
	$(DOCTRG)/ids_02_user_cmds.ps \
	$(DOCTRG)/ids_03_op_cmds.ps \
	$(DOCTRG)/ids_04_adm_cmds.ps \
	$(DOCTRG)/ids_05_server.ps \
	$(DOCTRG)/ids_06_scheduler.ps \
	$(DOCTRG)/ids_07_rm.ps \
	$(DOCTRG)/ids_08_mom.ps \
	$(DOCTRG)/ids_09_iff.ps \
	$(DOCTRG)/ids_10_lib.ps \
	$(DOCTRG)/ids_11_protocol.ps \
	$(DOCTRG)/ids_12_gui.ps \
	$(DOCTRG)/ids_index.ps

IDS_SRC = $(srcdir)/ids_intro.ms \
	$(srcdir)/ids_user_cmds.ms \
	$(srcdir)/ids_op_cmds.ms \
	$(srcdir)/ids_adm_cmds.ms \
	$(srcdir)/ids_server.ms \
	$(srcdir)/ids_scheduler.ms \
	$(srcdir)/ids_rm.ms \
	$(srcdir)/ids_mom.ms \
	$(srcdir)/ids_iff.ms \
	$(srcdir)/ids_lib.ms \
	$(srcdir)/ids_protocol.ms \
	$(srcdir)/ids_gui.ms \
	$(srcdir)/ids_index.ms

AUXIDS = $(srcdir)/ids_setup.ms $(srcdir)/../ers/ers.macros 

build:	ids_toc.input ids_index.input $(IDS_PS)

all: ids_all.ps 

ids_all.ps:  $(IDS_SRC) $(AUXIDS) $(DRAWINGS) ids_toc.input ids_index.input
	$(SOELIM) -d $(IDSDIR) -d $(IDSDIR)/../ers $(FONTS) $(IDS_SRC) | $(PIC) | $(TBL) | $(ROFF) -ms | $(POSTPS) > ids_all.ps

no_toc:	$(IDS_PS)  # make lastest changes without remaking toc/index

install:  build

distclean:: clean
	-$(RM) Makefile

clean::
	-$(RM) *.ps *.input

print:	build
	for F in $(IDS_PS) ; do $(PRTCMD) $(PRTFLG) $$F; done


$(DOCTRG)/ids_index.ps:	$(srcdir)/ids_index.ms ids_index.input
	$(SOELIM) -d $(DOCTRG) $(FONTS) $(srcdir)/ids_index.ms | $(TBL) | $(ROFF) -ms | $(POSTPS) > ids_index.ps

ids_toc.input:	$(IDS_SRC) $(srcdir)/ids_ifl.ms
	@echo Remaking IDS Table of Contents, please wait ...
	@rm -f ids_toc.input
	@touch  ids_toc.input
	@TMP=ids_toc.tmp.$$$$ ; \
	for f in $(IDS_SRC) ; do \
	    $(SOELIM) -d $(IDSDIR) -d $(IDSDIR)/../ers $(FONTS) $$f | $(PIC) | $(ROFF) -ms -rI2 > /dev/null 2>>$$TMP ; \
	done ; \
	grep -v "find font" < $$TMP >> ids_toc.input ; \
	rm $$TMP
	@echo TOC remake complete

ids_index.input: $(IDS_SRC) $(srcdir)/ids_ifl.ms
	@echo Remaking IDS index, please wait ...
	@rm -f ids_index.input
	@touch ids_index.input
	@TMP=ids_index.tmp.$$$$ ; \
	touch $$TMP ; \
	for f in $(IDS_SRC) ; do \
	    $(SOELIM) -d $(srcdir)  -d $(IDSDIR)/../ers $(FONTS) $$f | $(PIC) | $(ROFF) -ms -rI1 > /dev/null 2>>$$TMP ; \
	done ; \
	grep -v "find font" < $$TMP | sort | uniq > ids_index.input; \
	rm $$TMP
	@echo IDS index remade

$(DOCTRG)/ids_01_intro.ps:	${IDSDIR}/ids_intro.ms ${AUXIDS} \
		$(DOCTRG)/ids_toc.input \
		$(IDSDIR)/ids_struct.pic \
		$(IDSDIR)/../ers/release.ms \
		$(IDSDIR)/../ers/rel_history.ms
	${SOELIM} -d $(IDSDIR) $(FONTS) ${IDSDIR}/ids_intro.ms | ${PIC} | ${ROFF} -ms | ${POSTPS} > ${DOCTRG}/ids_01_intro.ps

${DOCTRG}/ids_02_user_cmds.ps:	${IDSDIR}/ids_user_cmds.ms ${AUXIDS}
	${SOELIM} -d $(IDSDIR) $(FONTS) ${IDSDIR}/ids_user_cmds.ms | ${ROFF} -ms | ${POSTPS} > ${DOCTRG}/ids_02_user_cmds.ps

${DOCTRG}/ids_03_op_cmds.ps:	${IDSDIR}/ids_op_cmds.ms ${AUXIDS}
	${SOELIM} -d $(IDSDIR) $(FONTS) ${IDSDIR}/ids_op_cmds.ms | ${ROFF} -ms | ${POSTPS} > ${DOCTRG}/ids_03_op_cmds.ps

${DOCTRG}/ids_04_adm_cmds.ps:	${IDSDIR}/ids_adm_cmds.ms ${AUXIDS}
	${SOELIM} -d $(IDSDIR) $(FONTS) ${IDSDIR}/ids_adm_cmds.ms | ${ROFF} -ms | ${POSTPS} > ${DOCTRG}/ids_04_adm_cmds.ps

${DOCTRG}/ids_05_server.ps:	${IDSDIR}/ids_server.ms ${AUXIDS}
	${SOELIM} -d $(IDSDIR) -d $(IDSDIR)/../ers $(FONTS) ${IDSDIR}/ids_server.ms | ${TBL} | ${PIC} | ${ROFF} -ms | ${POSTPS} > ${DOCTRG}/ids_05_server.ps

${DOCTRG}/ids_06_scheduler.ps:	${IDSDIR}/ids_scheduler.ms ${AUXIDS} \
				$(IDSDIR)/baslsw_arch.pic
	${SOELIM} -d $(IDSDIR) $(FONTS) ${IDSDIR}/ids_scheduler.ms | $(TBL) | ${PIC} | ${ROFF} -ms | ${POSTPS} > ${DOCTRG}/ids_06_scheduler.ps

${DOCTRG}/ids_07_rm.ps:	${IDSDIR}/ids_rm.ms ${AUXIDS}
	${SOELIM} -d $(IDSDIR) $(FONTS) ${IDSDIR}/ids_rm.ms | ${ROFF} -ms | ${POSTPS} > ${DOCTRG}/ids_07_rm.ps

${DOCTRG}/ids_08_mom.ps:	${IDSDIR}/ids_mom.ms ${AUXIDS}
	${SOELIM} -d $(IDSDIR) $(FONTS) ${IDSDIR}/ids_mom.ms | ${PIC} | ${ROFF} -ms | ${POSTPS} > ${DOCTRG}/ids_08_mom.ps

${DOCTRG}/ids_09_iff.ps:	${IDSDIR}/ids_iff.ms ${AUXIDS}
	${SOELIM} -d $(IDSDIR) -d $(IDSDIR)/../ers $(FONTS) ${IDSDIR}/ids_iff.ms | ${PIC} | ${ROFF} -ms | ${POSTPS} > ${DOCTRG}/ids_09_iff.ps

${DOCTRG}/ids_10_lib.ps:	${IDSDIR}/ids_lib.ms ${IDSDIR}/ids_ifl.ms ${AUXIDS}
	${SOELIM} -d $(IDSDIR) $(FONTS) ${IDSDIR}/ids_lib.ms | ${PIC} | ${ROFF} -ms | ${POSTPS} > ${DOCTRG}/ids_10_lib.ps

${DOCTRG}/ids_11_protocol.ps:	${IDSDIR}/ids_protocol.ms ${AUXIDS}
	${SOELIM} -d $(IDSDIR) $(FONTS) ${IDSDIR}/ids_protocol.ms | ${ROFF} -ms | ${POSTPS} > ${DOCTRG}/ids_11_protocol.ps

${DOCTRG}/ids_12_gui.ps:	${IDSDIR}/ids_gui.ms ${AUXIDS}
	${SOELIM} -d $(IDSDIR) $(FONTS) ${IDSDIR}/ids_gui.ms | ${ROFF} -ms | ${POSTPS} > ${DOCTRG}/ids_12_gui.ps


#
# Additional dependencies
#
$(IDS_PS): $(AUXIDS)

ids_intro.ps:	ids_toc.input \
		$(srcdir)/ids_struct.pic \
		$(srcdir)/../ers/release.ms \
		$(srcdir)/../ers/rel_history.ms



# the following go away in the final product

spell:
	spell +local_spell $(IDS_SRC) $(srcdir)/ids_ifl.ms

nroff:	
	-rm -f nroff.out
	$(NROFF) -ms $(IDS_SRC) > nroff.out

