# Last edited on 2011-05-31 19:22:15 by stolfilocal

SHELL := /bin/bash

# Shall we display static images and movie frames?
SHOW := YES

.PHONY::
.PHONY:: all render-all clean-all
   
SPECIAL_JOBS := \
  800+800+2+fig_un3_drone_W_2 \
  600+600+2+fig_un3_drone_S_1 \
  700+700+2+fig_un3_drone_Z_3 \
  300+300+1+fig_un4_pillars_and_beams_NW \
  750+750+1+fig_un4_crane \
  750+750+1+fig_un4_building_cut_Z5 \
  750+750+1+fig_un4_building_cut_N \
  750+750+1+fig_un4_building_cut_W \
  750+750+1+fig_un4_building_cut_NW \
  750+750+1+fig_un4_containment_cut_NW \
  750+750+1+fig_un4_massive_NW \
  750+750+1+fig_un4_structure_cut_NW \
  750+750+1+fig_un4_service_storey_E_face \
  750+750+1+fig_un4_service_storey_S_face \
  750+750+1+fig_un4_pools_and_walls \
  750+750+1+fig_un4_drywell_enclosure_cut_NW \
  750+750+1+fig_un4_skinless_NW \
  \
  750+750+1+fig_un1_containment_cut_NW \
  750+750+1+fig_un1_building_cut_NW \
  750+750+1+fig_un1_building_cut_Z0 \
  750+750+1+fig_un1_building_cut_Z1 \
  750+750+1+fig_un1_building_cut_Z3 \
  750+750+1+fig_un1_building_cut_Z4 \
  750+750+1+fig_un1_building_cut_Z5 \
  750+750+1+fig_un1_building_cut_Z6 \
  750+750+1+fig_un1_building_cut_Z7\
  750+750+1+fig_un1_pipes_bounder_NW \
  750+750+1+fig_un1_surge_pipe_NW \
  750+750+1+fig_un1_pools_and_walls \
  750+750+1+fig_un1_drywell_enclosure_cut_NW \
  \
  750+750+1+fig_un1_building_cut_N \
  750+750+1+fig_un1_building_cut_W

NOT_SPECIAL_JOBS := \

OVR_JOBS := \
  750+750+1+fig_un1_building_cut_W \
  750+750+1+fig_un1_building_cut_N

DEFAULT_SIZE := 200+200
DEFAULT_NRAYS := 1
FIG_POVS := ${wildcard fig*.pov}
FIG_JOBS := ${addprefix ${DEFAULT_SIZE}+${DEFAULT_NRAYS}+,${subst .pov,,${FIG_POVS}}}
 
# The goal jobjs:
TARGET_JOBS := ${SPECIAL_JOBS}
# TARGET_JOBS := ${FIG_JOBS}
# TARGET_JOBS := ${OVR_JOBS}

all: render-all

render-all:
	-for job in ${TARGET_JOBS} ; do \
          ${MAKE} JOB=$$job render-single ; \
        done

clean-all:
	-for job in ${TARGET_JOBS} ; do \
          ${MAKE} JOB=$$job clean-single ; \
        done

ifneq "/${JOB}" "/"
#######################################################################
# For recursive "make" - caller must define ${JOB}

JOB_ARGS := ${subst +, ,${JOB}}
WIDTH  := ${shell printf "%04d" "${word 1,${JOB_ARGS}}"}
HEIGHT := ${shell printf "%04d" "${word 2,${JOB_ARGS}}"}
NRAYS  := ${word 3,${JOB_ARGS}}
NAME   := ${word 4,${JOB_ARGS}}

OUT_DIR := out/${WIDTH}x${HEIGHT}-${NRAYS}

TARGET_PNG := ${OUT_DIR}/${NAME}.png
 
.PRECIOUS: ${TARGET_PNG}

.PHONY:: render-single clean-single

ICON_PNG := ${subst .png,_icon.png,${TARGET_PNG}}

render-single: ${TARGET_PNG} ${ICON_PNG}
 
# ----------------------------------------------------------------------
# Rendered static image:

INC_IMG_FILES := ${wildcard *.inc texmaps/*.png}
MAKE_FILES    := ${wildcard Makefile POVRAY-*.make}
SHELL_FILES   := ${wildcard *.sh}

${OUT_DIR}/fig_%.png: fig_%.pov ${INC_IMG_FILES} ${MAKE_FILES} ${SHELL_FILES}
	${MAKE} -f POVRAY-STATIC.make \
            OUT_DIR=${OUT_DIR} NAME="fig_$*" \
            WIDTH=${WIDTH} HEIGHT=${HEIGHT} NRAYS=${NRAYS} \
            SHOW="${SHOW}" \
            render-static 

# ----------------------------------------------------------------------
# Icon of overlaid or rendered image:

%_icon.png: %.png
	convert $*.png -resize 'x75' $*_icon.png

# End of ${JOB} section
#######################################################################
endif
