-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
212 lines (177 loc) · 6.77 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
SHELL = bash
RM = rm -rvf
# Directory containing this Makefile. Don't change it. Default '$(REPODIR)'
REPODIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
# Which jekyll binary to use. Default '$(JEKYLL)'
JEKYLL = jekyll
# Where to build site. Default '$(DSTDIR)'
DSTDIR := $(REPODIR)/docs
# Where site is stored. Default '$(SRCDIR)'
SRCDIR := $(REPODIR)/site
# Repository with DITA source texts. Default: $(GTDIR)
GTDIR := $(REPODIR)/repo/gt-guidelines
# Host to serve from. Default: $(JEKYLL_HOST)
JEKYLL_HOST = 10.46.3.57
# Configuration file for ocrd-kwalitee. Default: $(KWALITEE_CONFIG)
KWALITEE_CONFIG := $(REPODIR)/kwalitee.yml
# Languages to build. Default: '$(LANGS)'
LANGS = de en
.PHONY: LANGS
# BEGIN-EVAL makefile-parser --make-help Makefile
help:
@echo ""
@echo " Targets"
@echo ""
@echo " deps-ubuntu ubuntu deps"
@echo " jekyll Install jekyll dependencies"
@echo " shinclude Install shinclude"
@echo " bootstrap Set up the repos, site and tools"
@echo " gt Build gt-guidelines. This takes a few minutes. Be patient."
@echo " build-modules TODO Build module information"
@echo " build-processors TODO Build processor information"
@echo " serve serve the site dynamically"
@echo " build-site build the site"
@echo " core-docs Build sphinx documentation for core"
@echo " spec Build the spec documents TODO translate"
@echo " workflows Rebuild the workflow document from wiki fragments"
@echo ""
@echo " Variables"
@echo ""
@echo " REPODIR Directory containing this Makefile. Don't change it. Default '$(REPODIR)'"
@echo " JEKYLL Which jekyll binary to use. Default '$(JEKYLL)'"
@echo " DSTDIR Where to build site. Default '$(DSTDIR)'"
@echo " SRCDIR Where site is stored. Default '$(SRCDIR)'"
@echo " GTDIR Repository with DITA source texts. Default: $(GTDIR)"
@echo " JEKYLL_HOST Host to serve from. Default: $(JEKYLL_HOST)"
@echo " KWALITEE_CONFIG Configuration file for ocrd-kwalitee. Default: $(KWALITEE_CONFIG)"
@echo " LANGS Languages to build. Default: '$(LANGS)'"
@echo " LANGS_DST Guideline langs to build. Default: $(GT_LANGS)"
# END-EVAL
# ubuntu deps
deps-ubuntu:
sudo apt-get install ruby-dev ruby-bundler
# Install jekyll dependencies
jekyll:
bundle config set --local path 'vendor/bundle'
bundle install
# Install shinclude
shinclude:
cd repo/shinclude; \
make install PREFIX=$(HOME)/.local
# Set up the repos, site and tools
bootstrap:
git submodule sync
git submodule update --init
bundle --version || "bundle is not available, try 'make deps-ubuntu'"
java -version || echo "java not available, needed for the GT guidelines. try 'sudo apt install openjdk-8-jre'"
pip3 --version || echo "pip3 not available, needed for kwalitee. try 'sudo apt install python3-pip' or activating a venv"
jekyll --version || echo "jekyll not available, try 'make jekyll'"
shinclude --help || echo "shinclude ist not available, try 'make shinclude'"
cd repo/ocrd-kwalitee && pip install -e .
cd $(GTDIR) && make deps
LANGS_DST = $(LANGS:%=$(SRCDIR)/%/gt-guidelines)
# Build gt-guidelines. This takes a few minutes. Be patient.
gt: $(LANGS_DST)
.PHONY: $(LANGS_DST)
$(LANGS_DST): $(SRCDIR)/%/gt-guidelines : $(GTDIR)/%
make -C "$(GTDIR)" ANT_OPTS="" LANG="$*" GT_DOC_OUT="$@" build; \
# Build ocrd-kwalitee data
# data: $(SRCDIR/_data/ocrd-repo.json
$(SRCDIR)/_data/ocrd-repo.json: $(KWALITEE_CONFIG)
mkdir -p $(dir $@)
ocrd-kwalitee -c "$(KWALITEE_CONFIG)" json > "$@"
.PHONY: ocrd-all-tool
ocrd-all-tool: $(SRCDIR)/js/ocrd-all-tool.json
$(SRCDIR)/js/ocrd-all-tool.json: $(KWALITEE_CONFIG)
mkdir -p $(dir $@)
ocrd-kwalitee -c "$(KWALITEE_CONFIG)" ocrd-tool > "$@"
# TODO Build module information
build-modules: ocrd-kwalitee.json
@echo NIH
# TODO Build processor information
build-processors:
@echo NIH
# serve the site dynamically
serve:
bundle exec jekyll serve \
--baseurl '' \
--host $(JEKYLL_HOST) \
--port 4040 \
--trace \
--watch \
--strict_front_matter \
-s '$(SRCDIR)' -d '$(DSTDIR)'
# build the site
build-site:
bundle exec jekyll build \
--strict_front_matter \
-s '$(SRCDIR)' -d '$(DSTDIR)'
deploy:
cd repo/ocr-d.github.io; \
git clean -df; \
git checkout .; \
git checkout master; \
git pull
cp -r docs/* repo/ocr-d.github.io
cd repo/ocr-d.github.io; \
git add .; \
git commit -m "Update `date`" ;\
git push;
git add .
git commit -m "Update `date`" ;\
git push
# Build sphinx documentation for core
core-docs:
make -C repo/core docs
rm -rf site/core
mkdir site/core
mv repo/core/docs/build/html/* site/core
# Build the spec documents TODO translate
spec:
python3 yaml-to-json.py --indent 0 repo/spec/ocrd_tool.schema.yml repo/spec/ocrd_tool.schema.json
python3 yaml-to-json.py --indent 0 repo/spec/bagit-profile.yml repo/spec/bagit-profile.json
# -cd repo/spec; traf -o json gt-profile.yml
# -cd repo/spec; traf -o json single-line.yml
# -cd repo/spec; traf -o json training-schema.yml
# -cd repo/spec; traf -o json model-evaluation-schema.yml
cd repo/spec; shinclude -c xml -i cli.md 2>/dev/null
cd repo/spec; shinclude -c xml -i ocrd_tool.md 2>/dev/null
cd repo/spec; shinclude -c xml -i ocrd_zip.md 2>/dev/null
mkdir -p $(SRCDIR)/en/spec $(SRCDIR)/de/spec; \
find repo/spec -name '*.md'|while read md;do \
basename=$$(basename $$md); \
title=$$(grep --max-count 1 '^# ' $$md|sed 's,# ,,'); \
lang="en"; \
if [[ "$$md" = *.de.md ]];then \
basename=$$(basename $$md|sed 's,\.de\.md,.md,'); \
lang="de"; \
fi; \
sed "1 i ---\nlayout: page\nlang: $$lang\nlang-ref: $$basename\ntoc: true\ntitle: $$title\n---\n" $$md \
> $(SRCDIR)/$$lang/spec/$$basename; \
done;
cp -t $(SRCDIR)/en/spec repo/spec/bagit-profile.json
cp -t $(SRCDIR)/en/spec repo/spec/ocrd_tool.schema.json
cp -t $(SRCDIR)/en/spec repo/spec/openapi.yml
cp -t $(SRCDIR)/de/spec repo/spec/bagit-profile.json
cp -t $(SRCDIR)/de/spec repo/spec/ocrd_tool.schema.json
cp -t $(SRCDIR)/de/spec repo/spec/openapi.yml
cp -t $(SRCDIR)/assets repo/spec/assets/*
.PHONY: workflows
# Rebuild the workflow document from wiki fragments
workflows: site/en/workflows.md
site/en/workflows.md: site/en/workflows.src.md $(wildcard repo/ocrd-website.wiki/Workflow-Guide-*.md)
SHLOG_TERM=info shinclude -c xml site/en/workflows.src.md > $@
@echo "!!!"
@echo "!!! Manually edit site/en/workflows.md before comitting!"
@echo "!!!"
shortcuts:
mkdir -p site/goto
while read line;do \
slug_and_url=($${line}); \
slug=$${slug_and_url[0]}; \
url=$${slug_and_url[1]}; \
dir=site/goto/$$slug; \
index_html=$$dir/index.html; \
mkdir -p $$dir; \
sed "s,{{ url }},$$url,g" shortcuts.template.html > $$index_html; \
done < shortcuts.txt