Makefile 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. .POSIX:
  2. # Install prefix
  3. PREFIX = $(HOME)/.cargo
  4. # Cargo binary
  5. CARGO = cargo +nightly
  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) fmt --all
  20. check:
  21. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) hack check --target=$(RUST_TARGET) \
  22. --release --feature-powerset --workspace
  23. clippy:
  24. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --target=$(RUST_TARGET) \
  25. --release --all-features --workspace --tests
  26. fix:
  27. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --target=$(RUST_TARGET) \
  28. --release --all-features --workspace --tests --fix --allow-dirty
  29. rustdoc:
  30. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) doc --target=$(RUST_TARGET) \
  31. --release --all-features --workspace --document-private-items --no-deps
  32. test:
  33. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) test --target=$(RUST_TARGET) \
  34. --release --all-features --workspace
  35. coverage:
  36. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) llvm-cov --target=$(RUST_TARGET) \
  37. --release --all-features --workspace --html
  38. clean:
  39. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clean --target=$(RUST_TARGET) --release --package $(BIN)
  40. rm -f $(BIN)
  41. distclean: clean
  42. rm -rf target
  43. install: all
  44. mkdir -p $(DESTDIR)$(PREFIX)/bin
  45. cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin
  46. chmod 755 $(DESTDIR)$(PREFIX)/bin/$(BIN)
  47. uninstall:
  48. rm -f $(DESTDIR)$(PREFIX)/bin/$(BIN)
  49. .PHONY: all fmt check clippy fix rustdoc test coverage clean distclean install uninstall