1 |
# Makefile for the Gallery images on the Sketch homepage |
2 |
# |
3 |
|
4 |
# All the gallery files are generated from pairs of sk-files and readme |
5 |
# files. The rendering process involves relatively large intermediate |
6 |
# PPM files which are not automatically removed. You may want to do that |
7 |
# by hand occasionally. |
8 |
|
9 |
# Directory where the .sk and .readme files can be found |
10 |
SRCDIR = src |
11 |
|
12 |
# |
13 |
# Tools Configuration |
14 |
# |
15 |
|
16 |
# program to convert .sk files to ppm |
17 |
SK2PPM = sk2ppm |
18 |
|
19 |
# program to convert ppm to jpeg |
20 |
CJPEG = cjpeg |
21 |
|
22 |
# program to scale a ppm file |
23 |
PNMSCALE = pnmscale |
24 |
|
25 |
# The Gallery images. These are the basenames of the .sk and .readme |
26 |
# files in $(SRCDIR). They're grouped by artist with MISC as the catch |
27 |
# all. |
28 |
APASCUAL = coco nana portrait SimcaSP moniteur Affiche4 Distribution Simca8 |
29 |
WOJTKIEWICZ = bathead fruitscene kapelusznica |
30 |
HARA = trem01 raposa |
31 |
TATANE = avion cartes compo helicoptere photo pomme vache |
32 |
BIDDIER = southern_bell southern_cop smile_n_jack under_da_sea |
33 |
THILBRICHT = waratah |
34 |
STOVICEK = stay_with_us anna04 |
35 |
MISC = bsddaemon penguin sun |
36 |
|
37 |
# list of all drawing basenames to process |
38 |
DRAWINGS = $(APASCUAL) $(WOJTKIEWICZ) $(HARA) $(TATANE) $(BIDDIER) \ |
39 |
$(THILBRICHT) $(STOVICEK) $(MISC) |
40 |
|
41 |
# list of all the tarfiles |
42 |
TARFILES = $(DRAWINGS:%=%.tar.gz) |
43 |
# list of all the jpg images |
44 |
IMAGES = $(DRAWINGS:%=%.jpg) |
45 |
|
46 |
# Resolution of the rendered .sk files in ppi |
47 |
FULL_RESOLUTION = 144 |
48 |
|
49 |
# number of gradient steps when rendering |
50 |
GRADIENT_STEPS = 100 |
51 |
|
52 |
# Command to scale the rendered PPM file to a more suitable size for the |
53 |
# full image |
54 |
FULL_SCALE = $(PNMSCALE) 0.4 |
55 |
|
56 |
# scale factor for the preview thumbnail |
57 |
PREVIEW_FACTOR = -height 150 |
58 |
|
59 |
# cjpeg options for the full-scale images |
60 |
LARGE_JPEG_OPTS = -quality 80 |
61 |
|
62 |
# Some images need some special options or extra processing. To |
63 |
# facilitate this, the makefile uses variables with the form |
64 |
# <basename>_sk2ppmopt and <basename>_previewfilter. <basename> is the |
65 |
# basename of the sk-file being processed. |
66 |
# |
67 |
# The *_sk2ppmopt variables control the rendering of sk-files to ppm. |
68 |
# Normally, the bounding box of an image determines the region of the |
69 |
# drawing that is rendered. If the *_sk2ppmopt variable's value is page, |
70 |
# then the page is used as the region. |
71 |
# |
72 |
# The *_previewfilter are an additional filtering step for the generated |
73 |
# previews. Their value should be a command that accepts a PPM file on |
74 |
# stdin and writes a PPM file to stdout. The command should end in a |
75 |
# pipe symbol. The output is the input to the cjpeg program which writes |
76 |
# the preview image. |
77 |
coco_sk2ppmopt = page |
78 |
moniteur_previewfilter = pnmcrop -black | |
79 |
coco_previewfilter = pnmcrop -black | |
80 |
bathead_previewfilter = pnmcrop -black | |
81 |
|
82 |
|
83 |
# the intermediate ppm files should not be removed automatically because |
84 |
# they're relatively expensive to create. |
85 |
.PRECIOUS: %.ppm |
86 |
|
87 |
all: $(IMAGES) $(TARFILES) |
88 |
|
89 |
%.jpg: %.ppm |
90 |
$(PNMSCALE) $(PREVIEW_FACTOR) $< | $($*_previewfilter) \ |
91 |
$(CJPEG) > small$@ \ |
92 |
|| rm -f small$@ |
93 |
$(FULL_SCALE) $< | $(CJPEG) $(LARGE_JPEG_OPTS) > $@ || rm -f $@ |
94 |
|
95 |
%.ppm: $(SRCDIR)/%.sk |
96 |
$(SK2PPM) --resolution=$(FULL_RESOLUTION) \ |
97 |
--gradient-steps=$(GRADIENT_STEPS) \ |
98 |
$(shell if [ "$($*_sk2ppmopt)" == "page" ]; \ |
99 |
then echo ''; else echo '--bbox'; fi) \ |
100 |
$< $@ |
101 |
|
102 |
%.tar.gz: $(SRCDIR)/%.sk $(SRCDIR)/%.readme |
103 |
tar cvzf $@ $^ |
104 |
|
105 |
|
106 |
|
107 |
clean: |
108 |
rm -f $(IMAGES) $(IMAGES:%=small%) $(TARFILES) |
109 |
|
110 |
clobber: clean |
111 |
rm -f *.ppm |