2024-07-30 23:55:37 +00:00
|
|
|
PHONY = all android-ndk android-sdk base clean coverage distclean doc fetchthirdparty po pot re static-check test testbase testfront
|
2024-07-30 23:55:36 +00:00
|
|
|
SOUND = $(INSTALL_DIR)/%
|
2024-05-29 18:15:29 +00:00
|
|
|
|
2013-03-24 21:27:20 +00:00
|
|
|
# koreader-base directory
|
2024-07-30 23:55:36 +00:00
|
|
|
KOR_BASE ?= base
|
2013-03-24 21:27:20 +00:00
|
|
|
|
2024-05-11 18:12:42 +00:00
|
|
|
include $(KOR_BASE)/Makefile.defs
|
2013-03-24 21:04:32 +00:00
|
|
|
|
2024-05-18 11:21:59 +00:00
|
|
|
RELEASE_DATE := $(shell git show -s --format=format:"%cd" --date=short HEAD)
|
2018-10-31 22:34:11 +00:00
|
|
|
# We want VERSION to carry the version of the KOReader main repo, not that of koreader-base
|
2024-05-18 11:21:59 +00:00
|
|
|
VERSION := $(shell git describe HEAD)
|
2018-10-31 22:34:11 +00:00
|
|
|
# Only append date if we're not on a whole version, like v2018.11
|
|
|
|
ifneq (,$(findstring -,$(VERSION)))
|
2024-05-18 11:21:59 +00:00
|
|
|
VERSION := $(VERSION)_$(RELEASE_DATE)
|
2018-10-31 22:34:11 +00:00
|
|
|
endif
|
2013-03-24 14:08:42 +00:00
|
|
|
|
2020-05-14 12:26:00 +00:00
|
|
|
# releases do not contain tests and misc data
|
|
|
|
IS_RELEASE := $(if $(or $(EMULATE_READER),$(WIN32)),,1)
|
2024-05-13 10:11:11 +00:00
|
|
|
IS_RELEASE := $(if $(or $(IS_RELEASE),$(APPIMAGE),$(LINUX),$(MACOS)),1,)
|
2020-05-14 12:26:00 +00:00
|
|
|
|
2024-05-13 10:11:11 +00:00
|
|
|
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)
|
|
|
|
|
|
|
|
|
2024-05-11 18:12:42 +00:00
|
|
|
MACHINE=$(TARGET_MACHINE)
|
2017-10-27 18:36:36 +00:00
|
|
|
ifdef KODEBUG
|
|
|
|
MACHINE:=$(MACHINE)-debug
|
2019-08-26 18:29:08 +00:00
|
|
|
KODEDUG_SUFFIX:=-debug
|
2017-10-27 18:36:36 +00:00
|
|
|
endif
|
2015-10-03 06:18:47 +00:00
|
|
|
|
|
|
|
ifdef TARGET
|
|
|
|
DIST:=$(TARGET)
|
|
|
|
else
|
|
|
|
DIST:=emulator
|
|
|
|
endif
|
|
|
|
|
2024-05-11 18:12:43 +00:00
|
|
|
INSTALL_DIR ?= koreader-$(DIST)-$(MACHINE)
|
2013-03-24 14:08:42 +00:00
|
|
|
|
2014-10-03 10:02:50 +00:00
|
|
|
# platform directories
|
|
|
|
PLATFORM_DIR=platform
|
2018-09-05 23:35:48 +00:00
|
|
|
COMMON_DIR=$(PLATFORM_DIR)/common
|
2014-10-03 10:02:50 +00:00
|
|
|
WIN32_DIR=$(PLATFORM_DIR)/win32
|
2014-05-26 15:38:51 +00:00
|
|
|
|
2024-07-30 23:55:38 +00:00
|
|
|
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)/*))
|
|
|
|
|
2013-08-07 18:40:00 +00:00
|
|
|
# files to link from main directory
|
2016-11-13 07:44:06 +00:00
|
|
|
INSTALL_FILES=reader.lua setupkoenv.lua frontend resources defaults.lua datastorage.lua \
|
|
|
|
l10n tools README.md COPYING
|
2011-11-16 22:52:26 +00:00
|
|
|
|
2024-07-30 23:55:38 +00:00
|
|
|
OUTPUT_DIR_ARTIFACTS = $(abspath $(OUTPUT_DIR))/!(cache|cmake|data|history|staging|thirdparty)
|
|
|
|
OUTPUT_DIR_DATAFILES = $(wildcard $(OUTPUT_DIR)/data/*)
|
2024-05-11 18:12:43 +00:00
|
|
|
|
2024-05-11 18:12:42 +00:00
|
|
|
all: base
|
2016-01-03 06:28:24 +00:00
|
|
|
install -d $(INSTALL_DIR)/koreader
|
2018-03-07 18:26:56 +00:00
|
|
|
rm -f $(INSTALL_DIR)/koreader/git-rev; echo "$(VERSION)" > $(INSTALL_DIR)/koreader/git-rev
|
2019-04-02 16:28:46 +00:00
|
|
|
ifdef ANDROID
|
|
|
|
rm -f android-fdroid-version; echo -e "$(ANDROID_NAME)\n$(ANDROID_VERSION)" > koreader-android-fdroid-latest
|
|
|
|
endif
|
2024-07-30 23:55:34 +00:00
|
|
|
ifeq (,$(IS_RELEASE))
|
|
|
|
$(SYMLINK) $(KOR_BASE)/ev_replay.py $(INSTALL_DIR)/koreader/
|
|
|
|
endif
|
2024-05-11 18:12:43 +00:00
|
|
|
bash -O extglob -c '$(SYMLINK) $(OUTPUT_DIR_ARTIFACTS) $(INSTALL_DIR)/koreader/'
|
2024-07-30 23:55:34 +00:00
|
|
|
ifneq (,$(EMULATE_READER))
|
2016-01-31 22:24:26 +00:00
|
|
|
@echo "[*] install front spec only for the emulator"
|
2024-07-30 23:55:32 +00:00
|
|
|
$(SYMLINK) spec $(INSTALL_DIR)/koreader/spec/front
|
|
|
|
$(SYMLINK) test $(INSTALL_DIR)/koreader/spec/front/unit/data
|
2013-08-07 18:40:00 +00:00
|
|
|
endif
|
2024-07-30 23:55:32 +00:00
|
|
|
$(SYMLINK) $(INSTALL_FILES) $(INSTALL_DIR)/koreader/
|
2014-06-01 15:53:09 +00:00
|
|
|
ifdef ANDROID
|
2024-07-30 23:55:32 +00:00
|
|
|
$(SYMLINK) $(ANDROID_DIR)/*.lua $(INSTALL_DIR)/koreader/
|
2014-09-25 14:25:43 +00:00
|
|
|
endif
|
2022-06-25 20:46:43 +00:00
|
|
|
@echo "[*] Install update once marker"
|
|
|
|
@echo "# This file indicates that update once patches have not been applied yet." > $(INSTALL_DIR)/koreader/update_once.marker
|
2014-09-25 14:25:43 +00:00
|
|
|
ifdef WIN32
|
2016-01-31 22:24:26 +00:00
|
|
|
@echo "[*] Install runtime libraries for win32..."
|
2024-07-30 23:55:32 +00:00
|
|
|
$(SYMLINK) $(WIN32_DIR)/*.dll $(INSTALL_DIR)/koreader/
|
2022-09-04 15:17:08 +00:00
|
|
|
endif
|
|
|
|
ifdef SHIP_SHARED_STL
|
|
|
|
@echo "[*] Install C++ runtime..."
|
|
|
|
cp -fL $(SHARED_STL_LIB) $(INSTALL_DIR)/koreader/libs/
|
2022-09-05 04:04:52 +00:00
|
|
|
chmod 755 $(INSTALL_DIR)/koreader/libs/$(notdir $(SHARED_STL_LIB))
|
2022-09-04 15:17:08 +00:00
|
|
|
$(STRIP) --strip-unneeded $(INSTALL_DIR)/koreader/libs/$(notdir $(SHARED_STL_LIB))
|
2014-06-01 15:53:09 +00:00
|
|
|
endif
|
2016-01-31 22:24:26 +00:00
|
|
|
@echo "[*] Install plugins"
|
2024-07-30 23:55:32 +00:00
|
|
|
$(SYMLINK) plugins $(INSTALL_DIR)/koreader/
|
2020-06-19 19:23:47 +00:00
|
|
|
@echo "[*] Install resources"
|
2024-07-30 23:55:32 +00:00
|
|
|
$(SYMLINK) resources/fonts/* $(INSTALL_DIR)/koreader/fonts/
|
2024-07-30 23:55:34 +00:00
|
|
|
install -d $(INSTALL_DIR)/koreader/{screenshots,fonts/host,ota}
|
2024-07-30 23:55:38 +00:00
|
|
|
# Note: the data dir is distinct from the one in base/build/…!
|
|
|
|
@echo "[*] Install data files"
|
|
|
|
install -d $(INSTALL_DIR)/koreader/data
|
|
|
|
$(SYMLINK) $(OUTPUT_DIR_DATAFILES) $(CR3GUI_DATADIR_FILES) $(INSTALL_DIR)/koreader/data/
|
2024-07-30 23:55:34 +00:00
|
|
|
ifneq (,$(IS_RELEASE))
|
2016-01-31 22:24:26 +00:00
|
|
|
@echo "[*] Clean up, remove unused files for releases"
|
2024-07-30 23:55:34 +00:00
|
|
|
rm -rf $(INSTALL_DIR)/koreader/data/{cr3.ini,desktop,devices,dict,manual,tessdata}
|
2014-01-01 21:07:28 +00:00
|
|
|
endif
|
2013-08-07 18:40:00 +00:00
|
|
|
|
2024-07-30 23:55:36 +00:00
|
|
|
base: base-all
|
2011-12-02 22:10:59 +00:00
|
|
|
|
2016-02-04 04:23:46 +00:00
|
|
|
$(INSTALL_DIR)/koreader/.busted: .busted
|
2024-07-30 23:55:32 +00:00
|
|
|
$(SYMLINK) .busted $@
|
2014-05-15 08:07:38 +00:00
|
|
|
|
2014-10-06 13:31:04 +00:00
|
|
|
$(INSTALL_DIR)/koreader/.luacov:
|
2024-07-30 23:55:32 +00:00
|
|
|
$(SYMLINK) .luacov $@
|
2014-10-06 13:31:04 +00:00
|
|
|
|
2024-07-30 23:55:37 +00:00
|
|
|
testbase: base-test
|
|
|
|
|
|
|
|
testfront: all test-data $(INSTALL_DIR)/koreader/.busted
|
2016-08-12 06:05:18 +00:00
|
|
|
# sdr files may have unexpected impact on unit testing
|
2016-08-14 16:32:23 +00:00
|
|
|
-rm -rf spec/unit/data/*.sdr
|
2024-04-10 20:48:47 +00:00
|
|
|
cd $(INSTALL_DIR)/koreader && $(BUSTED_LUAJIT) $(BUSTED_OVERRIDES) $(BUSTED_SPEC_FILE)
|
2014-05-15 08:07:38 +00:00
|
|
|
|
2024-07-30 23:55:37 +00:00
|
|
|
test: testbase testfront
|
2014-03-25 14:26:36 +00:00
|
|
|
|
2014-10-06 13:31:04 +00:00
|
|
|
coverage: $(INSTALL_DIR)/koreader/.luacov
|
2016-08-14 16:32:23 +00:00
|
|
|
-rm -rf $(INSTALL_DIR)/koreader/luacov.*.out
|
2016-04-21 06:56:38 +00:00
|
|
|
cd $(INSTALL_DIR)/koreader && \
|
2017-10-11 07:08:18 +00:00
|
|
|
./luajit $(shell which busted) --output=gtest \
|
2016-08-14 16:32:23 +00:00
|
|
|
--sort-files \
|
2016-04-21 06:56:38 +00:00
|
|
|
--coverage --exclude-tags=nocov
|
2014-10-06 13:31:04 +00:00
|
|
|
# coverage report summary
|
|
|
|
cd $(INSTALL_DIR)/koreader && tail -n \
|
2017-02-02 11:13:13 +00:00
|
|
|
+$$(($$(grep -nm1 -e "^Summary$$" luacov.report.out|cut -d: -f1)-1)) \
|
2014-10-06 13:31:04 +00:00
|
|
|
luacov.report.out
|
|
|
|
|
2024-07-30 23:55:36 +00:00
|
|
|
ifeq (,$(wildcard $(KOR_BASE)/Makefile))
|
|
|
|
$(KOR_BASE)/Makefile: fetchthirdparty
|
|
|
|
endif
|
2024-07-30 23:55:31 +00:00
|
|
|
ifeq (,$(wildcard $(KOR_BASE)/Makefile.defs))
|
|
|
|
$(KOR_BASE)/Makefile.defs: fetchthirdparty
|
|
|
|
endif
|
|
|
|
|
|
|
|
fetchthirdparty:
|
2012-03-08 13:03:18 +00:00
|
|
|
git submodule init
|
2014-06-09 00:35:31 +00:00
|
|
|
git submodule sync
|
2024-04-14 15:32:33 +00:00
|
|
|
ifneq (,$(CI))
|
|
|
|
git submodule update --depth 1 --jobs 3
|
|
|
|
else
|
|
|
|
# Force shallow clones of submodules configured as such.
|
|
|
|
git submodule update --jobs 3 --depth 1 $(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
|
|
|
|
endif
|
2013-08-07 18:40:00 +00:00
|
|
|
$(MAKE) -C $(KOR_BASE) fetchthirdparty
|
2011-11-14 18:17:14 +00:00
|
|
|
|
2024-07-30 23:55:36 +00:00
|
|
|
clean: base-clean
|
2013-08-07 19:58:15 +00:00
|
|
|
rm -rf $(INSTALL_DIR)
|
2016-10-02 04:42:00 +00:00
|
|
|
ifeq ($(TARGET), android)
|
|
|
|
$(MAKE) -C $(CURDIR)/platform/android/luajit-launcher clean
|
|
|
|
endif
|
2013-03-24 16:18:53 +00:00
|
|
|
|
2024-07-30 23:55:36 +00:00
|
|
|
distclean: clean base-distclean
|
2016-02-04 18:24:39 +00:00
|
|
|
$(MAKE) -C doc clean
|
2016-01-05 07:52:47 +00:00
|
|
|
|
2024-07-30 23:55:36 +00:00
|
|
|
re: clean
|
|
|
|
$(MAKE) all
|
|
|
|
|
2024-05-11 18:12:43 +00:00
|
|
|
# Include target specific rules.
|
|
|
|
ifneq (,$(wildcard make/$(TARGET).mk))
|
|
|
|
include make/$(TARGET).mk
|
2015-10-03 06:18:47 +00:00
|
|
|
endif
|
|
|
|
|
2024-05-14 08:30:15 +00:00
|
|
|
android-ndk:
|
|
|
|
$(MAKE) -C $(KOR_BASE)/toolchain $(ANDROID_NDK_HOME)
|
|
|
|
|
|
|
|
android-sdk:
|
|
|
|
$(MAKE) -C $(KOR_BASE)/toolchain $(ANDROID_HOME)
|
|
|
|
|
2017-05-08 09:37:29 +00:00
|
|
|
# for gettext
|
|
|
|
DOMAIN=koreader
|
|
|
|
TEMPLATE_DIR=l10n/templates
|
2019-08-21 20:18:14 +00:00
|
|
|
XGETTEXT_BIN=xgettext
|
2017-05-08 09:37:29 +00:00
|
|
|
|
2019-12-31 14:39:15 +00:00
|
|
|
pot: po
|
2014-08-26 06:27:38 +00:00
|
|
|
mkdir -p $(TEMPLATE_DIR)
|
2019-08-24 21:06:06 +00:00
|
|
|
$(XGETTEXT_BIN) --from-code=utf-8 \
|
|
|
|
--keyword=C_:1c,2 --keyword=N_:1,2 --keyword=NC_:1c,2,3 \
|
2019-08-24 07:25:38 +00:00
|
|
|
--add-comments=@translators \
|
2019-12-31 16:47:54 +00:00
|
|
|
reader.lua `find frontend -iname "*.lua" | sort` \
|
|
|
|
`find plugins -iname "*.lua" | sort` \
|
|
|
|
`find tools -iname "*.lua" | sort` \
|
2019-08-21 20:18:14 +00:00
|
|
|
-o $(TEMPLATE_DIR)/$(DOMAIN).pot
|
2013-04-07 19:05:32 +00:00
|
|
|
|
2013-11-29 14:41:56 +00:00
|
|
|
po:
|
2019-12-31 14:39:15 +00:00
|
|
|
git submodule update --remote l10n
|
2017-05-08 09:37:29 +00:00
|
|
|
|
2014-10-25 23:57:31 +00:00
|
|
|
|
2015-04-27 00:43:32 +00:00
|
|
|
static-check:
|
2016-03-29 07:56:29 +00:00
|
|
|
@if which luacheck > /dev/null; then \
|
2018-04-15 21:49:08 +00:00
|
|
|
luacheck -q {reader,setupkoenv,datastorage}.lua frontend plugins spec; \
|
2016-03-29 07:56:29 +00:00
|
|
|
else \
|
|
|
|
echo "[!] luacheck not found. "\
|
|
|
|
"you can install it with 'luarocks install luacheck'"; \
|
|
|
|
fi
|
2015-04-27 00:43:32 +00:00
|
|
|
|
2016-02-04 18:24:39 +00:00
|
|
|
doc:
|
|
|
|
make -C doc
|
|
|
|
|
2024-05-29 18:15:29 +00:00
|
|
|
.NOTPARALLEL:
|
|
|
|
.PHONY: $(PHONY)
|
|
|
|
|
2024-07-30 23:55:36 +00:00
|
|
|
include $(KOR_BASE)/Makefile
|