forked from pieterlange/aws-dia-shapes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
123 lines (100 loc) · 3.96 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
.DEFAULT : build
.PHONY : build clean
.SUFFIXES :
.SECONDARY :
.POSIX :
.SILENT :
_svg_inputs_root := $(abspath ./tmp/svg)
_svg_inputs := $(wildcard $(_svg_inputs_root)/*.svg)
_eps_inputs_root := $(abspath ./eps)
_eps_inputs := $(wildcard $(_eps_inputs_root)/*.eps)
_outputs_root := $(abspath ./tmp/outputs)
_shapes_outputs_root := $(_outputs_root)/shapes
_shapes_sheet_output := $(_outputs_root)/shapes.sheet
build : $(_outputs_root)
clean :
test ! -e $(_outputs_root) || rm -R $(_outputs_root)
$(patsubst $(_svg_inputs_root)/%.svg, $(_shapes_outputs_root)/%.svg, $(_svg_inputs)) \
: $(_shapes_outputs_root)/%.svg \
: $(_svg_inputs_root)/%.svg makefile
$(info [xx] [sanitize] $(strip $(patsubst $(_outputs_root)/%, %, $(@))))
test ! -e $(@) || rm $(@)
test -e $(@D) || mkdir -p $(@D)
cp -T $(<) $(@)
cat <$(@) \
| tr '\t\n\r' ' ' \
| tr -s ' ' \
| sed -E -e 's!( *)<!\n<!g' -e 's!>( *)!>\n!g' \
| sed -E -e '/^$$/d' \
| cat >$(@)1
mv -T $(@)1 $(@)
$(_outputs_root) : $(patsubst $(_svg_inputs_root)/%.svg, $(_shapes_outputs_root)/%.svg, $(_svg_inputs))
$(patsubst $(_svg_inputs_root)/%.svg, $(_shapes_outputs_root)/%.shape, $(_svg_inputs)) \
: $(_shapes_outputs_root)/%.shape \
: $(_shapes_outputs_root)/%.svg makefile
$(info [xx] [create_shape] $(strip $(patsubst $(_outputs_root)/%, %, $(@))))
test ! -e $(@) || rm $(@)
test -e $(@D) || mkdir -p $(@D)
{ \
name="$$( basename -- $(@F) .shape | sed -r -e 's/AWS_Simple_Icons_//g' | tr '_' ' ' )" ; \
echo '<?xml version="1.0" encoding="UTF-8"?>' ; \
echo '<shape' ; \
echo ' xmlns="http://www.daa.com.au/~james/dia-shape-ns"' ; \
echo ' xmlns:svg="http://www.w3.org/2000/svg">' ; \
echo ' <name>'"$${name}"'</name>' ; \
echo ' <icon>$(strip $(patsubst %.shape, %.png, $(@F)))</icon>' ; \
echo ' <aspectratio type="fixed" /> ' ; \
echo ' <default-width>2</default-width>' ; \
echo ' <default-height>2</default-height>' ; \
echo ' <connections>' ; \
echo ' <point x="35" y="35" main="yes" />' ; \
echo ' </connections>' ; \
echo ' <textbox x1="0" x2="70" y1="0" y2="70" text="..." align="center" resize="no" />' ; \
sed -n -E \
-e '/^<\?xml/d' \
-e '/^<!DOCTYPE/d' \
-e '/^<!--/d' \
-e 's!<([^/:]+[ >])!<svg:\1!g' \
-e 's!</([^/:]+>)!</svg:\1!g' \
-e 's!fill="([^"]+)"!style="stroke: foreground; stroke-linecap: round; stroke-linejoin: round; fill: \1;"!g' \
-e 'p' \
<$(<) ; \
echo '</shape>' ; \
} >$(@)
$(_outputs_root) : $(patsubst $(_svg_inputs_root)/%.svg, $(_shapes_outputs_root)/%.shape, $(_svg_inputs))
$(patsubst $(_svg_inputs_root)/%.svg, $(_shapes_outputs_root)/%.png, $(_svg_inputs)) \
: $(_shapes_outputs_root)/%.png \
: $(_shapes_outputs_root)/%.svg makefile
$(info [xx] [create_png] $(strip $(patsubst $(_outputs_root)/%, %, $(@))))
test ! -e $(@) || rm $(@)
test -e $(@D) || mkdir -p $(@D)
convert -density 600 -resize 22x22 $(<) $(@)
$(_outputs_root) : $(patsubst $(_svg_inputs_root)/%.svg, $(_shapes_outputs_root)/%.png, $(_svg_inputs))
$(_shapes_sheet_output) : $(_svg_inputs) makefile
$(info [xx] [create_sheet] $(strip $(patsubst $(_outputs_root)/%, %, $(@))))
test ! -e $(@) || rm $(@)
test -e $(@D) || mkdir -p $(@D)
{ \
echo '<?xml version="1.0" encoding="utf-8"?>' ; \
echo '' ; \
echo '<sheet xmlns="http://www.lysator.liu.se/~alla/dia/dia-sheet-ns">' ; \
echo ' ' ; \
echo ' <name>AWS Simple Icons</name>' ; \
echo ' <description>AWS shapes</description>' ; \
echo ' ' ; \
echo ' <contents>' ; \
for shape in $(_svg_inputs) ; do \
name="$$( basename -- "$${shape}" .svg | sed -r -e 's/AWS_Simple_Icons_//g' | tr '_' ' ' )" ; \
echo ' <object name="'"$${name}"'"><description>'"$${name}"'</description></object>' ; \
done | sort ; \
echo ' </contents>' ; \
echo ' ' ; \
echo '</sheet>' ; \
} >$(@)
$(_outputs_root) : $(_shapes_sheet_output)
prepare:
./configure
install:
mkdir -p ~/.dia/shapes ~/.dia/sheets
cp -a $(_outputs_root)/shapes.sheet ~/.dia/sheets/AWS.sheet
cp -a $(_outputs_root)/shapes/* ~/.dia/shapes/