# Makefile para processar as entregas do exercĂ­cio tp05 de POV-Ray
# Last edited on 2003-05-31 18:41:24 by stolfi

WIDTH := 800
HEIGHT := 400

ICONWIDTH := 120
ICONHEIGHT := 60

NRAYS = 2

OTHERINPUTS = 

# No need to change below here

NAME = main

ICONNAME = icon

POVPUB = /home/staff/stolfi/programs/c-curitiba/povray-3.50c-1/PUB
POVRAY = ${POVPUB}/i686-Linux-2.2/bin/povray
POVINC = ${POVPUB}/share/povray-3.5/include
POVTTF = /home/staff/stolfi/PUB/povray/tt-fonts
IMVIEW = /usr/X11R6/bin/display
CONVERT = /usr/X11R6/bin/convert

.PHONY: all cleanup  image showimage all-images index

all: image showimage

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

image: ${NAME}.gif

showimage: ${NAME}.gif
	-${IMVIEW} ${NAME}.gif

${NAME}.gif: ${NAME}.png
	-/bin/rm -f ${NAME}.gif
	${CONVERT} ${NAME}.png ${NAME}.gif

${NAME}.png: ${NAME}.pov ${OTHERINPUTS}
	-/bin/rm -f ${NAME}.png
	nice ${POVRAY} \
            +FN +Q9 \
            +W${WIDTH} +H${HEIGHT} \
            +AM1 +A0.0 +R${NRAYS} \
            +D +SP32 +EP4 \
            +L${POVINC} \
            +L${POVTTF} \
	    +I${NAME}.pov \
	    +O${NAME}.png \
	  3>&2 > ${NAME}.log

${ICONNAME}.gif: ${NAME}.gif
	cat ${NAME}.gif \
          | giftopnm \
          | pnmscale -ysize ${ICONHEIGHT} \
          | pnmdepth 255 \
          | ppmquant 254 \
          | ppmtogif > ${ICONNAME}.gif
        
all-images: rausrs.txt
	../../../tools/make-all-images \
          `cat rausrs.txt | egrep -v '^ *([#]|$$)' | gawk '//{print $$1;}' `

index: title.txt rausrs.txt aus.txt \
       absent.gif absent-s.gif \
       missing.gif missing-s.gif
	../../../tools/make-labday-image-page "`cat title.txt`"

absent.gif: Makefile
	ppmmake 'rgbi:0.75/0.75/0.75' ${WIDTH} ${HEIGHT} \
          | pnmdepth 255 \
          | ppmquant 254 \
          | ppmtogif \
          > absent.gif
	-${IMVIEW} absent.gif
        
missing.gif: Makefile
	ppmmake 'rgbi:0.80/0.15/0.15' ${WIDTH} ${HEIGHT} \
          | pnmdepth 255 \
          | ppmquant 254 \
          | ppmtogif \
          > missing.gif
	-${IMVIEW} missing.gif

%-s.gif: %.gif Makefile
	cat $*.gif \
          | giftopnm \
          | pnmscale -ysize ${ICONHEIGHT} \
          | pnmdepth 255 \
          | ppmquant 254 \
          | ppmtogif > $*-s.gif
	-${IMVIEW} $*-s.gif