Makefile 875 B

12345678910111213141516171819202122232425262728293031323334353637
  1. .POSIX:
  2. # Install prefix
  3. PREFIX = $(HOME)/.cargo
  4. # Cargo binary
  5. CARGO = cargo
  6. # Compile target
  7. RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
  8. # Uncomment when doing musl static builds
  9. #RUSTFLAGS = -C target-feature=+crt-static -C link-self-contained=yes
  10. SRC = \
  11. Cargo.toml \
  12. $(shell find src -type f -name '*.rs') \
  13. BIN = $(shell grep '^name = ' Cargo.toml | cut -d' ' -f3 | tr -d '"')
  14. all: $(BIN)
  15. $(BIN): $(SRC)
  16. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build --target=$(RUST_TARGET) --release --package $@
  17. cp -f target/$(RUST_TARGET)/release/$@ $@
  18. fmt:
  19. $(CARGO) +nightly fmt --all
  20. clippy:
  21. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --target=$(RUST_TARGET) \
  22. --release --all-features --workspace --tests
  23. clean:
  24. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clean --target=$(RUST_TARGET) --release --package $(BIN)
  25. rm -f $(BIN)
  26. .PHONY: all fmt clippy clean