forked from koreader/koreader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
200 lines (167 loc) · 5.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
PHONY = all android-ndk android-sdk base clean distclean doc fetchthirdparty po pot re static-check
SOUND = $(INSTALL_DIR)/%
# koreader-base directory
KOR_BASE ?= base
include $(KOR_BASE)/Makefile.defs
RELEASE_DATE := $(shell git show -s --format=format:"%cd" --date=short HEAD)
# We want VERSION to carry the version of the KOReader main repo, not that of koreader-base
VERSION := $(shell git describe HEAD)
# Only append date if we're not on a whole version, like v2018.11
ifneq (,$(findstring -,$(VERSION)))
VERSION := $(VERSION)_$(RELEASE_DATE)
endif
# releases do not contain tests and misc data
IS_RELEASE := $(if $(or $(EMULATE_READER),$(WIN32)),,1)
IS_RELEASE := $(if $(or $(IS_RELEASE),$(APPIMAGE),$(LINUX),$(MACOS)),1,)
LINUX_ARCH?=native
ifeq ($(LINUX_ARCH), native)
LINUX_ARCH_NAME:=$(shell uname -m)
else ifeq ($(LINUX_ARCH), arm64)
LINUX_ARCH_NAME:=aarch64
else ifeq ($(LINUX_ARCH), arm)
LINUX_ARCH_NAME:=armv7l
endif
LINUX_ARCH_NAME?=$(LINUX_ARCH)
MACHINE=$(TARGET_MACHINE)
ifdef KODEBUG
MACHINE:=$(MACHINE)-debug
KODEDUG_SUFFIX:=-debug
endif
ifdef TARGET
DIST:=$(TARGET)
else
DIST:=emulator
endif
INSTALL_DIR ?= koreader-$(DIST)-$(MACHINE)
# platform directories
PLATFORM_DIR=platform
COMMON_DIR=$(PLATFORM_DIR)/common
WIN32_DIR=$(PLATFORM_DIR)/win32
define CR3GUI_DATADIR_EXCLUDES
%/KoboUSBMS.tar.gz
%/cr3.ini
%/cr3skin-format.txt
%/desktop
%/devices
%/manual
endef
CR3GUI_DATADIR_FILES = $(filter-out $(CR3GUI_DATADIR_EXCLUDES),$(wildcard $(CR3GUI_DATADIR)/*))
define DATADIR_FILES
$(CR3GUI_DATADIR_FILES)
$(OUTPUT_DIR_DATAFILES)
$(THIRDPARTY_DIR)/kpvcrlib/cr3.css
endef
# files to link from main directory
INSTALL_FILES=reader.lua setupkoenv.lua frontend resources defaults.lua datastorage.lua \
l10n tools README.md COPYING
OUTPUT_DIR_ARTIFACTS = $(abspath $(OUTPUT_DIR))/!(cache|cmake|data|history|staging|thirdparty)
OUTPUT_DIR_DATAFILES = $(wildcard $(OUTPUT_DIR)/data/*)
all: base
install -d $(INSTALL_DIR)/koreader
rm -f $(INSTALL_DIR)/koreader/git-rev; echo "$(VERSION)" > $(INSTALL_DIR)/koreader/git-rev
ifdef ANDROID
rm -f android-fdroid-version; echo -e "$(ANDROID_NAME)\n$(ANDROID_VERSION)" > koreader-android-fdroid-latest
endif
ifeq (,$(IS_RELEASE))
$(SYMLINK) $(KOR_BASE)/ev_replay.py $(INSTALL_DIR)/koreader/
endif
bash -O extglob -c '$(SYMLINK) $(OUTPUT_DIR_ARTIFACTS) $(INSTALL_DIR)/koreader/'
ifneq (,$(EMULATE_READER))
@echo "[*] install front spec only for the emulator"
$(SYMLINK) spec $(INSTALL_DIR)/koreader/spec/front
$(SYMLINK) test $(INSTALL_DIR)/koreader/spec/front/unit/data
endif
$(SYMLINK) $(INSTALL_FILES) $(INSTALL_DIR)/koreader/
ifdef ANDROID
$(SYMLINK) $(ANDROID_DIR)/*.lua $(INSTALL_DIR)/koreader/
endif
@echo "[*] Install update once marker"
@echo "# This file indicates that update once patches have not been applied yet." > $(INSTALL_DIR)/koreader/update_once.marker
ifdef WIN32
@echo "[*] Install runtime libraries for win32..."
$(SYMLINK) $(WIN32_DIR)/*.dll $(INSTALL_DIR)/koreader/
endif
ifdef SHIP_SHARED_STL
@echo "[*] Install C++ runtime..."
cp -fL $(SHARED_STL_LIB) $(INSTALL_DIR)/koreader/libs/
chmod 755 $(INSTALL_DIR)/koreader/libs/$(notdir $(SHARED_STL_LIB))
$(STRIP) --strip-unneeded $(INSTALL_DIR)/koreader/libs/$(notdir $(SHARED_STL_LIB))
endif
@echo "[*] Install plugins"
$(SYMLINK) plugins $(INSTALL_DIR)/koreader/
@echo "[*] Install resources"
$(SYMLINK) resources/fonts/* $(INSTALL_DIR)/koreader/fonts/
install -d $(INSTALL_DIR)/koreader/{screenshots,fonts/host,ota}
# Note: the data dir is distinct from the one in base/build/…!
@echo "[*] Install data files"
! test -L $(INSTALL_DIR)/koreader/data || rm $(INSTALL_DIR)/koreader/data
install -d $(INSTALL_DIR)/koreader/data
$(SYMLINK) $(strip $(DATADIR_FILES)) $(INSTALL_DIR)/koreader/data/
ifneq (,$(IS_RELEASE))
@echo "[*] Clean up, remove unused files for releases"
rm -rf $(INSTALL_DIR)/koreader/data/{cr3.ini,desktop,devices,dict,manual,tessdata}
endif
base: base-all
ifeq (,$(wildcard $(KOR_BASE)/Makefile $(KOR_BASE)/Makefile.defs))
$(KOR_BASE)/Makefile $(KOR_BASE)/Makefile.defs: fetchthirdparty
# Need a recipe, even if empty, or make won't know how to remake `base-all`.
endif
fetchthirdparty:
git submodule sync --recursive
ifneq (,$(CI))
git submodule update --depth 1 --jobs 3 --init --recursive
else
# Force shallow clones of submodules configured as such.
git submodule update --jobs 3 --depth 1 --init $(shell \
git config --file=.gitmodules --name-only --get-regexp '^submodule\.[^.]+\.shallow$$' true \
| sed 's/\.shallow$$/.path/' \
| xargs -n1 git config --file=.gitmodules \
)
# Update the rest.
git submodule update --jobs 3 --init --recursive
endif
clean: base-clean
rm -rf $(INSTALL_DIR)
distclean: clean base-distclean
$(MAKE) -C doc clean
re: clean
$(MAKE) all
# Include emulator specific rules.
ifneq (,$(EMULATE_READER))
include make/emulator.mk
endif
# Include target specific rules.
ifneq (,$(wildcard make/$(TARGET).mk))
include make/$(TARGET).mk
endif
android-ndk:
$(MAKE) -C $(KOR_BASE)/toolchain $(ANDROID_NDK_HOME)
android-sdk:
$(MAKE) -C $(KOR_BASE)/toolchain $(ANDROID_HOME)
# for gettext
DOMAIN=koreader
TEMPLATE_DIR=l10n/templates
XGETTEXT_BIN=xgettext
pot: po
mkdir -p $(TEMPLATE_DIR)
$(XGETTEXT_BIN) --from-code=utf-8 \
--keyword=C_:1c,2 --keyword=N_:1,2 --keyword=NC_:1c,2,3 \
--add-comments=@translators \
reader.lua `find frontend -iname "*.lua" | sort` \
`find plugins -iname "*.lua" | sort` \
`find tools -iname "*.lua" | sort` \
-o $(TEMPLATE_DIR)/$(DOMAIN).pot
po:
git submodule update --remote l10n
static-check:
@if which luacheck > /dev/null; then \
luacheck -q {reader,setupkoenv,datastorage}.lua frontend plugins spec; \
else \
echo "[!] luacheck not found. "\
"you can install it with 'luarocks install luacheck'"; \
fi
doc:
make -C doc
.NOTPARALLEL:
.PHONY: $(PHONY)
include $(KOR_BASE)/Makefile