2013-03-24 21:27:20 +00:00
|
|
|
# koreader-base directory
|
2014-10-04 12:52:06 +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
|
|
|
|
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
|
2018-03-07 18:26:56 +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-11 18:12:42 +00:00
|
|
|
VERSION:=$(VERSION)_$(shell git show -s --format=format:"%cd" --date=short HEAD)
|
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
|
|
|
|
2022-10-24 23:54:18 +00:00
|
|
|
ifeq ($(ANDROID_ARCH), arm64)
|
|
|
|
ANDROID_ABI?=arm64-v8a
|
|
|
|
else ifeq ($(ANDROID_ARCH), x86)
|
|
|
|
ANDROID_ABI?=$(ANDROID_ARCH)
|
|
|
|
else ifeq ($(ANDROID_ARCH), x86_64)
|
|
|
|
ANDROID_ABI?=$(ANDROID_ARCH)
|
|
|
|
else
|
|
|
|
ANDROID_ARCH?=arm
|
|
|
|
ANDROID_ABI?=armeabi-v7a
|
2021-06-07 15:13:34 +00:00
|
|
|
endif
|
|
|
|
|
2019-02-03 19:19:52 +00:00
|
|
|
# Use the git commit count as the (integer) Android version code
|
2019-02-04 12:52:20 +00:00
|
|
|
ANDROID_VERSION?=$(shell git rev-list --count HEAD)
|
2019-02-03 19:19:52 +00:00
|
|
|
ANDROID_NAME?=$(VERSION)
|
|
|
|
|
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
|
|
|
|
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-05-11 18:12:43 +00:00
|
|
|
ifeq ($(abspath $(OUTPUT_DIR)),$(OUTPUT_DIR))
|
|
|
|
ABSOLUTE_OUTPUT_DIR = $(OUTPUT_DIR)
|
|
|
|
else
|
|
|
|
ABSOLUTE_OUTPUT_DIR = $(KOR_BASE)/$(OUTPUT_DIR)
|
|
|
|
endif
|
2024-05-11 18:12:55 +00:00
|
|
|
OUTPUT_DIR_ARTIFACTS = $(ABSOLUTE_OUTPUT_DIR)/!(cache|history|thirdparty)
|
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
|
2020-05-14 12:26:00 +00:00
|
|
|
ifeq ($(IS_RELEASE),1)
|
2024-05-11 18:12:43 +00:00
|
|
|
bash -O extglob -c '$(RCP) -fL $(OUTPUT_DIR_ARTIFACTS) $(INSTALL_DIR)/koreader/'
|
2020-05-14 12:26:00 +00:00
|
|
|
else
|
2013-08-07 18:40:00 +00:00
|
|
|
cp -f $(KOR_BASE)/ev_replay.py $(INSTALL_DIR)/koreader/
|
2016-01-31 22:24:26 +00:00
|
|
|
@echo "[*] create symlink instead of copying files in development mode"
|
2024-05-11 18:12:43 +00:00
|
|
|
bash -O extglob -c '$(SYMLINK) $(OUTPUT_DIR_ARTIFACTS) $(INSTALL_DIR)/koreader/'
|
|
|
|
ifneq (,$(EMULATE_READER))
|
2016-01-31 22:24:26 +00:00
|
|
|
@echo "[*] install front spec only for the emulator"
|
2024-05-11 18:12:43 +00:00
|
|
|
$(SYMLINK) $(abspath spec) $(INSTALL_DIR)/koreader/spec/front
|
|
|
|
$(SYMLINK) $(abspath test) $(INSTALL_DIR)/koreader/spec/front/unit/data
|
|
|
|
endif
|
2013-08-07 18:40:00 +00:00
|
|
|
endif
|
2024-05-11 18:12:43 +00:00
|
|
|
$(SYMLINK) $(abspath $(INSTALL_FILES)) $(INSTALL_DIR)/koreader/
|
2014-06-01 15:53:09 +00:00
|
|
|
ifdef ANDROID
|
2024-05-11 18:12:43 +00:00
|
|
|
$(SYMLINK) $(abspath $(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-05-11 18:12:43 +00:00
|
|
|
$(SYMLINK) $(abspath $(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-05-11 18:12:51 +00:00
|
|
|
$(SYMLINK) $(abspath plugins) $(INSTALL_DIR)/koreader/
|
2020-06-19 19:23:47 +00:00
|
|
|
@echo "[*] Install resources"
|
2024-05-11 18:12:51 +00:00
|
|
|
$(SYMLINK) $(abspath resources/fonts/*) $(INSTALL_DIR)/koreader/fonts/
|
2016-01-03 06:28:24 +00:00
|
|
|
install -d $(INSTALL_DIR)/koreader/{screenshots,data/{dict,tessdata},fonts/host,ota}
|
2020-05-14 12:26:00 +00:00
|
|
|
ifeq ($(IS_RELEASE),1)
|
2016-01-31 22:24:26 +00:00
|
|
|
@echo "[*] Clean up, remove unused files for releases"
|
2013-08-07 18:40:00 +00:00
|
|
|
rm -rf $(INSTALL_DIR)/koreader/data/{cr3.ini,cr3skin-format.txt,desktop,devices,manual}
|
2014-01-01 21:07:28 +00:00
|
|
|
endif
|
2013-08-07 18:40:00 +00:00
|
|
|
|
2024-05-11 18:12:42 +00:00
|
|
|
base:
|
2013-08-07 18:40:00 +00:00
|
|
|
$(MAKE) -C $(KOR_BASE)
|
2011-12-02 22:10:59 +00:00
|
|
|
|
2016-02-04 04:23:46 +00:00
|
|
|
$(INSTALL_DIR)/koreader/.busted: .busted
|
2024-05-11 18:12:43 +00:00
|
|
|
$(SYMLINK) $(abspath .busted) $@
|
2014-05-15 08:07:38 +00:00
|
|
|
|
2014-10-06 13:31:04 +00:00
|
|
|
$(INSTALL_DIR)/koreader/.luacov:
|
2024-05-11 18:12:43 +00:00
|
|
|
$(SYMLINK) $(abspath .luacov) $@
|
2014-10-06 13:31:04 +00:00
|
|
|
|
2014-05-15 08:07:38 +00:00
|
|
|
testfront: $(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
|
|
|
|
2016-10-01 08:07:31 +00:00
|
|
|
test: $(INSTALL_DIR)/koreader/.busted
|
2014-03-25 14:26:36 +00:00
|
|
|
$(MAKE) -C $(KOR_BASE) test
|
2014-05-15 08:07:38 +00:00
|
|
|
$(MAKE) 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-05-11 18:12:42 +00:00
|
|
|
$(KOR_BASE)/Makefile.defs 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
|
|
|
|
2014-10-25 23:57:31 +00:00
|
|
|
VERBOSE ?= @
|
|
|
|
Q = $(VERBOSE:1=)
|
2011-11-14 18:17:14 +00:00
|
|
|
clean:
|
2013-08-07 19:58:15 +00:00
|
|
|
rm -rf $(INSTALL_DIR)
|
2014-10-25 23:57:31 +00:00
|
|
|
$(Q:@=@echo 'MAKE -C base clean'; &> /dev/null) \
|
|
|
|
$(MAKE) -C $(KOR_BASE) clean
|
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
|
|
|
|
2016-01-05 07:52:47 +00:00
|
|
|
dist-clean: clean
|
|
|
|
rm -rf $(INSTALL_DIR)
|
|
|
|
$(MAKE) -C $(KOR_BASE) dist-clean
|
2016-02-04 18:24:39 +00:00
|
|
|
$(MAKE) -C doc clean
|
2016-01-05 07:52:47 +00:00
|
|
|
|
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
|
|
|
|
|
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-11 18:12:43 +00:00
|
|
|
.PHONY: all base clean doc test
|