SHELL=/bin/sh
CFLAGS= -O
LIBS=-lX11
#
# change for your printer
# TROFF should be defined to [nt]roff an ms document and print it
#
# the line below is for our local machine
TROFF=troff -Tpsc -ms | psdit | psprint
#TROFF=nroff -ms | lpr
#
SRCS=hline.c vline.c sline.c rects.c fillrects.c invrects.c \
	 dline.c wline.o imagestr.c screencpy.c pixmapcpy.c  \
	 scroll.c bitmapcpy.c tiledrects.c stiprects.c      \
	 arcs.c filledarcs.c filledpoly.c complex1.c line.c \
	 main.c dobenches.c

OBJS=hline.o vline.o sline.o rects.o fillrects.o invrects.o \
	 dline.o wline.o imagestr.o screencpy.o pixmapcpy.o  \
	 scroll.o bitmapcpy.o tiledrects.o stiprects.o      \
	 arcs.o filledarcs.o filledpoly.o complex1.o line.o \
	 main.o dobenches.o

HDR=\
       externals.h \
       benches.h \
       patchlevel.h \
       stipple1.bit \
       stipple2.bit \
       tile1.bit \
       tile2.bit \
       bitmap1.bit
DOC=\
       README \
       AUTHOR \
       xbench.man \
       xbench.doc
STUFF=\
       Imakefile \
       mkfile \
       script.run
SCRIPTS=\
       scripts \
       results \
       results/sun3-50.R3.out  \
       results/sun3-160.R2.out \
       results/gpx.R2.out      \
       results/9733.R2.out     \
       scripts/Make.proto     \
       scripts/summary.awk       \
       scripts/detail.awk       \
       scripts/detail.awk       \
       scripts/xstones.awk       \
       scripts/insSep.sh         \
       scripts/postfix.ms        \
       scripts/prefix.ms


xbench: $(OBJS)
	  $(CC) -o xbench $(OBJS) $(LIBS)

dobenches.o:    benches.h

kit:
	-makekit $(DOC) $(SRCS) $(HDR) $(STUFF) $(SCRIPTS) > /dev/null

printdoc:   xbench.doc
	    tbl xbench.doc | $(TROFF)

print:      summary detail
	    tbl summary.ms detail.ms | $(TROFF)

summary:            results tmp summary.ms

printsummary:       summary
		    tbl summary.ms | $(TROFF)

detail:             results tmp detail.ms

printdetail:        detail
		    tbl detail.ms | $(TROFF)

results:
		    @echo You must put all .out files into
		    @echo a subdirectory named: results
		    exit 1

tmp:
		    mkdir tmp

summary.ms:         tmp/makefile
		    (cd tmp; make summary.ms)
		    mv tmp/summary.ms .

detail.ms:          tmp/makefile
		    (cd tmp; make detail.ms)
		    mv tmp/detail.ms .

tmp/makefile:       results
		    -(files=""; \
		      sfiles=""; \
		      cd results; \
		      for i in *.out; do     \
			sfiles="$$sfiles $$i""__" ; \
			files="$$files $$i"; \
		      done; \
		      cd ..; \
		      echo "SFILES=$$sfiles" > tmp/makefile; \
		      echo >> tmp/makefile; \
		      for i in $$files; do     \
			echo $$i"__: " $$i"_" >> tmp/makefile; \
			echo >> tmp/makefile; \
			echo $$i"_: " $$i >> tmp/makefile; \
			echo >> tmp/makefile; \
		      done)
		    echo >> tmp/makefile
		    cat scripts/Make.proto >> tmp/makefile
