#!/usr/bin/gmake -f
ifeq (0,1)
require GNU make
endif
#l224 Pocitacove site 3.6
N1 = 36
N2 = 44
N3 = 39
N4 = 35
N5 = 35
N6 = 40
N7 = 36
N8 = 40
N9 = 40
 
#.../pngs1/obraz0##
#.../pngs1/obraz1##
N10 =33
N11 =42
N12 =38
N13 =48
N14 =43
N15 =37
N16 =29
N17 =35
N18 =46
N19 =45
N20 =34
N21 =39
N22 =43
 
L ?= 8
 
define N
$(shell while [ $${i:=1} -le $(N$1) ];do echo $$i;i=`expr $$i + 1`;done)
endef
define iota
$(shell while [ $${i:=$1} -le $2 ];do echo $$i;i=`expr $$i + 1`;done)
endef
define pngs
$(shell echo $1| sed -e 's,^\([0-9]\)$$,gifs/obraz\1,' -e 's,^\([0-9]\)\(.\)$$,gifs\1/obraz\2,')
endef
 
#obraz = $(addprefix obraz$L,$(shell while [ $${i:=1} -le $(N$L) ];do echo $$i;i=`expr $$i + 1`;done))
 obraz = $(addprefix $(call pngs,$L),$(call N,$L))
 
#vyvoj/ladeni:
g : ; @echo '$(call pngs,55)'
o : ; @echo '$(obraz)'
t : ; @echo '$(call iota,1,10)'
 
pngs : $(addsuffix .png,$(obraz))
 
gifs/obraz%.png gifs1/obraz%.png gifs2/obraz%.png :
	test -d $(dir $@) || mkdir $(dir $@)
	wget -O $@ http://www.earchiv.cz/l224/$@
 
#lze pouzit i pdftk, pouzijeme convert (ImageMagick)
obraz%.pdf : export L = $*
obraz%.pdf : ; $(MAKE) pngs L=$L; convert $(addsuffix .png,$(obraz)) $@
 
pdfs : $(addsuffix .pdf,$(addprefix obraz,$(call iota,1,22)))
 
include ../common.mk
#vymazeme jenom stazene obrazky
clean : ; rm -rf -- gifs*
 
#vymazeme i vygenerovane
distclean : clean ; rm -rf -- *.pdf
 
#TODO: install/kopie na ci.bule.cz dokuwiki
 
FORCE : ;