replace export.sh by Makefile

This commit is contained in:
Johann Dreo 2025-08-03 22:01:49 +02:00
commit 7c1d2f4e32
2 changed files with 56 additions and 21 deletions

56
Makefile Normal file
View file

@ -0,0 +1,56 @@
##### Variables #####
SVGs := $(shell find . -type f -name "*.svg" -not -path "./sources/*")
# $(info SVGs: $(SVGs))
SIGHTS := $(SVGs:.svg=.png)
CARDS := $(foreach s,$(SVGs),\
$(foreach i,1 2 3 4,\
$(subst .svg,_card_$(i).png,$(s))))
##### Generic targets #####
all: sights cards galleries
sights: $(SIGHTS)
cards: $(CARDS)
galleries: gallery_cards.png gallery_sights.png
.PHONY: clean
clean:
rm -f $(SIGHTS)
rm -f $(CARDS)
rm gallery_cards.png gallery_sights.png
#### Galleries #####
gallery_sights.png: $(SIGHTS)
montage $(SIGHTS) -geometry 512 -border 10 -frame 4 -mattecolor black -shadow $@
gallery_cards.png: $(CARDS)
montage $(CARDS) -geometry 256 -border 10 -frame 4 -mattecolor black -shadow -tile 4x $@
##### Sights #####
define sight_template =
$(1:.svg=.png): $(1)
inkscape --without-gui --export-width=1024 --export-area-page --export-png=$(1:.svg=.png) $(1)
endef
$(foreach s,$(SVGs),\
$(eval $(call sight_template,$(s)))\
)
##### Cards #####
define card_template =
$(1:.svg=_card_$(2).png): $(1)
inkscape --without-gui --export-height=800 --export-id=card_$(i) --export-png=$(1:.svg=_card_$(2).png) $(1)
endef
$(foreach s,$(SVGs),\
$(foreach i,1 2 3 4,\
$(eval $(call card_template,$(s),$(i)))\
)\
)

View file

@ -1,21 +0,0 @@
#!/bin/sh
# for each svg file
for svg in `find $1 -name *.svg` ; do
# the complete filename without the extension
base=`echo $svg | sed s/.svg//`
# export each 4 cards
for i in `seq 4` ; do
echo "===== ${base}_card_$i ====="
time inkscape --export-png=${base}_card_$i.png --without-gui --export-id=card_$i --export-height=800 $svg
echo "===== DONE ====="
done
# export the whole page
echo "===== ${base} ====="
time inkscape --export-png=$base.png --export-area-page --export-width=1024 --without-gui $svg
echo "===== DONE ====="
done