Makefile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 drk darkirc dnetview vanityaddr
  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: $(ZKASDEPS)
  30. $(CARGO) build $(TARGET_PRFX)$(RUST_TARGET) --all-features --release --package $@
  31. cp -f target/$(RUST_TARGET)/release/$@ $@
  32. $(PROOFS_BIN): zkas $(PROOFS_SRC)
  33. ./zkas $(basename $@) -o $@
  34. contracts: zkas
  35. $(MAKE) -C src/contract/money
  36. $(MAKE) -C src/contract/dao
  37. $(MAKE) -C src/contract/consensus
  38. $(MAKE) -C src/contract/deployooor
  39. $(BINS): contracts $(PROOFS_BIN) $(BINDEPS)
  40. $(CARGO) build $(TARGET_PRFX)$(RUST_TARGET) --all-features --release --package $@
  41. cp -f target/$(RUST_TARGET)/release/$@ $@
  42. check: contracts $(PROOFS_BIN)
  43. $(CARGO) hack check --release --feature-powerset --all
  44. fix: contracts $(PROOFS_BIN)
  45. $(CARGO) clippy --release --all-features --fix --allow-dirty --all
  46. clippy: contracts $(PROOFS_BIN)
  47. $(CARGO) clippy --release --all-features --all
  48. rustdoc: contracts $(PROOFS_BIN)
  49. $(CARGO) doc --release --all-features --workspace --document-private-items
  50. test: $(PROOFS_BIN) contracts
  51. $(CARGO) test --release --all-features --all
  52. test-no-run: $(PROOFS_BIN) contracts
  53. $(CARGO) test --release --all-features --all --no-run
  54. coverage: contracts $(PROOFS_BIN)
  55. $(CARGO) llvm-cov --release --all-features --workspace --html
  56. cleanbin:
  57. rm -f $(BINS)
  58. clean: cleanbin
  59. $(CARGO) clean
  60. install:
  61. @for i in $(BINS); \
  62. do \
  63. if test ! -f $$i; \
  64. then \
  65. echo "The '$$i' binary was not built."; \
  66. echo "You should run 'make BINS=$$i' as a normal user before installing."; \
  67. exit 1; \
  68. fi; \
  69. done;
  70. mkdir -p $(DESTDIR)$(PREFIX)/bin
  71. cp -f $(BINS) $(DESTDIR)$(PREFIX)/bin
  72. uninstall:
  73. for i in $(BINS); \
  74. do \
  75. rm -f $(DESTDIR)$(PREFIX)/bin/$$i; \
  76. done;
  77. .PHONY: all check fix clippy test test-no-run cleanbin clean \
  78. install uninstall contracts coverage