blob: 106cf3c346e1b5e2a3e6fa3d6043657d6dd85e5f (
plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# Copyright 2025 Dillution <[email protected]>.
#
# This file is part of DPIBreak.
#
# DPIBreak is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# DPIBreak is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with DPIBreak. If not, see <https://www.gnu.org/licenses/>.
PREFIX ?= /usr/local
MANPREFIX ?= $(PREFIX)/share/man
BUILD_TARGET ?= x86_64-unknown-linux-musl
PROJECT = DPIBreak
PROG = dpibreak
MAN = dpibreak.1
TARGET = target/$(BUILD_TARGET)/release/$(PROG)
VERSION := $(shell cargo metadata --format-version=1 --no-deps \
| jq -r '.packages[0].version')
SOURCE_DATE_EPOCH := $(shell git log -1 --format=%ct)
export SOURCE_DATE_EPOCH
.PHONY: all build install uninstall tarball clean
all: build
build:
cargo build --release --locked --target "$(BUILD_TARGET)"
$(PROG): $(TARGET)
cp "$<" "$@"
strip --strip-unneeded "$@"
install: $(PROG) $(MAN)
@echo "Installing DPIBreak..."
install -d "$(DESTDIR)$(PREFIX)/bin"
install -d "$(DESTDIR)$(MANPREFIX)/man1"
install -m 755 "$(PROG)" "$(DESTDIR)$(PREFIX)/bin/"
install -m 644 "$(MAN)" "$(DESTDIR)$(MANPREFIX)/man1/"
@echo "Installation complete."
uninstall:
@echo "Uninstalling DPIBreak..."
rm -f "$(DESTDIR)$(PREFIX)/bin/$(PROG)"
rm -f "$(DESTDIR)$(MANPREFIX)/man1/$(MAN)"
@echo "Uninstallation complete."
DIST_ELEMS = $(PROG) $(MAN) README.md CHANGELOG COPYING Makefile
DISTDIR = dist
DISTNAME = $(PROJECT)-$(VERSION)-$(BUILD_TARGET)
TARBALL = $(DISTDIR)/$(DISTNAME).tar.gz
SHA256 = $(TARBALL).sha256
BUILDINFO = $(DISTDIR)/$(DISTNAME).buildinfo
tarball: $(SHA256) $(BUILDINFO)
$(DISTDIR):
mkdir -p "$@"
$(DISTDIR)/$(DISTNAME): | $(DISTDIR)
mkdir -p "$@"
$(TARBALL): build $(DIST_ELEMS) | $(DISTDIR)/$(DISTNAME)
cp $(DIST_ELEMS) "$(DISTDIR)/$(DISTNAME)"
tar -C "$(DISTDIR)" \
--sort=name \
--mtime="@$(SOURCE_DATE_EPOCH)" \
--owner=0 --group=0 --numeric-owner \
-czf "$@" "$(DISTNAME)"
$(SHA256): $(TARBALL)
{ cd $(DISTDIR) && sha256sum "$(DISTNAME).tar.gz"; } > "$@"
$(BUILDINFO): | $(DISTDIR)
{ \
echo "Name: $(PROJECT)"; \
echo "Version: $(VERSION)"; \
echo "Commit: $$(git rev-parse HEAD)"; \
echo "Target: $(BUILD_TARGET)"; \
echo "Rustc: $$(rustc --version)"; \
echo "Cargo: $$(cargo --version)"; \
echo "Date: $$(date -u -d @$(SOURCE_DATE_EPOCH) +%Y-%m-%dT%H:%M:%SZ)"; \
echo "Host: $$(uname -srvmo)"; \
if command -v getconf >/dev/null 2>&1 && getconf GNU_LIBC_VERSION >/dev/null 2>&1; then \
echo "libc: $$(getconf GNU_LIBC_VERSION)"; \
else \
echo "libc: $$(ldd --version 2>&1 | head -n1 || true)"; \
fi; \
} > "$@"
clean:
rm -rf "$(PROG)" \
"$(DISTDIR)/$(DISTNAME)" \
"$(TARBALL)" \
"$(SHA256)" \
"$(BUILDINFO)"
cargo clean
.PHONY: help
help:
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@echo " all Build the project (default)"
@echo " build Build the release binary"
@echo " install Install the binary and man page"
@echo " uninstall Uninstall the binary and man page"
@echo " tarball Create a distributable tarball"
@echo " clean Remove build artifacts"
@echo " help Show this help message"
|