-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
219 lines (165 loc) · 9.34 KB
/
Copy pathMakefile
File metadata and controls
219 lines (165 loc) · 9.34 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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# recon — Makefile
#
# Run `make` or `make help` for the target list.
# Recipes use tabs (required by make).
BIN := recon
RELEASE_BIN := target/release/$(BIN)
DEBUG_BIN := target/debug/$(BIN)
MANUAL_MD := docs/MANUAL.md
MANUAL_PDF := docs/MANUAL.pdf
CARGO ?= cargo
# `impersonate` Cargo feature: opt-in TLS+H2 browser fingerprint impersonation
# via rquest (BoringSSL) + rquest_util. Off by default — enable via the
# *-impersonate targets below or by passing FEATURES="--features impersonate"
# to any standard target.
IMPERSONATE := --features impersonate
FEATURES ?=
.DEFAULT_GOAL := help
.PHONY: help build release all check test test-quiet fmt fmt-check clippy lint \
doc run install uninstall trim clean clean-all distclean size pdf \
flags examples bump-check ci \
build-impersonate release-impersonate all-impersonate \
check-impersonate test-impersonate run-impersonate \
install-impersonate ci-impersonate \
linux-deps linux tarball deb dist dist-clean-deb
help: ## Show this help
@awk 'BEGIN {FS = ":.*##"; printf "Usage: make \033[36m<target>\033[0m\n\nTargets:\n"} \
/^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-14s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
# ---------- build ----------
build: ## Debug build
$(CARGO) build $(FEATURES)
release: ## Release build (optimized); auto-trims stale artifacts afterward
$(CARGO) build --release $(FEATURES)
@$(MAKE) --no-print-directory trim
all: build release ## Build both debug and release (per project convention)
build-impersonate: ## Debug build with TLS browser-fingerprint impersonation (BoringSSL; first build is slow)
$(CARGO) build $(IMPERSONATE)
release-impersonate: ## Release build with TLS browser-fingerprint impersonation; auto-trims afterward
$(CARGO) build --release $(IMPERSONATE)
@$(MAKE) --no-print-directory trim
all-impersonate: build-impersonate release-impersonate ## Both builds with --features impersonate
check: ## Fast type-check without producing a binary
$(CARGO) check --all-targets $(FEATURES)
check-impersonate: ## Fast type-check with --features impersonate
$(CARGO) check --all-targets $(IMPERSONATE)
# ---------- test / lint ----------
test: ## Run all tests
$(CARGO) test $(FEATURES)
test-impersonate: ## Run all tests with --features impersonate
$(CARGO) test $(IMPERSONATE)
test-quiet: ## Run tests with minimal output
$(CARGO) test --quiet $(FEATURES)
fmt: ## Format the codebase
$(CARGO) fmt --all
fmt-check: ## Verify formatting without modifying files
$(CARGO) fmt --all -- --check
clippy: ## Run clippy with warnings denied
$(CARGO) clippy --all-targets -- -D warnings
lint: fmt-check clippy ## fmt-check + clippy
# ---------- run / install ----------
run: ## Run the debug binary (use ARGS="..." to pass arguments)
$(CARGO) run $(FEATURES) -- $(ARGS)
run-impersonate: ## Run the impersonate-feature debug binary (use ARGS="..." to pass arguments)
$(CARGO) run $(IMPERSONATE) -- $(ARGS)
install: release ## Install the release binary into ~/.cargo/bin
$(CARGO) install --path . --force $(FEATURES)
install-impersonate: release-impersonate ## Install recon with --features impersonate into ~/.cargo/bin
$(CARGO) install --path . --force $(IMPERSONATE)
uninstall: ## Remove the installed binary
$(CARGO) uninstall $(BIN) || true
# ---------- docs ----------
doc: ## Build rustdoc for this crate (no deps)
$(CARGO) doc --no-deps
pdf: release ## Regenerate docs/MANUAL.pdf from MANUAL.md (requires agent-browser on PATH)
$(RELEASE_BIN) --md-to-pdf $(MANUAL_MD) \
--toc --toc-depth 3 --gfm \
--unsafe-html --page-break-on-h1 \
--doc-title 'recon User Manual' \
-o $(MANUAL_PDF)
flags: release ## Print recon --flags (useful for the per-flag checklist)
$(RELEASE_BIN) --flags
examples: release ## Print recon --examples
$(RELEASE_BIN) --examples
# ---------- cleaning ----------
# Number of most-recent recon binary copies to keep in each profile's deps/.
# Override per-invocation: `make trim KEEP=1`.
KEEP ?= 2
# The $(BIN)-* glob matches more than the binary copies: per-CGU object files
# ($(BIN)-<hash>.<crate>-<hash>...-cgu.N.rcgu.o), .rmeta, and .d all share the
# prefix. The pipeline below anchors on /$(BIN)-[0-9a-f]+$ to keep ONLY the
# executables (hex hash, no extension), so trim never deletes codegen objects
# the linker still needs mid-build (the historical .rcgu.o "no such file"
# link failure). Do not relax that anchor to a bare `grep -v '\.d$'`.
trim: ## Prune stale build artifacts (keep newest KEEP=2 recon binaries; drop old-toolchain cruft) — incremental-safe
@$(CARGO) sweep --installed >/dev/null 2>&1 || true
@for prof in release debug; do \
dir="target/$$prof/deps"; \
[ -d "$$dir" ] || continue; \
ls -t "$$dir"/$(BIN)-* 2>/dev/null \
| grep -E "/$(BIN)-[0-9a-f]+$$" \
| tail -n +$$(($(KEEP)+1)) \
| while read -r f; do rm -f "$$f" "$$f.d"; done; \
done
@echo "trim: kept newest $(KEEP) $(BIN) binary copies per profile; swept old-toolchain artifacts"
clean: ## Remove the entire target/ directory (use this to reclaim disk)
$(CARGO) clean
clean-all: clean ## clean + remove generated rustdoc, dist/, and stray artefacts
rm -rf target/doc dump.rdb $(DIST)
distclean: clean-all ## clean-all + drop Cargo.lock (rarely needed)
rm -f Cargo.lock
# ---------- linux cross-build / debian packaging ----------
# Cross-compiles the DEFAULT recon build (includes ssh) from macOS to Linux
# via cargo-zigbuild, then packages .deb via cargo-deb. No impersonate variant.
# `bundled-sqlite` vendors sqlite (zig's Linux sysroot has no libsqlite3).
# Requires zig, cargo-zigbuild, cargo-deb, and the two rustup targets
# (run `make linux-deps`). See README "Building Debian packages".
DIST := dist
LINUX_AMD64 := x86_64-unknown-linux-gnu
LINUX_ARM64 := aarch64-unknown-linux-gnu
LINUX_AMD64_MUSL := x86_64-unknown-linux-musl
LINUX_ARM64_MUSL := aarch64-unknown-linux-musl
GLIBC := 2.28
VERSION := $(shell grep -m1 '^version' Cargo.toml | sed -E 's/.*"([^"]+)".*/\1/')
linux-deps: ## Check Linux cross-build prerequisites; print install hints if missing
@command -v zig >/dev/null 2>&1 || { echo "missing: zig — brew install zig"; exit 1; }
@command -v cargo-zigbuild >/dev/null 2>&1 || { echo "missing: cargo-zigbuild — cargo install cargo-zigbuild"; exit 1; }
@command -v cargo-deb >/dev/null 2>&1 || { echo "missing: cargo-deb — cargo install cargo-deb"; exit 1; }
@rustup target list --installed | grep -q '^$(LINUX_AMD64)$$' || { echo "missing rustup target: $(LINUX_AMD64) — rustup target add $(LINUX_AMD64)"; exit 1; }
@rustup target list --installed | grep -q '^$(LINUX_ARM64)$$' || { echo "missing rustup target: $(LINUX_ARM64) — rustup target add $(LINUX_ARM64)"; exit 1; }
@rustup target list --installed | grep -q '^$(LINUX_AMD64_MUSL)$$' || { echo "missing rustup target: $(LINUX_AMD64_MUSL) — rustup target add $(LINUX_AMD64_MUSL)"; exit 1; }
@rustup target list --installed | grep -q '^$(LINUX_ARM64_MUSL)$$' || { echo "missing rustup target: $(LINUX_ARM64_MUSL) — rustup target add $(LINUX_ARM64_MUSL)"; exit 1; }
@echo "linux cross-build prerequisites OK"
linux: linux-deps ## Cross-build the release binary for amd64 + arm64, glibc + musl
$(CARGO) zigbuild --release --features bundled-sqlite --target $(LINUX_AMD64).$(GLIBC)
$(CARGO) zigbuild --release --features bundled-sqlite --target $(LINUX_ARM64).$(GLIBC)
$(CARGO) zigbuild --release --features bundled-sqlite --target $(LINUX_AMD64_MUSL)
$(CARGO) zigbuild --release --features bundled-sqlite --target $(LINUX_ARM64_MUSL)
tarball: linux ## Package each Linux binary + LICENSE + README into dist/*.tar.gz
mkdir -p $(DIST)
tar -czf $(DIST)/recon-$(VERSION)-x86_64-linux.tar.gz -C target/$(LINUX_AMD64)/release recon -C $(CURDIR) LICENSE README.md
tar -czf $(DIST)/recon-$(VERSION)-aarch64-linux.tar.gz -C target/$(LINUX_ARM64)/release recon -C $(CURDIR) LICENSE README.md
tar -czf $(DIST)/recon-$(VERSION)-x86_64-linux-musl.tar.gz -C target/$(LINUX_AMD64_MUSL)/release recon -C $(CURDIR) LICENSE README.md
tar -czf $(DIST)/recon-$(VERSION)-aarch64-linux-musl.tar.gz -C target/$(LINUX_ARM64_MUSL)/release recon -C $(CURDIR) LICENSE README.md
deb: linux ## Build .deb packages for amd64 + arm64 into dist/
mkdir -p $(DIST)
$(CARGO) deb --no-build --no-strip --target $(LINUX_AMD64) --output $(DIST)/
$(CARGO) deb --no-build --no-strip --target $(LINUX_ARM64) --output $(DIST)/
$(CARGO) deb --no-build --no-strip --variant musl --target $(LINUX_AMD64_MUSL) --output $(DIST)/
$(CARGO) deb --no-build --no-strip --variant musl --target $(LINUX_ARM64_MUSL) --output $(DIST)/
dist: linux tarball deb ## Build all Linux artifacts (binaries, tarballs, .debs) into dist/
@echo "── dist/ ──"; ls -1 $(DIST)
dist-clean-deb: ## Remove the dist/ directory
rm -rf $(DIST)
# ---------- diagnostics ----------
size: ## Show disk usage of target/ subdirectories
@if [ -d target ]; then \
du -sh target target/debug target/release target/doc 2>/dev/null | sort -hr; \
else \
echo "target/ does not exist"; \
fi
# ---------- meta ----------
bump-check: ## Show current version + release date
@grep -E '^version' Cargo.toml | head -1
@grep -E 'RELEASE_DATE' src/version.rs | head -1
ci: fmt-check clippy test ## What CI should run: format check, lint, tests
ci-impersonate: fmt-check clippy test test-impersonate ## CI plus a build+test pass with --features impersonate