-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (71 loc) · 3.06 KB
/
Copy pathMakefile
File metadata and controls
85 lines (71 loc) · 3.06 KB
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
# gknowledge — build & install
#
# `make install` performs a local (per-user) install using the system
# PyGObject, so it works out of the box on Ubuntu/Fedora/Arch without touching
# pip's externally-managed environment. Use PREFIX=/usr with sudo for a
# system-wide install.
APP_ID := io.gknowledge.Gknowledge
PYTHON ?= python3
PREFIX ?= $(HOME)/.local
DESTDIR ?=
BINDIR := $(PREFIX)/bin
LIBDIR := $(PREFIX)/share/gknowledge
DATADIR := $(PREFIX)/share
APPSDIR := $(DATADIR)/applications
ICONDIR := $(DATADIR)/icons/hicolor/scalable/apps
METAINFODIR := $(DATADIR)/metainfo
INSTALL := install
.PHONY: all help check test run dev install uninstall clean dist flatpak
all: help
help:
@echo "gknowledge — targets:"
@echo " make run Run the app from the source tree"
@echo " make test Run the headless core test suite"
@echo " make check Byte-compile all sources (syntax check)"
@echo " make install Install locally into $(PREFIX)"
@echo " make uninstall Remove a local install"
@echo " make dist Build a wheel/sdist with the Python build backend"
@echo " make flatpak Build a Flatpak (needs flatpak-builder)"
@echo " make clean Remove build artifacts"
check:
$(PYTHON) -m compileall -q gknowledge
test:
$(PYTHON) tests/test_core.py
run:
$(PYTHON) -m gknowledge
dev: run
install:
@echo ">> Installing gknowledge into $(DESTDIR)$(PREFIX)"
$(INSTALL) -d $(DESTDIR)$(LIBDIR)
cp -r gknowledge $(DESTDIR)$(LIBDIR)/
$(PYTHON) -m compileall -q $(DESTDIR)$(LIBDIR)/gknowledge || true
# Launcher that uses the installed package with the system PyGObject.
$(INSTALL) -d $(DESTDIR)$(BINDIR)
printf '#!/bin/sh\nexport PYTHONPATH="%s:$$PYTHONPATH"\nexec %s -m gknowledge "$$@"\n' \
"$(LIBDIR)" "$(PYTHON)" > $(DESTDIR)$(BINDIR)/gknowledge
chmod +x $(DESTDIR)$(BINDIR)/gknowledge
# Desktop entry, icon and AppStream metadata.
$(INSTALL) -d $(DESTDIR)$(APPSDIR)
$(INSTALL) -m 644 data/$(APP_ID).desktop $(DESTDIR)$(APPSDIR)/$(APP_ID).desktop
$(INSTALL) -d $(DESTDIR)$(ICONDIR)
$(INSTALL) -m 644 data/icons/hicolor/scalable/apps/$(APP_ID).svg $(DESTDIR)$(ICONDIR)/$(APP_ID).svg
$(INSTALL) -d $(DESTDIR)$(METAINFODIR)
$(INSTALL) -m 644 data/$(APP_ID).metainfo.xml $(DESTDIR)$(METAINFODIR)/$(APP_ID).metainfo.xml
-update-desktop-database $(DESTDIR)$(APPSDIR) 2>/dev/null || true
-gtk-update-icon-cache -f -t $(DESTDIR)$(DATADIR)/icons/hicolor 2>/dev/null || true
@echo ">> Done. Make sure $(BINDIR) is on your PATH, then run: gknowledge"
uninstall:
rm -f $(DESTDIR)$(BINDIR)/gknowledge
rm -rf $(DESTDIR)$(LIBDIR)
rm -f $(DESTDIR)$(APPSDIR)/$(APP_ID).desktop
rm -f $(DESTDIR)$(ICONDIR)/$(APP_ID).svg
rm -f $(DESTDIR)$(METAINFODIR)/$(APP_ID).metainfo.xml
@echo ">> Uninstalled gknowledge from $(PREFIX)"
dist:
$(PYTHON) -m build
flatpak:
flatpak-builder --user --install --force-clean build-aux/flatpak-build \
build-aux/flatpak/$(APP_ID).yaml
clean:
rm -rf build dist *.egg-info build-aux/flatpak-build .pytest_cache
find gknowledge -name '__pycache__' -type d -exec rm -rf {} + 2>/dev/null || true