Files
disktree/Makefile
T
Tobi Lutke 1b5588f114 Install with make: binary, desktop entry and icon
`make install` puts disktree in ~/.local with a desktop entry for the
launcher and a file manager's "Open with" for directories. The build step
always asks cargo, so a stale binary is never installed.
2026-09-24 15:56:19 -05:00

87 lines
2.7 KiB
Makefile

# disktree: build, check, and install.
#
# `make install` puts the binary, a desktop entry and an icon under PREFIX
# (default: ~/.local), so disktree shows up in the Omarchy launcher and in
# "Open with" for directories. The default needs no root:
#
# make install # ~/.local/bin/disktree
# sudo make install PREFIX=/usr/local # system-wide
PREFIX ?= $(HOME)/.local
BINDIR ?= $(PREFIX)/bin
APPDIR ?= $(PREFIX)/share/applications
ICONDIR ?= $(PREFIX)/share/icons/hicolor/scalable/apps
MANIFEST = Cargo.toml
CARGO ?= cargo
TARGET = target/release/disktree
ICON = assets/disktree.svg
DESKTOP = packaging/disktree.desktop.in
.PHONY: help build run install uninstall lint test ci fmt clean
help:
@echo "disktree"
@echo
@echo " make build release build"
@echo " make run build and run, scanning $$HOME"
@echo " make install install to $(PREFIX): binary, desktop entry, icon"
@echo " make uninstall remove what install put there"
@echo " make lint rustfmt --check and clippy -D warnings"
@echo " make test core and window-harness tests"
@echo " make ci lint, then test"
@echo " make fmt format in place"
@echo " make clean cargo clean"
# Always ask cargo: it is incremental and knows every source file, where a
# make file-target would only compare the binary against the manifest and
# happily install a stale build.
build:
$(CARGO) build --release
run: build
$(TARGET)
lint:
$(CARGO) xtask lint
test:
$(CARGO) xtask test
ci: lint test
fmt:
$(CARGO) xtask fmt-fix
install: build
install -d $(BINDIR) $(APPDIR) $(ICONDIR)
install -m755 $(TARGET) $(BINDIR)/disktree
install -m644 $(ICON) $(ICONDIR)/disktree.svg
VERSION=$$(sed -n 's/^version = "\(.*\)"/\1/p' $(MANIFEST) | head -1) && \
sed -e 's|@BINDIR@|$(BINDIR)|' -e "s|@VERSION@|$$VERSION|" \
$(DESKTOP) > $(APPDIR)/disktree.desktop && \
chmod 644 $(APPDIR)/disktree.desktop
@if command -v update-desktop-database >/dev/null 2>&1; then \
update-desktop-database $(APPDIR) 2>/dev/null || true; \
fi
@echo
@echo "installed:"
@echo " $(BINDIR)/disktree"
@echo " $(APPDIR)/disktree.desktop"
@echo " $(ICONDIR)/disktree.svg"
@if command -v desktop-file-validate >/dev/null 2>&1; then \
desktop-file-validate $(APPDIR)/disktree.desktop || true; \
fi
@case ":$$PATH:" in *":$(BINDIR):"*) ;; *) \
echo; echo "note: $(BINDIR) is not on PATH in this shell";; esac
uninstall:
rm -f $(BINDIR)/disktree $(APPDIR)/disktree.desktop $(ICONDIR)/disktree.svg
@if command -v update-desktop-database >/dev/null 2>&1; then \
update-desktop-database $(APPDIR) 2>/dev/null || true; \
fi
@echo "removed"
clean:
$(CARGO) clean