blob: 7d387945f75bfa40a8e3dafb32a9d64b794f98b4 (
plain)
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
# prerequisities:
# - xsltproc
# - inkscape
# - isaviz (http://www.w3.org/2001/11/IsaViz/)
#DEBUG = 1
ifndef DEBUG
DEBUG = 0
endif
ifeq (${DEBUG},0)
DEBUG_RM_DEP = rm -f -- $<
else
DEBUG_RM_DEP =
endif
ONTOGEN_dir ?= ontogen
HTML_NSSCHEMAXSL_file = ${ONTOGEN_dir}/ns-schema.xsl
RDF_ISAVIZPREPROCESSXSL_file = ${ONTOGEN_dir}/isaviz-preprocess.xsl
RDF_ISAVIZPOSTPROCESSXSL_file = ${ONTOGEN_dir}/isaviz-postprocess.xsl
SVG_ISAVIZ_path ?= ~/wrkspc/sw/IsaViz
SVG_ISAVIZ_runner ?= ./run.sh
SVG_ISAVIZ_cfg = ~/isaviz.cfg
SVG_ISAVIZ_font = Liberation Mono
SVG_ISAVIZ_fontsize = 10
# LR or TB (not recommended)
SVG_ISAVIZ_orientation = LR
SVG_ISAVIZ_charcount = 30
SVG_BIGGERXSL_url = http://inkscape-forum.andreas-s.net/attachment/2730/bigger.xsl
#SVG_BIGGERXSL_url = http://sourceforge.net/mailarchive/attachment.php?list_name=inkscape-user&message_id=20080925142218.2ba4194e%40nrri.umn.edu
#SVG_BIGGERXSL_file ?= $(shell \
# wget -nv -nc --content-disposition --delete-after ${SVG_BIGGERXSL_url} \
# | cut -d' ' -f6 \
#)
SVG_BIGGERXSL_file = bigger.xsl
SVG_BIGGERXSL_scale = 0.9
TARGETS_PY = $(shell \
find -maxdepth 1 -name '*.py' -and -executable -and -type f -printf '%f\n' \
)
TARGETS = $(TARGETS_PY:.py=)
REMOVE = ${TARGETS:=.requires} ${TARGETS:=.1.rdf} ${TARGETS:=.1.svg} ${TARGETS:=.2.svg}
REMOVE_SYMLINKS = ${TARGETS:=.rdf} ${TARGETS:=.html} ${TARGETS:=.svg}
.PHONY = ${TARGETS} clean mrproper
# top-level wrapper
${TARGETS}: %: %.requires
${DEBUG_RM_DEP}
ifneq ($(MAKECMDGOALS),clean)
$(foreach target,${TARGETS},$(eval -include ${target:=.requires}))
endif
# rdf + html
$(TARGETS:=.requires): %.requires: %.rdf
touch $<
$(TARGETS:=.rdf) : %.rdf: %.py
./$< AUTO | grep -E '^self-figure: ' | cut -d' ' -f2 \
| xargs -I'{}' find -L {} -printf '$(@:.rdf=): %f\n' \
>> $(@:.rdf=.requires)
# ^ -not/-empty condition?
# only used if html accidentally deleted and rdf kept
$(TARGETS:=.html):: %.html: %.rdf
xsltproc --stringparam xmlfile $< ${HTML_NSSCHEMAXSL_file} $< > $@
$(TARGETS:=.svg): %.svg: %.2.svg ${SVG_BIGGERXSL_file}
xsltproc --stringparam scale ${SVG_BIGGERXSL_scale} \
${SVG_BIGGERXSL_file} $< > $@
inkscape $@ --verb FitCanvasToDrawing --verb FileVacuum \
--verb FileSave --verb FileClose
${DEBUG_RM_DEP}
$(TARGETS:=.1.rdf): %.1.rdf: %.rdf ${RDF_ISAVIZPREPROCESSXSL_file}
xsltproc ${RDF_ISAVIZPREPROCESSXSL_file} $< > $@
$(TARGETS:=.2.svg): %.2.svg: %.1.svg ${RDF_ISAVIZPOSTPROCESSXSL_file}
xsltproc ${RDF_ISAVIZPOSTPROCESSXSL_file} $< > $@
${DEBUG_RM_DEP}
$(TARGETS:=.1.svg): %.svg: %.rdf ${SVG_ISAVIZ_path}/${SVG_ISAVIZ_runner}
@echo " Sorry, this part currently requires manual actions:"
@echo " 1. File - Import - Replace - RDF/XML from file: $<"
@echo " 2. View - Suggest Layout (only to get a better form; 14pt?)"
@echo " 3. Optionally increase font size for better final look"
@echo " via Edit - Preferences - Rendering/GSS"
@echo " 4. Export - SVG: $@"
mv ${SVG_ISAVIZ_cfg} ${SVG_ISAVIZ_cfg}.$(@:.1.svg=) || :
touch ${SVG_ISAVIZ_cfg}
echo '<?xml version="1.0" encoding="UTF-8"?>' >>${SVG_ISAVIZ_cfg}
echo '<isv:config xmlns:isv="http://www.w3.org/2001/10/IsaViz">' >>${SVG_ISAVIZ_cfg}
echo ' <isv:directories>' >>${SVG_ISAVIZ_cfg}
echo ' <isv:tmpDir value="true">/tmp</isv:tmpDir>' >>${SVG_ISAVIZ_cfg}
echo ' <isv:projDir>/tmp</isv:projDir>' >>${SVG_ISAVIZ_cfg}
echo ' <isv:rdfDir>$(CURDIR)</isv:rdfDir>' >>${SVG_ISAVIZ_cfg}
echo ' <isv:dotExec>/bin/dot</isv:dotExec>' >>${SVG_ISAVIZ_cfg}
#echo ' <isv:graphvizFontDir>/tmp</isv:graphvizFontDir>' >>${SVG_ISAVIZ_cfg}
echo ' </isv:directories>' >>${SVG_ISAVIZ_cfg}
echo ' <isv:constants abbrevSyntax="true"' >>${SVG_ISAVIZ_cfg}
echo ' alwaysIncludeLang="false"' >>${SVG_ISAVIZ_cfg}
echo ' anonymousNodes="genid:"' >>${SVG_ISAVIZ_cfg}
echo ' antialiasing="false"' >>${SVG_ISAVIZ_cfg}
echo ' backgroundColor="-1579033"' >>${SVG_ISAVIZ_cfg}
echo ' defaultLang="en"' >>${SVG_ISAVIZ_cfg}
echo ' defaultNamespace=""' >>${SVG_ISAVIZ_cfg}
echo ' displayLabels="false"' >>${SVG_ISAVIZ_cfg}
echo ' graphFont="${SVG_ISAVIZ_font} Plain ${SVG_ISAVIZ_fontsize}"' \
>>${SVG_ISAVIZ_cfg}
echo ' graphOrient="${SVG_ISAVIZ_orientation}"' >>${SVG_ISAVIZ_cfg}
echo ' incGSSstyling="false"' >>${SVG_ISAVIZ_cfg}
echo ' maxLitCharCount="${SVG_ISAVIZ_charcount}"' >>${SVG_ISAVIZ_cfg}
echo ' parsingMode="0"' >>${SVG_ISAVIZ_cfg}
echo ' prefixInTf="true"' >>${SVG_ISAVIZ_cfg}
echo ' saveWindowLayout="false"' >>${SVG_ISAVIZ_cfg}
echo ' showAnonIds="false" swingFont="SansSerif Plain 12"/>' \
>>${SVG_ISAVIZ_cfg}
echo '</isv:config>' >>${SVG_ISAVIZ_cfg}
pushd ${SVG_ISAVIZ_path} 2>/dev/null && \
( cat ${SVG_ISAVIZ_runner} \
| sed 's|\(ISAVIZ_HOME=\).*|\1${SVG_ISAVIZ_path}|' \
| sh || : ) && popd 2>/dev/null
mv ${SVG_ISAVIZ_cfg}.$(@:.1.svg=) ${SVG_ISAVIZ_cfg} || rm -f ${SVG_ISAVIZ_cfg}
${DEBUG_RM_DEP}
${SVG_BIGGERXSL_file}:
wget -nv -nc --content-disposition ${SVG_BIGGERXSL_url} -O- > $@
clean:
for f in ${REMOVE_SYMLINKS}; do rm -f -- $$(readlink $$f) $$f; done
rm -f -- ${REMOVE}
mrproper: clean
rm -f -- ${SVG_BIGGERXSL_file}
|