138 lines
6.9 KiB
Makefile
138 lines
6.9 KiB
Makefile
PYTHON ?= python3
|
|
PREFIX ?= $(HOME)/.local
|
|
BINDIR := $(PREFIX)/bin
|
|
SHAREDIR := $(PREFIX)/share/assembly-player
|
|
APPDIR := $(PREFIX)/share/applications
|
|
ICONDIR := $(PREFIX)/share/icons/hicolor
|
|
BUILDDIR := build
|
|
DISTDIR := dist
|
|
|
|
APT_PACKAGES := python3-gi python3-gi-cairo gir1.2-gtk-3.0 gir1.2-webkit2-4.1 \
|
|
gir1.2-ayatanaappindicator3-0.1 gir1.2-notify-0.7 gir1.2-rsvg-2.0
|
|
|
|
# Paquets requis à l'EXÉCUTION seulement (pas gir1.2-rsvg-2.0/gi-cairo, qui ne
|
|
# servent qu'à générer les icônes au moment du build, déjà incluses dans le .deb).
|
|
DEB_DEPENDS := python3-gi, gir1.2-gtk-3.0, gir1.2-webkit2-4.1, gir1.2-ayatanaappindicator3-0.1, gir1.2-notify-0.7
|
|
DEB_VERSION := $(shell $(PYTHON) -c "from assembly_player import __version__; print(__version__)")
|
|
DEB_ARCH := all
|
|
DEB_STAGE := $(BUILDDIR)/deb
|
|
DEB_PKG := $(DISTDIR)/assembly-player_$(DEB_VERSION)_$(DEB_ARCH).deb
|
|
|
|
.PHONY: help deps check-deps icons install uninstall deb run test clean autostart-enable autostart-disable
|
|
|
|
.DEFAULT_GOAL := help
|
|
|
|
help: ## 📖 Afficher cette aide
|
|
@echo ""
|
|
@echo " 🎬 \033[1mLecteur de sessions\033[0m — commandes disponibles (v$(DEB_VERSION))"
|
|
@echo " 📂 Préfixe d'installation : \033[2m$(PREFIX)\033[0m (make install PREFIX=... pour changer)"
|
|
@awk 'BEGIN {FS = ":.*?## "} \
|
|
/^##@/ {printf "\n\033[1m%s\033[0m\n", substr($$0, 5); next} \
|
|
/^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-22s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
|
@echo ""
|
|
|
|
##@ 🔧 Installation
|
|
|
|
check-deps: ## 🔍 Vérifier que les bibliothèques système requises sont installées
|
|
@$(PYTHON) -c "import gi; gi.require_version('Gtk','3.0'); gi.require_version('WebKit2','4.1'); from gi.repository import Gtk, WebKit2" \
|
|
|| { echo "❌ GTK3 / WebKit2GTK (4.1) introuvables. Lancez 'make deps'."; exit 1; }
|
|
@echo "✅ Dépendances Python/GTK présentes."
|
|
|
|
deps: ## 📥 Installer les paquets système requis (Debian/Ubuntu, sudo)
|
|
@command -v apt-get >/dev/null || { echo "❌ apt-get introuvable ; installez manuellement : $(APT_PACKAGES)"; exit 1; }
|
|
sudo apt-get update
|
|
sudo apt-get install -y $(APT_PACKAGES)
|
|
@echo "✅ Dépendances système installées."
|
|
|
|
icons: ## 🎨 Générer les icônes PNG (hicolor) à partir du SVG source
|
|
@$(PYTHON) -c "import gi; gi.require_version('Rsvg','2.0')" \
|
|
|| { echo "❌ gir1.2-rsvg-2.0 introuvable. Lancez 'make deps'."; exit 1; }
|
|
$(PYTHON) tools/gen_icons.py $(BUILDDIR)/icons
|
|
@echo "✅ Icônes générées dans $(BUILDDIR)/icons."
|
|
|
|
install: check-deps icons ## 🚀 Installer l'application (voir PREFIX ci-dessus)
|
|
install -d $(BINDIR) $(SHAREDIR) $(APPDIR)
|
|
cp -r assembly_player $(SHAREDIR)/
|
|
find $(SHAREDIR)/assembly_player -name '__pycache__' -type d -exec rm -rf {} +
|
|
sed -e 's#__PYTHONPATH__#$(SHAREDIR)#' packaging/assembly-player.in > $(BUILDDIR)/assembly-player
|
|
install -m 755 $(BUILDDIR)/assembly-player $(BINDIR)/assembly-player
|
|
install -m 644 packaging/assembly-player.desktop $(APPDIR)/assembly-player.desktop
|
|
@for size in 16 22 24 32 48 64 128 256 512; do \
|
|
install -d $(ICONDIR)/$${size}x$${size}/apps; \
|
|
install -m 644 $(BUILDDIR)/icons/$${size}x$${size}/apps/assembly-player.png $(ICONDIR)/$${size}x$${size}/apps/assembly-player.png; \
|
|
done
|
|
install -d $(ICONDIR)/scalable/apps
|
|
install -m 644 $(BUILDDIR)/icons/scalable/apps/assembly-player.svg $(ICONDIR)/scalable/apps/assembly-player.svg
|
|
@command -v update-desktop-database >/dev/null && update-desktop-database $(APPDIR) 2>/dev/null || true
|
|
@command -v gtk-update-icon-cache >/dev/null && gtk-update-icon-cache -f -t $(ICONDIR) 2>/dev/null || true
|
|
@echo "✅ Installé ! Lancez \033[1massembly-player\033[0m (vérifiez que $(BINDIR) est dans votre PATH)."
|
|
|
|
deb: check-deps icons ## 📦 Générer un paquet .deb dans dist/
|
|
@command -v dpkg-deb >/dev/null || { echo "❌ dpkg-deb introuvable (paquet dpkg)."; exit 1; }
|
|
rm -rf $(DEB_STAGE)
|
|
install -d $(DEB_STAGE)/DEBIAN $(DEB_STAGE)/usr/bin $(DEB_STAGE)/usr/share/assembly-player $(DEB_STAGE)/usr/share/applications
|
|
cp -r assembly_player $(DEB_STAGE)/usr/share/assembly-player/
|
|
find $(DEB_STAGE)/usr/share/assembly-player/assembly_player -name '__pycache__' -type d -exec rm -rf {} +
|
|
sed -e 's#__PYTHONPATH__#/usr/share/assembly-player#' packaging/assembly-player.in > $(DEB_STAGE)/usr/bin/assembly-player
|
|
chmod 755 $(DEB_STAGE)/usr/bin/assembly-player
|
|
install -m 644 packaging/assembly-player.desktop $(DEB_STAGE)/usr/share/applications/assembly-player.desktop
|
|
@for size in 16 22 24 32 48 64 128 256 512; do \
|
|
install -d $(DEB_STAGE)/usr/share/icons/hicolor/$${size}x$${size}/apps; \
|
|
install -m 644 $(BUILDDIR)/icons/$${size}x$${size}/apps/assembly-player.png $(DEB_STAGE)/usr/share/icons/hicolor/$${size}x$${size}/apps/assembly-player.png; \
|
|
done
|
|
install -d $(DEB_STAGE)/usr/share/icons/hicolor/scalable/apps
|
|
install -m 644 $(BUILDDIR)/icons/scalable/apps/assembly-player.svg $(DEB_STAGE)/usr/share/icons/hicolor/scalable/apps/assembly-player.svg
|
|
printf '%s\n' \
|
|
"Package: assembly-player" \
|
|
"Version: $(DEB_VERSION)" \
|
|
"Section: video" \
|
|
"Priority: optional" \
|
|
"Architecture: $(DEB_ARCH)" \
|
|
"Depends: $(DEB_DEPENDS)" \
|
|
"Maintainer: Johnny <infocpea@gmail.com>" \
|
|
"Description: Lecteur automatise de sessions d'assemblee (stream.jw.org)" \
|
|
" Lit automatiquement, dans l'ordre, les sessions video d'une assemblee sur" \
|
|
" un lien stream.jw.org configurable, avec reprise de lecture, demarrage" \
|
|
" automatique et icone dans la barre des taches (GNOME/Wayland)." \
|
|
" Projet non officiel, non affilie a jw.org / stream.jw.org." \
|
|
> $(DEB_STAGE)/DEBIAN/control
|
|
install -d $(DISTDIR)
|
|
dpkg-deb --build --root-owner-group $(DEB_STAGE) $(DEB_PKG)
|
|
@echo "✅ Paquet généré : \033[1m$(DEB_PKG)\033[0m"
|
|
@echo " 📀 Installation : sudo apt install ./$(DEB_PKG)"
|
|
|
|
uninstall: ## 🗑️ Désinstaller l'application (voir PREFIX ci-dessus)
|
|
rm -f $(BINDIR)/assembly-player
|
|
rm -rf $(SHAREDIR)
|
|
rm -f $(APPDIR)/assembly-player.desktop
|
|
@for size in 16 22 24 32 48 64 128 256 512; do \
|
|
rm -f $(ICONDIR)/$${size}x$${size}/apps/assembly-player.png; \
|
|
done
|
|
rm -f $(ICONDIR)/scalable/apps/assembly-player.svg
|
|
rm -f $(HOME)/.config/autostart/assembly-player.desktop
|
|
@echo "✅ Désinstallé."
|
|
|
|
##@ 💻 Développement
|
|
|
|
run: check-deps ## ▶️ Lancer l'application depuis les sources (développement)
|
|
$(PYTHON) -m assembly_player
|
|
|
|
test: ## 🧪 Vérifier que les modules Python compilent
|
|
$(PYTHON) -m py_compile assembly_player/*.py tools/gen_icons.py
|
|
@echo "✅ Compilation OK."
|
|
|
|
clean: ## 🧹 Supprimer les fichiers générés
|
|
rm -rf $(BUILDDIR)
|
|
find . -name '__pycache__' -type d -exec rm -rf {} +
|
|
@echo "✅ Nettoyé."
|
|
|
|
##@ ⏰ Démarrage automatique
|
|
|
|
autostart-enable: ## ✅ Activer le lancement automatique au démarrage du PC
|
|
@$(PYTHON) -c "from assembly_player import config; config.set_autostart(True)"
|
|
@echo "✅ Démarrage automatique activé."
|
|
|
|
autostart-disable: ## 🚫 Désactiver le lancement automatique au démarrage du PC
|
|
@$(PYTHON) -c "from assembly_player import config; config.set_autostart(False)"
|
|
@echo "✅ Démarrage automatique désactivé."
|