TARGETS = all

# Print command
#              vvvvv  This needs to be customized!!!
PRINT   = lpr -Phpps

TBL     = tbl
PTROFF  = ptroff -ms -t

#
# Suffix Rules
#
.SUFFIXES: .tbl .tms .ms .ps

#
# Keep command state
#
.KEEP_STATE:

#
# MTV Format
#
FORMAT_FILE   = mtvformat.ms
FORMAT_PSFILE = mtvformat.ps
FORMAT_DATA   = mtv_ident1.tms mtv_ident2.tms \
                ex1.mtvdat ex2.mtvdat ex3.mtvdat ex4.mtvdat \
                ex5a.mtvdat ex5b.mtvdat ex6a.mtvdat ex6b.mtvdat

#
# Format Appendix
#
APPENDIXA_FILE   = mtvformat.appA.ms 
APPENDIXA_PSFILE = mtvformat.appA.ps 
APPENDIXA_DATA   = 

#
# MTV Properties
#

OPTION_FILE   = options.ms
OPTION_PSFILE = options.ps
OPTION_SOURCES= plot_pr.tbl view_pr.tbl data_pr.tbl curv_pr.tbl gbcv_pr.tbl
OPTION_OBJECTS= plot_pr.tms view_pr.tms data_pr.tms curv_pr.tms gbcv_pr.tms

EPSFILES = dataA.ps dataB.ps dataC.ps dataD.ps dataE.ps dataF.ps

PSFILES = $(FORMAT_PSFILE) \
          $(APPENDIXA_PSFILE) $(OPTION_PSFILE) $(EPSFILES)\
          $(APPENDIXB_PSFILE) $(ANNOT_PSFILE) $(ANNOT_EPSFILE)


#
# Annotations Appendix
#
APPENDIXB_FILE   = mtvformat.appB.ms
APPENDIXB_PSFILE = mtvformat.appB.ps
APPENDIXB_DATA   = 

#
# MTV Annotations
#

ANNOT_FILE    = annot.ms
ANNOT_PSFILE  = annot.ps
ANNOT_SOURCES = annot_pr.tbl
ANNOT_OBJECTS = annot_pr.tms annot.mtv
ANNOT_EPSFILE = annot.mtv.ps

#
# What to make
#
all: $(PSFILES) 

print: $(PSFILES) 
	$(PRINT) $(PSFILES)

#
# MTVDAT format 
#
$(FORMAT_PSFILE) : $(FORMAT_DATA)

#
# Appendix A : MTV Properties
#
$(APPENDIXA_PSFILE) : $(APPENDIXA_DEP)

#
# MTV Properties
#
$(OPTION_PSFILE) : $(OPTION_OBJECTS)

#
# Appendix B : MTV Properties
#
$(APPENDIXB_PSFILE) : $(APPENDIXB_DEP)

#
# MTV Annotations
#
$(ANNOT_PSFILE) : $(ANNOT_OBJECTS)

#
# Clean
#
cleanall: clean

clean:
	rm -f $(PSFILES) $(OPTION_OBJECTS)

#
# Suffix rule for converting .tbl files to .tms files
#
.tbl.tms:
	$(TBL) $< > $@

#
# Suffix rule for converting .ms files to .ps files
#
.ms.ps:
	$(TBL) $< | $(PTROFF) > $@
