2019-12-18 02:12:17 +01:00
|
|
|
PREFIX := /usr
|
|
|
|
SHELL := bash
|
|
|
|
.SHELLFLAGS := -eu -o pipefail -c
|
|
|
|
.ONESHELL:
|
|
|
|
.DELETE_ON_ERROR:
|
|
|
|
MAKEFLAGS += --warn-undefined-variables
|
|
|
|
MAKEFLAGS += --no-builtin-rules
|
|
|
|
RUNARGS :=
|
|
|
|
.SUFFIXES:
|
|
|
|
|
|
|
|
$(shell mkdir -p .build)
|
|
|
|
|
2019-12-18 07:05:51 +01:00
|
|
|
# Installing
|
|
|
|
######################
|
|
|
|
|
2019-12-18 02:12:17 +01:00
|
|
|
.PHONY: all install uninstall
|
2012-12-21 08:51:59 +01:00
|
|
|
|
|
|
|
all:
|
2019-12-18 22:46:25 +01:00
|
|
|
@echo "You can run Anki from this folder with 'make run'."
|
|
|
|
@echo
|
|
|
|
@echo "After confirming it's working, to install Anki system-wide, use"
|
|
|
|
@echo "'make build && sudo make install'."
|
|
|
|
@echo
|
|
|
|
@echo "To undo a system install, use 'sudo make uninstall'."
|
2012-12-21 08:51:59 +01:00
|
|
|
|
|
|
|
install:
|
|
|
|
rm -rf ${DESTDIR}${PREFIX}/share/anki
|
|
|
|
mkdir -p ${DESTDIR}${PREFIX}/share/anki
|
2018-02-24 09:14:56 +01:00
|
|
|
cp -av anki aqt web ${DESTDIR}${PREFIX}/share/anki/
|
|
|
|
-cp -av locale ${DESTDIR}${PREFIX}/share/anki/
|
2018-02-24 09:03:05 +01:00
|
|
|
sed -e 's:@PREFIX@:${PREFIX}:' tools/runanki.system.in > tools/runanki.system
|
2018-02-24 09:14:56 +01:00
|
|
|
install -m 0755 -D tools/runanki.system ${DESTDIR}${PREFIX}/bin/anki
|
|
|
|
install -m 0644 -D -t ${DESTDIR}${PREFIX}/share/pixmaps anki.xpm anki.png
|
|
|
|
install -m 0644 -D -t ${DESTDIR}${PREFIX}/share/applications anki.desktop
|
|
|
|
install -m 0644 -D -t ${DESTDIR}${PREFIX}/share/man/man1 anki.1
|
2018-03-17 01:37:50 +01:00
|
|
|
install -m 0644 -D -t ${DESTDIR}${PREFIX}/share/doc/anki README.contributing README.development README.md LICENSE LICENSE.logo
|
2018-02-24 09:16:37 +01:00
|
|
|
-xdg-mime install anki.xml --novendor
|
|
|
|
-xdg-mime default anki.desktop application/x-anki
|
|
|
|
-xdg-mime default anki.desktop application/x-apkg
|
2012-12-21 08:51:59 +01:00
|
|
|
@echo
|
|
|
|
@echo "Install complete."
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
rm -rf ${DESTDIR}${PREFIX}/share/anki
|
2018-02-24 09:06:22 +01:00
|
|
|
rm -rf ${DESTDIR}${PREFIX}/bin/anki
|
2013-12-09 03:54:18 +01:00
|
|
|
rm -rf ${DESTDIR}${PREFIX}/share/pixmaps/anki.xpm
|
|
|
|
rm -rf ${DESTDIR}${PREFIX}/share/pixmaps/anki.png
|
2012-12-21 08:51:59 +01:00
|
|
|
rm -rf ${DESTDIR}${PREFIX}/share/applications/anki.desktop
|
|
|
|
rm -rf ${DESTDIR}${PREFIX}/share/man/man1/anki.1
|
|
|
|
-xdg-mime uninstall ${DESTDIR}${PREFIX}/share/mime/packages/anki.xml
|
|
|
|
@echo
|
|
|
|
@echo "Uninstall complete."
|
2019-12-18 02:12:17 +01:00
|
|
|
|
2019-12-18 07:05:51 +01:00
|
|
|
# Prerequisites
|
|
|
|
######################
|
2019-12-18 02:12:17 +01:00
|
|
|
|
2019-12-22 01:13:36 +01:00
|
|
|
RUNREQS := .build/pyrunreqs .build/jsreqs
|
2019-12-18 07:05:51 +01:00
|
|
|
|
|
|
|
.build/pyrunreqs: requirements.txt
|
|
|
|
pip install -r $<
|
2019-12-21 23:56:47 +01:00
|
|
|
touch $@
|
|
|
|
|
2019-12-22 01:13:36 +01:00
|
|
|
.build/pycheckreqs: requirements.check .build/pyrunreqs
|
|
|
|
pip install -r $<
|
|
|
|
./tools/typecheck-setup.sh
|
2019-12-21 23:56:47 +01:00
|
|
|
touch $@
|
|
|
|
|
2019-12-22 01:13:36 +01:00
|
|
|
.build/pytypereqs: .build/pycheckreqs
|
2019-12-21 23:56:47 +01:00
|
|
|
pip install pytype
|
2019-12-18 07:05:51 +01:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
.build/jsreqs: ts/package.json
|
|
|
|
(cd ts && npm i)
|
|
|
|
touch $@
|
|
|
|
|
2019-12-18 08:56:58 +01:00
|
|
|
# Typescript source
|
|
|
|
######################
|
|
|
|
|
|
|
|
TSDEPS := $(wildcard ts/src/*.ts)
|
|
|
|
JSDEPS := $(patsubst ts/src/%.ts, web/%.js, $(TSDEPS))
|
|
|
|
|
2019-12-18 07:05:51 +01:00
|
|
|
# Building
|
|
|
|
######################
|
2019-12-18 02:12:17 +01:00
|
|
|
|
2019-12-18 08:28:23 +01:00
|
|
|
BUILDDEPS := .build/ui .build/js
|
2019-12-18 02:12:17 +01:00
|
|
|
|
2019-12-22 01:13:36 +01:00
|
|
|
.build/ui: $(RUNREQS) $(shell find designer -type f)
|
2019-12-18 02:12:17 +01:00
|
|
|
./tools/build_ui.sh
|
|
|
|
touch $@
|
|
|
|
|
2019-12-22 01:13:36 +01:00
|
|
|
.build/js: $(RUNREQS) $(TSDEPS)
|
2019-12-18 07:05:51 +01:00
|
|
|
(cd ts && npm run build)
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
.PHONY: build clean
|
|
|
|
|
|
|
|
build: $(BUILDDEPS)
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
rm -rf .build
|
|
|
|
rm -rf $(JSDEPS)
|
|
|
|
|
|
|
|
# Running
|
|
|
|
######################
|
|
|
|
|
|
|
|
.PHONY: run
|
2019-12-18 02:12:17 +01:00
|
|
|
run: build
|
|
|
|
./runanki ${RUNARGS}
|
|
|
|
|
2019-12-18 07:05:51 +01:00
|
|
|
# Checking
|
|
|
|
######################
|
2019-12-18 02:12:17 +01:00
|
|
|
|
2019-12-18 07:05:51 +01:00
|
|
|
.PHONY: check
|
2019-12-21 23:56:47 +01:00
|
|
|
check: mypy pyimports pytest pylint checkpretty
|
2019-12-18 02:12:17 +01:00
|
|
|
|
2019-12-18 07:05:51 +01:00
|
|
|
# Checking python
|
|
|
|
######################
|
|
|
|
|
2019-12-22 01:13:36 +01:00
|
|
|
PYCHECKDEPS := $(BUILDDEPS) .build/pycheckreqs $(shell find anki aqt -name '*.py' | grep -v buildhash.py)
|
2019-12-18 02:12:17 +01:00
|
|
|
|
2019-12-22 01:13:36 +01:00
|
|
|
.build/mypy: $(PYCHECKDEPS)
|
2019-12-18 02:12:17 +01:00
|
|
|
mypy anki aqt
|
|
|
|
touch $@
|
|
|
|
|
2019-12-22 01:13:36 +01:00
|
|
|
.build/pytest: $(PYCHECKDEPS)
|
2019-12-18 02:12:17 +01:00
|
|
|
./tools/tests.sh
|
|
|
|
touch $@
|
|
|
|
|
2019-12-22 01:13:36 +01:00
|
|
|
.build/pylint: $(PYCHECKDEPS)
|
2019-12-18 02:12:17 +01:00
|
|
|
pylint -j 0 --rcfile=.pylintrc -f colorized --extension-pkg-whitelist=PyQt5 anki aqt
|
|
|
|
touch $@
|
|
|
|
|
2019-12-22 01:13:36 +01:00
|
|
|
.build/pyimports: $(PYCHECKDEPS)
|
|
|
|
isort -rc anki aqt --check # if this fails, run 'make fixpyimports'
|
2019-12-18 02:12:17 +01:00
|
|
|
touch $@
|
2019-12-18 03:53:13 +01:00
|
|
|
|
2019-12-22 01:13:36 +01:00
|
|
|
.build/pytype: $(PYCHECKDEPS) .build/pytypereqs
|
|
|
|
pytype --config pytype.conf
|
2019-12-20 10:19:03 +01:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
.PHONY: mypy pytest pylint pytype pyimports fixpyimports
|
2019-12-18 07:05:51 +01:00
|
|
|
mypy: .build/mypy
|
|
|
|
pytest: .build/pytest
|
|
|
|
pylint: .build/pylint
|
|
|
|
pytype: .build/pytype
|
2019-12-20 10:19:03 +01:00
|
|
|
pyimports: .build/pyimports
|
|
|
|
|
|
|
|
.PHONY: fixpyimports
|
|
|
|
|
|
|
|
fixpyimports:
|
|
|
|
isort -rc anki aqt
|
2019-12-18 07:05:51 +01:00
|
|
|
|
|
|
|
# Checking typescript
|
|
|
|
######################
|
2019-12-18 06:09:46 +01:00
|
|
|
|
2019-12-18 07:05:51 +01:00
|
|
|
TSCHECKDEPS := $(BUILDDEPS) $(TSDEPS)
|
2019-12-18 06:09:46 +01:00
|
|
|
|
2019-12-18 07:05:51 +01:00
|
|
|
.build/checkpretty: $(TSCHECKDEPS)
|
2019-12-20 11:37:03 +01:00
|
|
|
(cd ts && npm run check-pretty) # if this fails, run 'make pretty'
|
2019-12-18 06:09:46 +01:00
|
|
|
touch $@
|
|
|
|
|
2019-12-18 07:05:51 +01:00
|
|
|
.build/pretty: $(TSCHECKDEPS)
|
|
|
|
(cd ts && npm run pretty)
|
2019-12-18 06:09:46 +01:00
|
|
|
touch $@
|
|
|
|
|
2019-12-18 07:05:51 +01:00
|
|
|
.PHONY: pretty checkpretty
|
|
|
|
pretty: .build/pretty
|
|
|
|
checkpretty: .build/checkpretty
|