Makefile 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. .POSIX:
  2. # Install prefix
  3. PREFIX = $(HOME)/.cargo
  4. # Cargo binary
  5. CARGO = cargo +nightly
  6. # Optional compile target
  7. #RUST_TARGET = x86_64-unknown-linux-musl
  8. # Uncomment this if the above is uncommented
  9. #TARGET_PRFX = --target=
  10. # Binaries to be built
  11. BINS = darkfid faucetd darkirc vanityaddr tau taud
  12. # zkas dependencies
  13. ZKASDEPS = \
  14. Cargo.toml \
  15. bin/zkas/Cargo.toml \
  16. $(shell find src/zkas -type f) \
  17. $(shell find src/serial -type f) \
  18. $(shell find bin/zkas/src -type f)
  19. # ZK proofs to compile with zkas
  20. PROOFS_SRC = $(shell find proof -type f -name '*.zk') example/simple.zk
  21. PROOFS_BIN = $(PROOFS_SRC:=.bin)
  22. # Common dependencies which should force the binaries to be rebuilt
  23. BINDEPS = \
  24. Cargo.toml \
  25. $(shell find bin/*/src -type f) \
  26. $(shell find bin -type f -name '*.toml') \
  27. $(shell find src -type f) \
  28. all: $(BINS)
  29. zkas:
  30. $(MAKE) -C bin/zkas
  31. $(PROOFS_BIN): zkas $(PROOFS_SRC)
  32. ./zkas $(basename $@) -o $@
  33. contracts: zkas
  34. $(MAKE) -C src/contract/money
  35. $(MAKE) -C src/contract/dao
  36. $(MAKE) -C src/contract/consensus
  37. $(MAKE) -C src/contract/deployooor
  38. $(BINS): contracts $(PROOFS_BIN) $(BINDEPS)
  39. $(CARGO) build $(TARGET_PRFX)$(RUST_TARGET) --all-features --release --package $@
  40. cp -f target/$(RUST_TARGET)/release/$@ $@
  41. check: contracts $(PROOFS_BIN)
  42. $(CARGO) hack check --release --feature-powerset --all
  43. fix: contracts $(PROOFS_BIN)
  44. $(CARGO) clippy --release --all-features --fix --allow-dirty --all
  45. fmt:
  46. $(CARGO) fmt
  47. clippy: contracts $(PROOFS_BIN)
  48. $(CARGO) clippy --release --all-features --all
  49. rustdoc: contracts $(PROOFS_BIN)
  50. $(CARGO) doc --release --all-features --workspace --document-private-items --no-deps
  51. test: $(PROOFS_BIN) contracts
  52. $(CARGO) test --release --all-features --all
  53. test-no-run: $(PROOFS_BIN) contracts
  54. $(CARGO) test --release --all-features --all --no-run
  55. coverage: contracts $(PROOFS_BIN)
  56. $(CARGO) llvm-cov --release --all-features --workspace --html
  57. cleanbin:
  58. rm -f $(BINS)
  59. clean: cleanbin
  60. $(CARGO) clean
  61. install:
  62. @for i in $(BINS); \
  63. do \
  64. if test ! -f $$i; \
  65. then \
  66. echo "The '$$i' binary was not built."; \
  67. echo "You should run 'make BINS=$$i' as a normal user before installing."; \
  68. exit 1; \
  69. fi; \
  70. done;
  71. mkdir -p $(DESTDIR)$(PREFIX)/bin
  72. cp -f $(BINS) $(DESTDIR)$(PREFIX)/bin
  73. uninstall:
  74. for i in $(BINS); \
  75. do \
  76. rm -f $(DESTDIR)$(PREFIX)/bin/$$i; \
  77. done;
  78. .PHONY: all check fix fmt clippy test test-no-run cleanbin clean \
  79. install uninstall contracts coverage