about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexey Yerin <yyp@disroot.org>2025-03-21 14:57:38 +0300
committerAlexey Yerin <yyp@disroot.org>2025-03-21 14:57:38 +0300
commit1f81aa0bbfd363b1d264b5b19ef086b5bdd1260e (patch)
tree51171590e0f31292f61778783a3e7d2ab0c7de65
parent100753a060bebb9ad33a2b56722a4e83faba3fea (diff)
Improve install and uninstall tasks
-rw-r--r--Makefile56
-rwxr-xr-xscripts/install-modules10
-rwxr-xr-xscripts/uninstall-modules9
3 files changed, 46 insertions, 29 deletions
diff --git a/Makefile b/Makefile
index 1456f25..9338dff 100644
--- a/Makefile
+++ b/Makefile
@@ -24,10 +24,10 @@ MODULES_GTK_SHARED = \
 	gi/cairo \
 	gi/pango \
 	gi/xlib
-MODULES_GTK3 = $(MODULES_CORE) $(MODULES_GTK_SHARED) \
+MODULES_GTK3 = \
 	gi/gdk \
 	gi/gtk
-MODULES_GTK4 = $(MODULES_CORE) $(MODULES_GTK_SHARED) \
+MODULES_GTK4 = \
 	gi/gdk4 \
 	gi/gtk4 \
 	gi/pangocairo \
@@ -49,36 +49,34 @@ hare-gi: $(HARE_GI_SRC) $(GIR_SRC) $(FORMAT_FASTXML_SRC)
 	./scripts/generate4
 	touch .gen
 
-install: hare-gi install-gtk3 install-gtk4
+install: hare-gi install-core install-gtk-shared install-gtk3 install-gtk4
 	install -Dm755 hare-gi "$(DESTDIR)$(BINDIR)"/hare-gi
 
+install-core: .gen
+	@./scripts/install-modules "$(DESTDIR)$(THIRDPARTYDIR)" $(MODULES_CORE)
+
+install-gtk-shared: .gen
+	@./scripts/install-modules "$(DESTDIR)$(THIRDPARTYDIR)" $(MODULES_GTK_SHARED)
+
 install-gtk3: .gen
-	@for mod in $(MODULES_GTK3); do \
-		printf "installing %s\n" "$$mod"; \
-		mkdir -p "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \
-		install -m644 "$$mod"/* "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \
-	done
+	@./scripts/install-modules "$(DESTDIR)$(THIRDPARTYDIR)" $(MODULES_GTK3)
 
 install-gtk4: .gen
-	@for mod in $(MODULES_GTK4); do \
-		printf "installing %s\n" "$$mod"; \
-		mkdir -p "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \
-		install -m644 "$$mod"/* "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \
-	done
-
-uninstall: uninstall3 uninstall4
-
-uninstall3:
-	@for mod in $(MODULES_GTK3); do \
-		printf "uninstalling %s\n" "$$mod"; \
-		rm -r "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \
-	done
-
-uninstall4:
-	@for mod in $(MODULES_GTK4); do \
-		printf "uninstalling %s\n" "$$mod"; \
-		rm -r "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \
-	done
+	@./scripts/install-modules "$(DESTDIR)$(THIRDPARTYDIR)" $(MODULES_GTK4)
+
+uninstall: uninstall-core uninstall-gtk-shared uninstall-gtk3 uninstall-gtk4
+
+uninstall-core:
+	@./scripts/uninstall-modules "$(DESTDIR)$(THIRDPARTYDIR)" $(MODULES_CORE)
+
+uninstall-gtk-shared:
+	@./scripts/uninstall-modules "$(DESTDIR)$(THIRDPARTYDIR)" $(MODULES_GTK_SHARED)
+
+uninstall-gtk3:
+	@./scripts/uninstall-modules "$(DESTDIR)$(THIRDPARTYDIR)" $(MODULES_GTK3)
+
+uninstall-gtk4:
+	@./scripts/uninstall-modules "$(DESTDIR)$(THIRDPARTYDIR)" $(MODULES_GTK4)
 
 demo3: .gen
 	hare build $(LIBS_3) -o demo3 cmd/demo3
@@ -90,6 +88,6 @@ clean:
 	rm -f hare-gi xmltree demo3 demo4 gi/*/_generate.ha
 
 .PHONY: all clean
-.PHONY: install install-gtk3 install-gtk4
-.PHONY: uninstall uninstall3 uninstall4
+.PHONY: install install-core install-gtk-shared install-gtk3 install-gtk4
+.PHONY: uninstall uninstall-core uninstall-gtk-shared uninstall-gtk3 uninstall-gtk4
 .PHONY: demo3 demo4
diff --git a/scripts/install-modules b/scripts/install-modules
new file mode 100755
index 0000000..5f61004
--- /dev/null
+++ b/scripts/install-modules
@@ -0,0 +1,10 @@
+#!/bin/sh -eu
+
+install_dir="$1"
+shift
+
+for mod; do
+	printf "installing %s\n" "$mod"
+	mkdir -p "$install_dir/$mod"
+	install -m644 "$mod"/* "$install_dir/$mod"
+done
diff --git a/scripts/uninstall-modules b/scripts/uninstall-modules
new file mode 100755
index 0000000..545c19d
--- /dev/null
+++ b/scripts/uninstall-modules
@@ -0,0 +1,9 @@
+#!/bin/sh -eu
+
+install_dir="$1"
+shift
+
+for mod; do
+	printf "uninstalling %s\n" "$mod"
+	rm -r "$install_dir/$mod"
+done