From ae49c28389cd947eb4e7e1173b6d4595b2f00cae Mon Sep 17 00:00:00 2001 From: giri256 <80974392+giri256@users.noreply.github.com> Date: Fri, 9 Oct 2026 10:55:09 +0000 Subject: [PATCH] Build into a fixed target directory Pass --target-dir to cargo so the library always ends up where the install target expects it, even if CARGO_TARGET_DIR or build.target-dir is set globally. The directory can still be changed with TARGET_DIR. Also depend on the source files instead of the src directory, so editing a file in place triggers a rebuild. Fixes #211 --- Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index c4a706f..786f4de 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ NAME = spotify-adblock PREFIX = /usr/local PROFILE ?= release -BINARY_SOURCE = target/$(PROFILE)/libspotifyadblock.so +TARGET_DIR ?= target +BINARY_SOURCE = $(TARGET_DIR)/$(PROFILE)/libspotifyadblock.so BINARY_TARGET = $(DESTDIR)$(PREFIX)/lib/$(NAME).so CONFIG_SOURCE = config.toml CONFIG_TARGET = $(DESTDIR)/etc/$(NAME)/config.toml @@ -9,12 +10,12 @@ CONFIG_TARGET = $(DESTDIR)/etc/$(NAME)/config.toml .PHONY: all all: $(BINARY_SOURCE) -$(BINARY_SOURCE): src Cargo.toml - cargo build --profile $(PROFILE) +$(BINARY_SOURCE): $(wildcard src/*.rs) Cargo.toml + cargo build --profile $(PROFILE) --target-dir $(TARGET_DIR) .PHONY: clean clean: - rm -rf target + rm -rf $(TARGET_DIR) .PHONY: install install: $(BINARY_SOURCE) $(CONFIG_SOURCE)