This repository has been archived by the owner on Jun 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
134 lines (88 loc) · 3.09 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
# Makefile for ubiquity-slideshow-ubuntu
SLIDESHOWS = \
ubuntu \
kubuntu \
xubuntu \
ubuntustudio \
ubuntu-budgie \
ubuntukylin \
ubuntu-mate \
oem-config-ubuntu \
oem-config-ubuntu-mate \
oem-config-ubuntu-budgie
SOURCE ?= .
SOURCESLIDES ?= $(SOURCE)/slideshows
BUILD ?= $(SOURCE)/build
PO4A_FLAGS = -M UTF-8 -f xhtml -o attributes="data-translate"
find-slides = $(filter-out %/index.html,$(wildcard $1/*.html))
find-slidenames = $(notdir $(call find-slides,$(SOURCESLIDES)/$1/slides))
find-locales = $(basename $(notdir $(wildcard po/$1/*.po)))
.PHONY: all
all: build.slideshows
.PHONY: pot
.PHONY: clean
clean:
-rm -rf $(_ALL_TMP_DIRS) $(BUILD)
.PHONY: test
test: build
./test-slideshow.sh
$(BUILD):
mkdir -p $(BUILD)
.PHONY: build.slideshows
define MAKE-SLIDESHOW
# Per-slideshow build
_SOURCE_FILES_$(1) := $$(shell find -L $(SOURCESLIDES)/$(1) -type f)
_BUILD_FILES_$(1) := $$(patsubst $(SOURCESLIDES)/%,$(BUILD)/%,$$(_SOURCE_FILES_$(1)))
_ALL_TMP_DIRS += $(BUILD)/$1
build.slideshows: build.$1
.PHONY: build.$1
build.$1: build.base.$1 build.l10n.$1
.PHONY: build.base.$1
build.base.$1: $$(_BUILD_FILES_$(1))
.PHONY: build.l10n.$1
build.l10n.$1: build.base.$1
./build-directory-jsonp.py $(BUILD)/$1/slides/l10n > $(BUILD)/$1/slides/directory.jsonp
# Per-slideshow pot file creation
_ALL_TMP_DIRS += po/$1/.tmp
pot: po/$1/slideshow-$1.pot
po/$1/slideshow-$1.pot: $(addsuffix .pot,$(addprefix po/$1/.tmp/,$(call find-slidenames,$1)))
msgcat -F $$^ > $$@
po/$1/.tmp/%.pot: $(SOURCESLIDES)/$1/slides/% | po/$1/.tmp
po4a-updatepo $(PO4A_FLAGS) -m $$^ -p $$@
po/$1/.tmp:
mkdir -p po/$1/.tmp
# Per-slideshow test scripts
.PHONY: $(SLIDESHOWS)
$(SLIDESHOWS): %: build.%
.PHONY: test.$1
test.$1: build.base.$1
./Slideshow.py --path="$(BUILD)/$1" --controls
$(foreach p,$(call find-locales,$1),$(eval $(call MAKE-SLIDESHOW-LOCALE,$1,$p)))
endef
define MAKE-SLIDESHOW-LOCALE
# Per-locale per-slideshow build
# By creating a different target for each locale, parallel build works as expected.
build.l10n.$1: build.l10n.$1.$2
.PHONY: build.l10n.$1.$2
build.l10n.$1.$2: $(addprefix $(BUILD)/$1/slides/l10n/$2/,$(call find-slidenames,$1))
rmdir --ignore-fail-on-non-empty $(BUILD)/$1/slides/l10n/$2
$(BUILD)/$1/slides/l10n/$2/%: $(SOURCESLIDES)/$1/slides/% po/$1/$2.po | $(BUILD)/$1/slides/l10n/$2
po4a-translate $(PO4A_FLAGS) --keep=1 --master=$$< --po=po/$1/$2.po --localized=$$@
$(BUILD)/$1/slides/l10n/$2:
# translate all slides inside this locale
mkdir -p $$@
# Per-locale per-slideshow test scripts
test.$1.$2: build.base.$1 build.l10n.$1.$2
./build-directory-jsonp.py $(BUILD)/$1/slides/l10n > $(BUILD)/$1/slides/directory.jsonp
./Slideshow.py --path="$(BUILD)/$1" --controls --locale=$2
test.$1.$2.rtl: build.base.$1 build.l10n.$1.$2
./build-directory-jsonp.py $(BUILD)/$1/slides/l10n > $(BUILD)/$1/slides/directory.jsonp
./Slideshow.py --path="$(BUILD)/$1" --controls --locale=$2 --rtl
endef
$(foreach s,$(SLIDESHOWS),$(eval $(call MAKE-SLIDESHOW,$s)))
$(BUILD)/%: $(SOURCESLIDES)/% | $(BUILD)
mkdir -p $(@D)
cp $^ $@
$(BUILD)/%.js: $(SOURCESLIDES)/%.js | $(BUILD)
mkdir -p $(@D)
cp $^ $@