# Last edited on 2016-09-08 21:51:28 by stolfilocal

EXDIR := NONE

# DO_FIGS = ${SPEC_FIGS}
# DO_FIGS = ${TEST_FIGS}

DO_FIGS = \
  800:600:fig_810_wetbench_solo
  
SPEC_FIGS := \
  800:600:fig_810_wetbench_solo \
  800:700:fig_811_wetbench_bnch \
  \
  800:800:fig_820_wetbench_dims \
  800:800:fig_821_wetbench_expl \
  800:800:fig_822_wetbench_fram \
  800:800:fig_823_wetbench_solo

TEST_FIGS := \
  600:600:fig_910_test_bench \
  600:600:fig_960_test_basics \
  600:600:fig_970_test_ctrim

ALL_FIGS := \
  \
  ${TEST_FIGS} \
  \
  ${SPEC_FIGS} \
  \
  640:480:fig_051_wetbench_1 \
  640:480:fig_053_wetbench_3 \
  640:480:fig_054_wetbench_4 \
  640:480:fig_061_wetbench_1_bench \
  640:480:fig_063_wetbench_3_bench \
  640:480:fig_064_wetbench_4_bench \
  \
  640:480:fig_210_lab_302_wetbench \
  640:480:fig_211_lab_302_wetbench \
  640:480:fig_212_lab_302_wetbench \
  640:480:fig_213_lab_302_wetbench \
  640:480:fig_214_lab_302_wetbench \
  640:480:fig_215_lab_302_wetbench \
  \
  800:800:fig_220_lab_302_wetbench_t \
  \
  640:480:fig_230_lab_304_wetbench \
  640:480:fig_231_lab_304_wetbench \
  640:480:fig_232_lab_304_wetbench \
  640:480:fig_233_lab_304_wetbench \
  \
  800:800:fig_240_lab_304_wetbench_t

DONT_DO_FIGS := \
  ${ALL_FIGS}
  
JUNK_FIGS := \
  640:480:fig_052_wetbench_2 \
  640:480:fig_062_wetbench_2_bench

INCLUDES :=

.PHONY: all single cleanup  image showimage export
  
all: 
	@for fig in ${DO_FIGS} ; do \
          ${MAKE} FIGARGS=$$fig single ; \
        done

export: ${EXDIR}
	for fig in ${DO_FIGS} ; do \
          ${MAKE} FIGARGS=$$fig export-single ; \
        done
        
        
######################################################################
# Sub-makefile - caller must define ${FIGARGS}

FIGARGS := FIGARGS.IS.UNDEFINED

ifneq "/${FIGARGS}" "/FIGARGS.IS.UNDEFINED"

FIELDS   := ${subst :, ,${FIGARGS}}
WIDTH    := ${word  1,${FIELDS}}
HEIGHT   := ${word  2,${FIELDS}}
FIG      := ${word  3,${FIELDS}}

ICONFIG = ${FIG}-i

POVPUB = /usr
POVRAY = ${POVPUB}/bin/povray
POVINC = ${POVPUB}/share/povray-3.7/include
POVTTF = $${STOLFIHOME}/ttf
IMVIEW = display -title '%d/%f'
CONVERT = convert

# single: image showimage
single: image showimage
	@echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"

cleanup: 
	-/bin/rm -f ${FIG}.png

image: ${FIG}.png

showimage: ${FIG}.png
	-if [[ -s ${FIG}.png ]]; then ${IMVIEW} ${FIG}.png ; fi

NRAYS := 2

${FIG}.png: ${FIG}.pov ${INCLUDES}
	@echo "@@@ ${FIG} @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
	-/bin/rm -f ${FIG}.png
	@nice ${POVRAY} \
            +FN +Q9 \
            +W${WIDTH} +H${HEIGHT} \
            +AM1 +A0.0 +R${NRAYS} \
            +D \
            +L${POVINC} \
            +L${POVTTF} \
            +I${FIG}.pov \
            +O${FIG}.png \
          2>&1 | povray-output-filter.gawk


ICONHEIGHT := 100

${ICONFIG}.jpg: ${FIG}.png
	convert ${FIG}.png \
            -quality 99 \
            -resize 'x${ICONHEIGHT}' \
            ${ICONFIG}.jpg
        
export-single: ${FIG}.png ${ICONFIG}.jpg
	cp -av ${FIG}.png ${ICONFIG}.jpg ${EXDIR}


endif
# End ${FIGARGS} sub-makefile.
######################################################################

ALL_PNGS := ${addsuffix .png,${patsubst %:,,${patsubst %:,,${ALL_FIGS}}}}

debug: 
	@echo "${ALL_PNGS}"
