-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (59 loc) · 2.49 KB
/
Copy pathMakefile
File metadata and controls
65 lines (59 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Makefile for spkrd - speaker device network server
#
# Targets: all, clean, install
# Variables: DSTDIR (default /usr/local), PROGRAM, PROFILE
#
# install auto-detects the OS via uname(1): on Linux it installs a systemd
# user unit (lib/systemd/user/) so the service runs in the user session and
# has access to PulseAudio/PipeWire; on FreeBSD it installs the rc.d script.
# Shell conditionals are used in the recipe (rather than make-level ifeq/.if
# directives) so that this Makefile remains compatible with GNU make and BSD make.
# Configuration variables
DSTDIR ?= /usr/local
PROGRAM ?= spkrd
# PROFILE can be 'dev' for debugging
PROFILE ?= release
TARGET_DIR = target/$(PROFILE)
BINARY_PATH = $(TARGET_DIR)/$(PROGRAM)
CARGO_FLAGS = --profile $(PROFILE)
# Optional Cargo features to enable. When empty (the default) the build
# recipe auto-detects jack/pulseaudio/pipewire via pkg-config and enables
# each feature whose system library is present. Override to force a specific
# set or to disable auto-detection: make FEATURES=jack,pulseaudio
FEATURES ?=
# Default target
.PHONY: all clean install
all: $(BINARY_PATH)
$(BINARY_PATH):
@_F="$(FEATURES)"; \
if [ -z "$$_F" ]; then \
pkg-config --exists jack 2>/dev/null && _F="$${_F:+$$_F,}jack" || true; \
pkg-config --exists libpulse 2>/dev/null && _F="$${_F:+$$_F,}pulseaudio" || true; \
pkg-config --exists libpipewire-0.3 2>/dev/null && _F="$${_F:+$$_F,}pipewire" || true; \
fi; \
FLAGS="$(CARGO_FLAGS)$${_F:+ --features $$_F}"; \
echo "cargo build $$FLAGS"; \
cargo build $$FLAGS
clean:
cargo clean
install: $(BINARY_PATH)
install -d $(DSTDIR)/bin
install -m 755 $(TARGET_DIR)/$(PROGRAM) $(DSTDIR)/bin/$(PROGRAM)
@OS=$$(uname -s); \
if [ "$$OS" = "Linux" ]; then \
install -d $(DSTDIR)/lib/systemd/user; \
install -m 644 systemd/$(PROGRAM).service $(DSTDIR)/lib/systemd/user/$(PROGRAM).service; \
echo ""; \
echo "Systemd user unit installed to $(DSTDIR)/lib/systemd/user/$(PROGRAM).service"; \
echo "To enable and start for the current user:"; \
echo " systemctl --user daemon-reload"; \
echo " systemctl --user enable $(PROGRAM)"; \
echo " systemctl --user start $(PROGRAM)"; \
echo "To auto-start on boot without login:"; \
echo " loginctl enable-linger \$$USER"; \
elif [ "$$OS" = "FreeBSD" ]; then \
install -d $(DSTDIR)/etc/rc.d; \
install -m 755 rc.d/$(PROGRAM) $(DSTDIR)/etc/rc.d/$(PROGRAM); \
else \
echo "Unknown operating system. Please set up the service to start automatically on boot."; \
fi