Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. # Git revision, embedded in src/lib.rs
  11. GIT_REV = $(shell git rev-parse --short HEAD)
  12. # Binaries to be built
  13. BINS = darkfid faucetd drk darkirc vanityaddr tau taud
  14. # zkas dependencies
  15. ZKASDEPS = \
  16. Cargo.toml \
  17. bin/zkas/Cargo.toml \
  18. $(shell find src/zkas -type f) \
  19. $(shell find src/serial -type f) \
  20. $(shell find bin/zkas/src -type f)
  21. # ZK proofs to compile with zkas
  22. PROOFS_SRC = $(shell find proof -type f -name '*.zk') example/simple.zk
  23. PROOFS_BIN = $(PROOFS_SRC:=.bin)
  24. # Common dependencies which should force the binaries to be rebuilt
  25. BINDEPS = \
  26. Cargo.toml \
  27. $(shell find bin/*/src -type f) \
  28. $(shell find bin -type f -name '*.toml') \
  29. $(shell find src -type f) \
  30. all: $(BINS)
  31. rev:
  32. @grep -q "$(GIT_REV)" src/lib.rs || sed -e 's/@GIT_REV@/$(GIT_REV)/' -i src/lib.rs
  33. zkas: rev $(ZKASDEPS)
  34. $(CARGO) build $(TARGET_PRFX)$(RUST_TARGET) --all-features --release --package $@
  35. cp -f target/$(RUST_TARGET)/release/$@ $@
  36. $(PROOFS_BIN): zkas $(PROOFS_SRC)
  37. ./zkas $(basename $@) -o $@
  38. contracts: zkas
  39. $(MAKE) -C src/contract/money
  40. $(MAKE) -C src/contract/dao
  41. $(MAKE) -C src/contract/consensus
  42. $(MAKE) -C src/contract/deployooor
  43. $(BINS): contracts $(PROOFS_BIN) $(BINDEPS)
  44. $(CARGO) build $(TARGET_PRFX)$(RUST_TARGET) --all-features --release --package $@
  45. cp -f target/$(RUST_TARGET)/release/$@ $@
  46. check: contracts $(PROOFS_BIN)
  47. $(CARGO) hack check --release --feature-powerset --all
  48. fix: contracts $(PROOFS_BIN)
  49. $(CARGO) clippy --release --all-features --fix --allow-dirty --all
  50. fmt:
  51. $(CARGO) fmt
  52. clippy: contracts $(PROOFS_BIN)
  53. $(CARGO) clippy --release --all-features --all
  54. rustdoc: contracts $(PROOFS_BIN)
  55. $(CARGO) doc --release --all-features --workspace --document-private-items
  56. test: $(PROOFS_BIN) contracts
  57. $(CARGO) test --release --all-features --all
  58. test-no-run: $(PROOFS_BIN) contracts
  59. $(CARGO) test --release --all-features --all --no-run
  60. coverage: contracts $(PROOFS_BIN)
  61. $(CARGO) llvm-cov --release --all-features --workspace --html
  62. cleanbin:
  63. rm -f $(BINS)
  64. clean: cleanbin
  65. $(CARGO) clean
  66. install:
  67. @for i in $(BINS); \
  68. do \
  69. if test ! -f $$i; \
  70. then \
  71. echo "The '$$i' binary was not built."; \
  72. echo "You should run 'make BINS=$$i' as a normal user before installing."; \
  73. exit 1; \
  74. fi; \
  75. done;
  76. mkdir -p $(DESTDIR)$(PREFIX)/bin
  77. cp -f $(BINS) $(DESTDIR)$(PREFIX)/bin
  78. uninstall:
  79. for i in $(BINS); \
  80. do \
  81. rm -f $(DESTDIR)$(PREFIX)/bin/$$i; \
  82. done;
  83. .PHONY: all rev check fix fmt clippy test test-no-run cleanbin clean \
  84. install uninstall contracts coverage