Commit fec0ded465

fec0ded465b8dec05e1963b88590666c657febd7

parent: a2fd1932b2

Unsigned

Darafei Praliaskouski <me@komzpa.net> · 2026-07-05 13:37 UTC
committer: <strk@kbt.io>

build: split system and user install targets

Layout: unified · split

Makefile +21 −3
@@ -1,12 +1,18 @@
1# See https://weechat.org/files/doc/weechat/stable/weechat_user.en.html#xdg_directories 1# See https://weechat.org/files/doc/weechat/stable/weechat_user.en.html#xdg_directories
2XDG_DATA_HOME ?= $(HOME)/.local/share 2XDG_DATA_HOME ?= $(HOME)/.local/share
3WEECHAT_DATA_DIR ?= $(XDG_DATA_HOME)/weechat 3WEECHAT_DATA_DIR ?= $(XDG_DATA_HOME)/weechat
4DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null)
5ifeq ($(DEB_HOST_MULTIARCH),)
6WEECHAT_PLUGIN_DIR ?= /usr/lib/weechat/plugins
7else
8WEECHAT_PLUGIN_DIR ?= /usr/lib/$(DEB_HOST_MULTIARCH)/weechat/plugins
9endif
4 10
5SOURCES := $(wildcard src/*.rs src/bar_items/*.rs src/commands/*.rs src/room/*.rs Cargo.lock) 11SOURCES := $(wildcard src/*.rs src/bar_items/*.rs src/commands/*.rs src/room/*.rs Cargo.lock)
6 12
7PROFILE ?= release 13PROFILE ?= release
8 14
9.PHONY: install install-dir lint all help deb 15.PHONY: install install-user uninstall uninstall-user install-dir install-user-dir lint all help deb
10 16
11all: help 17all: help
12 18
@@ -19,10 +25,22 @@ target/debug/libmatrix.so: $(SOURCES) ## Build plugin in dev profile
19target/release/libmatrix.so: $(SOURCES) ## Build plugin release profile 25target/release/libmatrix.so: $(SOURCES) ## Build plugin release profile
20 cargo build --release 26 cargo build --release
21 27
22install: install-dir target/$(PROFILE)/libmatrix.so ## Install plugin to weechat dir 28install: install-dir target/$(PROFILE)/libmatrix.so ## Install plugin systemwide
29 install -m644 target/$(PROFILE)/libmatrix.so $(DESTDIR)$(WEECHAT_PLUGIN_DIR)/matrix.so
30
31install-user: install-user-dir target/$(PROFILE)/libmatrix.so ## Install plugin to user WeeChat dir
23 install -m644 target/$(PROFILE)/libmatrix.so $(DESTDIR)$(WEECHAT_DATA_DIR)/plugins/matrix.so 32 install -m644 target/$(PROFILE)/libmatrix.so $(DESTDIR)$(WEECHAT_DATA_DIR)/plugins/matrix.so
24 33
25install-dir: ## Create plugins directory 34uninstall: ## Remove systemwide plugin
35 rm -f $(DESTDIR)$(WEECHAT_PLUGIN_DIR)/matrix.so
36
37uninstall-user: ## Remove plugin from user WeeChat dir
38 rm -f $(DESTDIR)$(WEECHAT_DATA_DIR)/plugins/matrix.so
39
40install-dir:
41 install -d $(DESTDIR)$(WEECHAT_PLUGIN_DIR)
42
43install-user-dir:
26 install -d $(DESTDIR)$(WEECHAT_DATA_DIR)/plugins 44 install -d $(DESTDIR)$(WEECHAT_DATA_DIR)/plugins
27 45
28lint: ## Lint issues with clippy 46lint: ## Lint issues with clippy
README.md +25 −3
@@ -55,9 +55,26 @@ On Linux this creates a `libmatrix.so` file in the `target/release/`
55(`target/debug` for dev builds) folder. Rename it to `matrix.so` and copy it to 55(`target/debug` for dev builds) folder. Rename it to `matrix.so` and copy it to
56your WeeChat plugin directory. 56your WeeChat plugin directory.
57 57
58`make install` uses WeeChat's XDG data directory by default: 58`make install` installs the plugin systemwide:
59 59
60 make install 60 sudo make install
61
62On Debian-like multiarch systems this installs the release build to:
63
64 /usr/lib/${DEB_HOST_MULTIARCH}/weechat/plugins/matrix.so
65
66On other systems it defaults to:
67
68 /usr/lib/weechat/plugins/matrix.so
69
70Set `WEECHAT_PLUGIN_DIR` if your distribution uses another system plugin
71directory:
72
73 sudo make install WEECHAT_PLUGIN_DIR=/path/to/weechat/plugins
74
75To install only for the current user, use:
76
77 make install-user
61 78
62This installs the release build to: 79This installs the release build to:
63 80
@@ -65,7 +82,12 @@ This installs the release build to:
65 82
66Use `PROFILE=debug` for a debug build: 83Use `PROFILE=debug` for a debug build:
67 84
68 make install PROFILE=debug 85 make install-user PROFILE=debug
86
87The matching uninstall targets are:
88
89 sudo make uninstall
90 make uninstall-user
69 91
70On older WeeChat setups the plugin directory may instead live under 92On older WeeChat setups the plugin directory may instead live under
71`$WEECHAT_HOME/plugins`, commonly `~/.weechat/plugins/`. Create the directory if 93`$WEECHAT_HOME/plugins`, commonly `~/.weechat/plugins/`. Create the directory if