-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
145 lines (118 loc) · 6.92 KB
/
Makefile
File metadata and controls
145 lines (118 loc) · 6.92 KB
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
# Detect Python: try venv/bin/python, venv/bin/python3, then system python3
PYTHON=$(shell if [ -x venv/bin/python ]; then echo venv/bin/python; elif [ -x venv/bin/python3 ]; then echo venv/bin/python3; else echo python3; fi)
# Edition definitions
EDITIONS = bereanbible majoritybible
bereanbible_URL = https://bereanbible.com/bsb_tables.tsv
bereanbible_ID = BSB
bereanbible_SENTINEL = GEN
majoritybible_URL = https://majoritybible.com/msb_nt_tables.tsv
majoritybible_ID = MSB
majoritybible_SENTINEL = MAT
# PHONY targets that don't represent files
.PHONY: all clean clean-cache force bereanbible majoritybible
all: bereanbible majoritybible
# Per-edition top-level targets
define EDITION_TARGETS
$(1): $(1)/results/$($(1)_SENTINEL).usfm \
$(1)/results/int/$(call sentinel_int,$(1)).usfm \
$(1)/results/strongs/$(call sentinel_strongs,$(1)).usfm \
$(1)/results/strongs_full/$(call sentinel_full,$(1)).usfm \
$(1)/results_usj/$($(1)_SENTINEL).usj \
$(1)/results_usj/int/$(call sentinel_int,$(1)).usj \
$(1)/results_usj/strongs/$(call sentinel_strongs,$(1)).usj \
$(1)/results_usj/strongs_full/$(call sentinel_full,$(1)).usj \
$(1)/results_usx/$($(1)_SENTINEL).usx \
$(1)/results_usx/int/$(call sentinel_int,$(1)).usx \
$(1)/results_usx/strongs/$(call sentinel_strongs,$(1)).usx \
$(1)/results_usx/strongs_full/$(call sentinel_full,$(1)).usx
$$(PYTHON) adapt_usx_for_DBL.py $(1)/results_usx -o $(1)/results_usx_for_DBL
$$(PYTHON) adapt_usfm_for_paratext.py $(1)/results -o $(1)/results_for_paratext --identifier $($(1)_ID)
$$(PYTHON) create_zips.py --base-dir $(1) --identifier $($(1)_ID)
endef
# Helper functions for sentinel filenames
sentinel_int = $(call _bookcode,$(1))$($(1)_SENTINEL)$($(1)_ID)_int
sentinel_strongs = $(call _bookcode,$(1))$($(1)_SENTINEL)$($(1)_ID)_strongs
sentinel_full = $(call _bookcode,$(1))$($(1)_SENTINEL)$($(1)_ID)_full_strongs
_bookcode = $(if $(filter GEN,$($(1)_SENTINEL)),01,40)
# Generate edition targets
$(foreach ed,$(EDITIONS),$(eval $(call EDITION_TARGETS,$(ed))))
# Per-edition cache management
define EDITION_CACHE
$(1)/temp/source.tsv: | $(1)/temp
@echo "Checking for updates from $($(1)_URL)..."
@if [ -f "$$@" ]; then \
curl -s -z "$$@" -o "$$@.tmp" "$($(1)_URL)"; \
if [ -f "$$@.tmp" ]; then \
echo "Remote file has been updated, using new version"; \
mv "$$@.tmp" "$$@"; \
else \
echo "Using cached version (remote not modified)"; \
fi \
else \
echo "Downloading $($(1)_URL) for the first time..."; \
curl -s -o "$$@" "$($(1)_URL)"; \
fi
$(1)/temp:
mkdir -p $(1)/temp
endef
$(foreach ed,$(EDITIONS),$(eval $(call EDITION_CACHE,$(ed))))
# Per-edition build rules
define EDITION_RULES
# Basic USFM
$(1)/results/$($(1)_SENTINEL).usfm: bsb2usfm.py $(1)/temp/source.tsv
mkdir -p $(1)/results
- $$(PYTHON) bsb2usfm.py --identifier $($(1)_ID) -o $(1)/results/%.usfm -f demo_data/sample_footnotes.tsv -n demo_data/sample_book_names.xml $(1)/temp/source.tsv
# Interlinear USFM
$(1)/results/int/$(call sentinel_int,$(1)).usfm: bsb2usfm.py $(1)/temp/source.tsv
mkdir -p $(1)/results/int
- $$(PYTHON) bsb2usfm.py --identifier $($(1)_ID) -I -o $(1)/results/int/^%$($(1)_ID)_int.usfm -f demo_data/sample_footnotes.tsv -n demo_data/sample_book_names.xml $(1)/temp/source.tsv
# Strongs USFM
$(1)/results/strongs/$(call sentinel_strongs,$(1)).usfm: bsb2usfm.py $(1)/temp/source.tsv
mkdir -p $(1)/results/strongs
$$(PYTHON) bsb2usfm.py --identifier $($(1)_ID) -S -o $(1)/results/strongs/^%$($(1)_ID)_strongs.usfm -f demo_data/sample_footnotes.tsv -n demo_data/sample_book_names.xml $(1)/temp/source.tsv
# Strongs full USFM
$(1)/results/strongs_full/$(call sentinel_full,$(1)).usfm: bsb2usfm.py $(1)/temp/source.tsv
mkdir -p $(1)/results/strongs_full
$$(PYTHON) bsb2usfm.py --identifier $($(1)_ID) -S -P -B -o $(1)/results/strongs_full/^%$($(1)_ID)_full_strongs.usfm -f demo_data/sample_footnotes.tsv -n demo_data/sample_book_names.xml $(1)/temp/source.tsv
# Basic USJ
$(1)/results_usj/$($(1)_SENTINEL).usj: bsb2usfm.py $(1)/temp/source.tsv
mkdir -p $(1)/results_usj
- $$(PYTHON) bsb2usfm.py --identifier $($(1)_ID) -o $(1)/results_usj/%.usj -f demo_data/sample_footnotes.tsv -n demo_data/sample_book_names.xml $(1)/temp/source.tsv
# Interlinear USJ
$(1)/results_usj/int/$(call sentinel_int,$(1)).usj: bsb2usfm.py $(1)/temp/source.tsv
mkdir -p $(1)/results_usj/int
- $$(PYTHON) bsb2usfm.py --identifier $($(1)_ID) -I -o $(1)/results_usj/int/^%$($(1)_ID)_int.usj -f demo_data/sample_footnotes.tsv -n demo_data/sample_book_names.xml $(1)/temp/source.tsv
# Strongs USJ
$(1)/results_usj/strongs/$(call sentinel_strongs,$(1)).usj: bsb2usfm.py $(1)/temp/source.tsv
mkdir -p $(1)/results_usj/strongs
$$(PYTHON) bsb2usfm.py --identifier $($(1)_ID) -S -o $(1)/results_usj/strongs/^%$($(1)_ID)_strongs.usj -f demo_data/sample_footnotes.tsv -n demo_data/sample_book_names.xml $(1)/temp/source.tsv
# Strongs full USJ
$(1)/results_usj/strongs_full/$(call sentinel_full,$(1)).usj: bsb2usfm.py $(1)/temp/source.tsv
mkdir -p $(1)/results_usj/strongs_full
$$(PYTHON) bsb2usfm.py --identifier $($(1)_ID) -S -P -B -o $(1)/results_usj/strongs_full/^%$($(1)_ID)_full_strongs.usj -f demo_data/sample_footnotes.tsv -n demo_data/sample_book_names.xml $(1)/temp/source.tsv
# Basic USX
$(1)/results_usx/$($(1)_SENTINEL).usx: bsb2usfm.py $(1)/temp/source.tsv
mkdir -p $(1)/results_usx
- $$(PYTHON) bsb2usfm.py --identifier $($(1)_ID) -o $(1)/results_usx/%.usx -f demo_data/sample_footnotes.tsv -n demo_data/sample_book_names.xml $(1)/temp/source.tsv
# Interlinear USX
$(1)/results_usx/int/$(call sentinel_int,$(1)).usx: bsb2usfm.py $(1)/temp/source.tsv
mkdir -p $(1)/results_usx/int
- $$(PYTHON) bsb2usfm.py --identifier $($(1)_ID) -I -o $(1)/results_usx/int/^%$($(1)_ID)_int.usx -f demo_data/sample_footnotes.tsv -n demo_data/sample_book_names.xml $(1)/temp/source.tsv
# Strongs USX
$(1)/results_usx/strongs/$(call sentinel_strongs,$(1)).usx: bsb2usfm.py $(1)/temp/source.tsv
mkdir -p $(1)/results_usx/strongs
$$(PYTHON) bsb2usfm.py --identifier $($(1)_ID) -S -o $(1)/results_usx/strongs/^%$($(1)_ID)_strongs.usx -f demo_data/sample_footnotes.tsv -n demo_data/sample_book_names.xml $(1)/temp/source.tsv
# Strongs full USX
$(1)/results_usx/strongs_full/$(call sentinel_full,$(1)).usx: bsb2usfm.py $(1)/temp/source.tsv
mkdir -p $(1)/results_usx/strongs_full
$$(PYTHON) bsb2usfm.py --identifier $($(1)_ID) -S -P -B -o $(1)/results_usx/strongs_full/^%$($(1)_ID)_full_strongs.usx -f demo_data/sample_footnotes.tsv -n demo_data/sample_book_names.xml $(1)/temp/source.tsv
endef
$(foreach ed,$(EDITIONS),$(eval $(call EDITION_RULES,$(ed))))
# Force update by removing cache and rebuilding
force: clean-cache all
# Clean generated output files
clean:
$(foreach ed,$(EDITIONS),rm -rf $(ed)/results $(ed)/results_usj $(ed)/results_usx $(ed)/results_usx_for_DBL $(ed)/results_for_paratext $(ed)/sfm_for_paratext $(ed)/workspace;)
# Clean the cached data files to force re-download
clean-cache:
$(foreach ed,$(EDITIONS),rm -f $(ed)/temp/source.tsv;)