2
0
mirror of https://github.com/koreader/koreader synced 2024-11-04 12:00:25 +00:00
koreader/Makefile

348 lines
12 KiB
Makefile
Raw Normal View History

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
# the repository might not have been checked out yet, so make this
# able to fail:
2013-03-24 21:04:32 +00:00
-include $(KOR_BASE)/Makefile.defs
# we want VERSION to carry the version of koreader, not koreader-base
VERSION=$(shell git describe HEAD)
2014-05-25 08:18:55 +00:00
REVISION=$(shell git rev-parse --short HEAD)
# set PATH to find CC in managed toolchains
ifeq ($(TARGET), android)
PATH:=$(CURDIR)/$(KOR_BASE)/$(ANDROID_TOOLCHAIN)/bin:$(PATH)
else ifeq ($(TARGET), pocketbook)
PATH:=$(CURDIR)/$(KOR_BASE)/$(POCKETBOOK_TOOLCHAIN)/bin:$(PATH)
endif
MACHINE=$(shell PATH=$(PATH) $(CC) -dumpmachine 2>/dev/null)
ifdef TARGET
DIST:=$(TARGET)
else
DIST:=emulator
endif
INSTALL_DIR=koreader-$(DIST)-$(MACHINE)
# platform directories
PLATFORM_DIR=platform
KINDLE_DIR=$(PLATFORM_DIR)/kindle
KOBO_DIR=$(PLATFORM_DIR)/kobo
2015-01-12 16:14:56 +00:00
POCKETBOOK_DIR=$(PLATFORM_DIR)/pocketbook
UBUNTUTOUCH_DIR=$(PLATFORM_DIR)/ubuntu-touch
ANDROID_DIR=$(PLATFORM_DIR)/android
ANDROID_LAUNCHER_DIR:=$(ANDROID_DIR)/luajit-launcher
UBUNTUTOUCH_SDL_DIR:=$(UBUNTUTOUCH_DIR)/ubuntu-touch-sdl
WIN32_DIR=$(PLATFORM_DIR)/win32
# files to link from main directory
INSTALL_FILES=reader.lua frontend resources defaults.lua datastorage.lua l10n utils \
README.md COPYING
2013-04-07 19:05:32 +00:00
# for gettext
DOMAIN=koreader
TEMPLATE_DIR=l10n/templates
KOREADER_MISC_TOOL=../misc
XGETTEXT_BIN=$(KOREADER_MISC_TOOL)/gettext/lua_xgettext.py
2014-06-05 12:54:36 +00:00
all: $(if $(ANDROID),,$(KOR_BASE)/$(OUTPUT_DIR)/luajit)
$(MAKE) -C $(KOR_BASE)
2016-01-03 06:28:24 +00:00
install -d $(INSTALL_DIR)/koreader
rm -f $(INSTALL_DIR)/koreader/git-rev; echo $(VERSION) > $(INSTALL_DIR)/koreader/git-rev
2014-09-25 14:25:43 +00:00
ifneq ($(or $(EMULATE_READER),$(WIN32)),)
cp -f $(KOR_BASE)/ev_replay.py $(INSTALL_DIR)/koreader/
@echo "[*] create symlink instead of copying files in development mode"
cd $(INSTALL_DIR)/koreader && \
ln -sf ../../$(KOR_BASE)/$(OUTPUT_DIR)/* .
@echo "[*] install front spec only for the emulator"
2014-05-25 08:18:55 +00:00
cd $(INSTALL_DIR)/koreader/spec && test -e front || \
ln -sf ../../../../spec ./front
2014-05-29 13:09:22 +00:00
cd $(INSTALL_DIR)/koreader/spec/front/unit && test -e data || \
ln -sf ../../test ./data
else
cp -rfL $(KOR_BASE)/$(OUTPUT_DIR)/* $(INSTALL_DIR)/koreader/
endif
for f in $(INSTALL_FILES); do \
2013-08-07 19:58:15 +00:00
ln -sf ../../$$f $(INSTALL_DIR)/koreader/; \
done
ifdef ANDROID
cd $(INSTALL_DIR)/koreader && \
ln -sf ../../$(ANDROID_DIR)/*.lua .
2014-09-25 14:25:43 +00:00
endif
ifdef WIN32
@echo "[*] Install runtime libraries for win32..."
cd $(INSTALL_DIR)/koreader && cp ../../$(WIN32_DIR)/*.dll .
endif
@echo "[*] Install plugins"
cp -r plugins/* $(INSTALL_DIR)/koreader/plugins/
@echo "[*] Installresources"
cp -rpL 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}
2014-09-25 14:25:43 +00:00
ifeq ($(or $(EMULATE_READER),$(WIN32)),)
@echo "[*] Clean up, remove unused files for releases"
rm -rf $(INSTALL_DIR)/koreader/data/{cr3.ini,cr3skin-format.txt,desktop,devices,manual}
rm -rf $(INSTALL_DIR)/koreader/fonts/droid/DroidSansFallbackFull.ttf
endif
$(KOR_BASE)/$(OUTPUT_DIR)/luajit:
$(MAKE) -C $(KOR_BASE)
2016-02-04 04:23:46 +00:00
$(INSTALL_DIR)/koreader/.busted: .busted
ln -sf ../../.busted $(INSTALL_DIR)/koreader
2014-05-15 08:07:38 +00:00
$(INSTALL_DIR)/koreader/.luacov:
test -e $(INSTALL_DIR)/koreader/.luacov || \
ln -sf ../../.luacov $(INSTALL_DIR)/koreader
2014-05-15 08:07:38 +00:00
testfront: $(INSTALL_DIR)/koreader/.busted
cd $(INSTALL_DIR)/koreader && ./luajit $(shell which busted) -o verbose_print --exclude-tags=notest
2014-05-15 08:07:38 +00:00
test:
$(MAKE) -C $(KOR_BASE) test
2014-05-15 08:07:38 +00:00
$(MAKE) testfront
coverage: $(INSTALL_DIR)/koreader/.luacov
2015-10-07 14:41:14 +00:00
cd $(INSTALL_DIR)/koreader && ./luajit $(shell which busted) -o verbose_print --coverage --exclude-tags=nocov
# coverage report summary
cd $(INSTALL_DIR)/koreader && tail -n \
+$$(($$(grep -nm1 Summary luacov.report.out|cut -d: -f1)-1)) \
luacov.report.out
fetchthirdparty:
git submodule init
git submodule sync
git submodule update
$(MAKE) -C $(KOR_BASE) fetchthirdparty
2014-10-25 23:57:31 +00:00
VERBOSE ?= @
Q = $(VERBOSE:1=)
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-01-05 07:52:47 +00:00
dist-clean: clean
rm -rf $(INSTALL_DIR)
$(MAKE) -C $(KOR_BASE) dist-clean
$(MAKE) -C doc clean
2016-01-05 07:52:47 +00:00
2014-10-20 06:17:57 +00:00
# Don't bundle launchpad on touch devices..
ifeq ($(TARGET), kindle-legacy)
KINDLE_LEGACY_LAUNCHER:=launchpad
endif
kindleupdate: all
# ensure that the binaries were built for ARM
file $(INSTALL_DIR)/koreader/luajit | grep ARM || exit 1
# remove old package if any
rm -f koreader-kindle-$(MACHINE)-$(VERSION).zip
# Kindle launching scripts
ln -sf ../$(KINDLE_DIR)/extensions $(INSTALL_DIR)/
ln -sf ../$(KINDLE_DIR)/launchpad $(INSTALL_DIR)/
ln -sf ../../$(KINDLE_DIR)/koreader.sh $(INSTALL_DIR)/koreader
ln -sf ../../$(KINDLE_DIR)/libkohelper.sh $(INSTALL_DIR)/koreader
ln -sf ../../$(KINDLE_DIR)/kotar_cpoint $(INSTALL_DIR)/koreader
# create new package
2014-10-20 06:17:57 +00:00
cd $(INSTALL_DIR) && pwd && \
zip -9 -r \
../koreader-kindle-$(MACHINE)-$(VERSION).zip \
extensions koreader $(KINDLE_LEGACY_LAUNCHER) \
-x "koreader/resources/fonts/*" "koreader/ota/*" \
"koreader/resources/icons/src/*" "koreader/spec/*"
# generate kindleupdate package index file
zipinfo -1 koreader-kindle-$(MACHINE)-$(VERSION).zip > \
$(INSTALL_DIR)/koreader/ota/package.index
echo "koreader/ota/package.index" >> $(INSTALL_DIR)/koreader/ota/package.index
# update index file in zip package
cd $(INSTALL_DIR) && zip -u ../koreader-kindle-$(MACHINE)-$(VERSION).zip \
koreader/ota/package.index
# make gzip kindleupdate for zsync OTA update
2015-10-03 07:07:31 +00:00
# note that the targz file extension is intended to keep ISP from caching
# the file, see koreader#1644.
cd $(INSTALL_DIR) && \
tar czafh ../koreader-kindle-$(MACHINE)-$(VERSION).targz \
-T koreader/ota/package.index --no-recursion
2013-03-24 21:04:32 +00:00
2013-08-06 10:03:10 +00:00
koboupdate: all
# ensure that the binaries were built for ARM
file $(INSTALL_DIR)/koreader/luajit | grep ARM || exit 1
# remove old package if any
rm -f koreader-kobo-$(MACHINE)-$(VERSION).zip
# Kobo launching scripts
mkdir -p $(INSTALL_DIR)/kobo/mnt/onboard/.kobo
ln -sf ../../../../../$(KOBO_DIR)/fmon $(INSTALL_DIR)/kobo/mnt/onboard/.kobo/
cd $(INSTALL_DIR)/kobo && tar -czhf ../KoboRoot.tgz mnt
cp resources/koreader.png $(INSTALL_DIR)/koreader.png
cp $(KOBO_DIR)/fmon/README.txt $(INSTALL_DIR)/README_kobo.txt
cp $(KOBO_DIR)/koreader.sh $(INSTALL_DIR)/koreader
cp $(KOBO_DIR)/suspend.sh $(INSTALL_DIR)/koreader
cp $(KOBO_DIR)/nickel.sh $(INSTALL_DIR)/koreader
# create new package
cd $(INSTALL_DIR) && \
zip -9 -r \
../koreader-kobo-$(MACHINE)-$(VERSION).zip \
koreader -x "koreader/resources/fonts/*" \
"koreader/resources/icons/src/*" "koreader/spec/*"
# generate koboupdate package index file
zipinfo -1 koreader-kobo-$(MACHINE)-$(VERSION).zip > \
$(INSTALL_DIR)/koreader/ota/package.index
echo "koreader/ota/package.index" >> $(INSTALL_DIR)/koreader/ota/package.index
# update index file in zip package
cd $(INSTALL_DIR) && zip -u ../koreader-kobo-$(MACHINE)-$(VERSION).zip \
koreader/ota/package.index KoboRoot.tgz koreader.png README_kobo.txt
# make gzip koboupdate for zsync OTA update
cd $(INSTALL_DIR) && \
tar czafh ../koreader-kobo-$(MACHINE)-$(VERSION).targz \
-T koreader/ota/package.index --no-recursion
2013-04-07 19:05:32 +00:00
2015-01-12 16:14:56 +00:00
pbupdate: all
# ensure that the binaries were built for ARM
file $(INSTALL_DIR)/koreader/luajit | grep ARM || exit 1
# remove old package if any
rm -f koreader-pocketbook-$(MACHINE)-$(VERSION).zip
# Pocketbook launching script
mkdir -p $(INSTALL_DIR)/applications
mkdir -p $(INSTALL_DIR)/system/bin
mkdir -p $(INSTALL_DIR)/system/config
2015-01-12 16:14:56 +00:00
cp $(POCKETBOOK_DIR)/koreader.app $(INSTALL_DIR)/applications
cp $(POCKETBOOK_DIR)/koreader.app $(INSTALL_DIR)/system/bin
cp $(POCKETBOOK_DIR)/extensions.cfg $(INSTALL_DIR)/system/config
cp -rfL $(INSTALL_DIR)/koreader $(INSTALL_DIR)/applications
2015-01-12 16:14:56 +00:00
# create new package
cd $(INSTALL_DIR) && \
zip -9 -r \
../koreader-pocketbook-$(MACHINE)-$(VERSION).zip \
applications -x "applications/koreader/resources/fonts/*" \
"applications/koreader/resources/icons/src/*" "applications/koreader/spec/*"
2015-01-12 16:14:56 +00:00
# generate koboupdate package index file
zipinfo -1 koreader-pocketbook-$(MACHINE)-$(VERSION).zip > \
$(INSTALL_DIR)/applications/koreader/ota/package.index
echo "applications/koreader/ota/package.index" >> \
$(INSTALL_DIR)/applications/koreader/ota/package.index
2015-01-19 16:07:36 +00:00
# hack file path when running tar in parent directory of koreader
sed -i -e 's/^/..\//' \
$(INSTALL_DIR)/applications/koreader/ota/package.index
2015-01-12 16:14:56 +00:00
# update index file in zip package
cd $(INSTALL_DIR) && zip -ru ../koreader-pocketbook-$(MACHINE)-$(VERSION).zip \
applications/koreader/ota/package.index system
2015-01-12 16:14:56 +00:00
# make gzip pbupdate for zsync OTA update
cd $(INSTALL_DIR)/applications && \
tar czafh ../../koreader-pocketbook-$(MACHINE)-$(VERSION).targz \
-T koreader/ota/package.index --no-recursion
2015-01-12 16:14:56 +00:00
utupdate: all
# ensure that the binaries were built for ARM
file $(INSTALL_DIR)/koreader/luajit | grep ARM || exit 1
# remove old package if any
rm -f koreader-ubuntu-touch-$(MACHINE)-$(VERSION).click
ln -sf ../../$(UBUNTUTOUCH_DIR)/koreader.sh $(INSTALL_DIR)/koreader
ln -sf ../../$(UBUNTUTOUCH_DIR)/manifest.json $(INSTALL_DIR)/koreader
ln -sf ../../$(UBUNTUTOUCH_DIR)/koreader.apparmor $(INSTALL_DIR)/koreader
ln -sf ../../$(UBUNTUTOUCH_DIR)/koreader.apparmor.openstore $(INSTALL_DIR)/koreader
ln -sf ../../$(UBUNTUTOUCH_DIR)/koreader.desktop $(INSTALL_DIR)/koreader
ln -sf ../../$(UBUNTUTOUCH_DIR)/koreader.png $(INSTALL_DIR)/koreader
ln -sf ../../../$(UBUNTUTOUCH_SDL_DIR)/lib/arm-linux-gnueabihf/libSDL2.so $(INSTALL_DIR)/koreader/libs
# create new package
cd $(INSTALL_DIR) && pwd && \
zip -9 -r \
../koreader-$(DIST)-$(MACHINE)-$(VERSION).zip \
koreader -x "koreader/resources/fonts/*" "koreader/ota/*" \
"koreader/resources/icons/src/*" "koreader/spec/*"
# generate update package index file
zipinfo -1 koreader-$(DIST)-$(MACHINE)-$(VERSION).zip > \
$(INSTALL_DIR)/koreader/ota/package.index
echo "koreader/ota/package.index" >> $(INSTALL_DIR)/koreader/ota/package.index
# update index file in zip package
cd $(INSTALL_DIR) && zip -u ../koreader-$(DIST)-$(MACHINE)-$(VERSION).zip \
koreader/ota/package.index
# make gzip update for zsync OTA update
cd $(INSTALL_DIR) && \
tar czafh ../koreader-$(DIST)-$(MACHINE)-$(VERSION).targz \
-T koreader/ota/package.index --no-recursion
# generate ubuntu touch click package
rm -rf $(INSTALL_DIR)/tmp && mkdir -p $(INSTALL_DIR)/tmp
cd $(INSTALL_DIR)/tmp && \
unzip ../../koreader-$(DIST)-$(MACHINE)-$(VERSION).zip && \
click build koreader && \
mv *.click ../../koreader-$(DIST)-$(MACHINE)-$(VERSION).click
androidupdate: all
mkdir -p $(ANDROID_LAUNCHER_DIR)/assets/module
-rm $(ANDROID_LAUNCHER_DIR)/assets/module/koreader-*
2016-03-13 15:42:58 +00:00
# create zip package
cd $(INSTALL_DIR)/koreader && \
zip -9 -r \
../../koreader-android-$(MACHINE)-$(VERSION).zip \
* -x "resources/fonts/*" "resources/icons/src/*" "spec/*"
# generate android update package index file
zipinfo -1 koreader-android-$(MACHINE)-$(VERSION).zip > \
$(INSTALL_DIR)/koreader/ota/package.index
rm -f koreader-android-$(MACHINE)-$(VERSION).zip
echo "ota/package.index" >> $(INSTALL_DIR)/koreader/ota/package.index
cp $(INSTALL_DIR)/koreader/git-rev $(INSTALL_DIR)/koreader/ota-rev
# make gzip android update for zsync OTA update
cd $(INSTALL_DIR)/koreader && \
tar czafh ../../koreader-android-$(MACHINE)-$(VERSION).targz \
-T ota/package.index --no-recursion
# make android update apk
cd $(INSTALL_DIR)/koreader && 7z a -l -mx=1 \
../../$(ANDROID_LAUNCHER_DIR)/assets/module/koreader-g$(REVISION).7z * \
-x!resources/fonts -x!resources/icons/src -x!spec
2014-05-29 13:09:22 +00:00
$(MAKE) -C $(ANDROID_LAUNCHER_DIR) apk
cp $(ANDROID_LAUNCHER_DIR)/bin/NativeActivity-debug.apk \
koreader-android-$(MACHINE)-$(VERSION).apk
update:
ifeq ($(TARGET), kindle)
make kindleupdate
2016-02-01 06:43:46 +00:00
else ifeq ($(TARGET), kindle-legacy)
make kindleupdate
else ifeq ($(TARGET), kobo)
make koboupdate
else ifeq ($(TARGET), pocketbook)
make pbupdate
else ifeq ($(TARGET), ubuntu-touch)
make utupdate
else ifeq ($(TARGET), android)
make androidupdate
endif
androiddev: androidupdate
$(MAKE) -C $(ANDROID_LAUNCHER_DIR) dev
2014-05-25 08:18:55 +00:00
2014-05-29 13:09:22 +00:00
android-toolchain:
$(MAKE) -C $(KOR_BASE) android-toolchain
pocketbook-toolchain:
$(MAKE) -C $(KOR_BASE) pocketbook-toolchain
2013-04-07 19:05:32 +00:00
pot:
mkdir -p $(TEMPLATE_DIR)
2013-04-07 19:05:32 +00:00
$(XGETTEXT_BIN) reader.lua `find frontend -iname "*.lua"` \
2014-04-23 15:02:45 +00:00
`find plugins -iname "*.lua"` \
2015-10-17 16:34:57 +00:00
`find utils -iname "*.lua"` \
2013-04-07 19:05:32 +00:00
> $(TEMPLATE_DIR)/$(DOMAIN).pot
# push source file to Transifex
$(MAKE) -i -C l10n bootstrap push
2013-04-07 19:05:32 +00:00
po:
$(MAKE) -i -C l10n bootstrap pull
2014-10-25 23:57:31 +00:00
static-check:
2016-02-10 18:30:05 +00:00
@if which luacheck > /dev/null; then luacheck -q frontend; else \
echo "[!] luacheck not found. "\
"you can install it with 'luarocks install luacheck'"; fi
doc:
make -C doc
.PHONY: test doc