# Last edited on 2004-09-26 17:40:44 by stolfi
# Creates the range scatterplots

MAKEFILE := range-scatterplots.make

######################################################################
# Recipe for all plots and stacks
# Caller must define BOOKS (list of three-letter book codes), 
# FMTS (list of "eps" and/or "png")

BOOKS := BOOKS.IS.UNDEFINED
ifneq "/${BOOKS}" "/BOOKS.IS.UNDEFINED"
FMTS := FMTS.IS.UNDEFINED
ifneq "/${FMTS}" "/FMTS.IS.UNDEFINED"

all:
	@echo "BOOKS = ${BOOKS}  FMTS = ${FMTS}"
	@for fmt in ${FMTS}; do \
	  for book in ${BOOKS}; do \
            ${MAKE} -f ${MAKEFILE} \
                FMT=$$fmt BOOK=$$book \
                stack ; \
	  done ; \
	done
        
endif
endif
# end of BOOKS, FMTS
######################################################################

######################################################################
# Recipe for a single stack
# Caller must define BOOK (three-letter book code), 
# FMT ("eps" or "png")

BOOK := BOOK.IS.UNDEFINED
ifneq "/${BOOK}" "/BOOK.IS.UNDEFINED"
FMT := FMT.IS.UNDEFINED
ifneq "/${FMT}" "/FMT.IS.UNDEFINED"

# Stack of histograms:
STKFILE := ${BOOK}-rs.${FMT}

stack: 
	@echo "BOOK = ${BOOK}  FMT = ${FMT}"
	for t in n r; do \
	  ${MAKE} -f ${MAKEFILE} \
              FMT=${FMT} BOOK=${BOOK} ORDER=$$t single; \
	done; \
	if [ ".${FMT}" == ".png" ]; then \
	  convert ${BOOK}-{n,r}-rs.${FMT} +append "${STKFILE}"; \
	  display "${STKFILE}"; \
	fi
        
endif
endif
# end of BOOK, FMT
######################################################################

######################################################################
# Recipe for a single scatterplot
# Caller must define BOOK (three-letter book code), 
# FMT ("eps" or "png"), ORDER ("n" or "t")

BOOK := BOOK.IS.UNDEFINED
ifneq "/${BOOK}" "/BOOK.IS.UNDEFINED"
FMT := FMT.IS.UNDEFINED
ifneq "/${FMT}" "/FMT.IS.UNDEFINED"
ORDER := ORDER.IS.UNDEFINED
ifneq "/${ORDER}" "/ORDER.IS.UNDEFINED"

# File with word counts and ranges for ${BOOK}, in order ${ORDER}
FLRFILE := ${BOOK}-${ORDER}.flr

# Sacterplot image
PLTFILE := ${BOOK}-${ORDER}-rs.${FMT}

single: ${PLTFILE}

${PLTFILE}: ${FLRFILE} ${MAKEFILE} plot-range-width-scatter
	plot-range-width-scatter ${FMT} \
          < ${FLRFILE} \
          > ${PLTFILE}
	if [ ".${FMT}" == ".png" ]; then display -title '%d%f' ${PLTFILE}; fi
	if [ ".${FMT}" == ".eps" ]; then gv ${PLTFILE}; fi
        
endif
endif
endif
# end of BOOK, FMT, ORDER
######################################################################