# Makefile to process POV-Ray static images

SHELL := /bin/bash

ifneq "/${MAIN}" "/"
ifneq "/${IMGNAME}" "/"
ifneq "/${NRAYS}" "/"
ifneq "/${WIDTH}" "/"
ifneq "/${HEIGHT}" "/"
#=======================================================================

# POV-Ray installation directories:
POVRAY := /usr/bin/povray
POVINC := /usr/share/povray-3.7/include/

POVTTF := ../tools/tt-fonts

PNGFILE := ${IMGNAME}.png

IMVIEW := display -title '%f' -resize '<700x1200'

image: ${PNGFILE} 

${PNGFILE}: ${NAME}.pov ${wildcard *.inc img-*.png}
	-/bin/rm -f ${PNGFILE}
	export PATH="../tools:$${PATH} ; \
        ${POVRAY} +K0.5000 \
            +FN +Q9 \
            +W${WIDTH} +H${HEIGHT} \
            +AM1 +A0.0 +R${NRAYS} \
            +D \
            +L${POVINC} \
	    +L${POVTTF} \
	    +I${MAIN}.pov \
	    +O${PNGFILE} \
          2>&1 | povray-output-filter.gawk
	if [[ "/${SHOW}" == "/YES" ]]; then \
          if [[ -s ${PNGFILE} ]]; then \
            ${IMVIEW} ${PNGFILE} ; \
          fi \
        fi

endif
endif
endif
endif
endif
