Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. .POSIX:
  2. # Install prefix
  3. PREFIX = $(HOME)/.cargo
  4. # Cargo binary
  5. CARGO = cargo
  6. # Flags passed to cargo/rustc
  7. #RUSTFLAGS = -C target-cpu=native
  8. # Optional compile target
  9. #RUST_TARGET = x86_64-unknown-linux-musl
  10. # Uncomment this if the above is uncommented
  11. #TARGET_PRFX = --target=
  12. # Binaries to be built
  13. BINS = drk darkfid ircd dnetview faucetd vanityaddr
  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. $(shell find contrib/token -type f)
  31. all: $(BINS)
  32. zkas: $(ZKASDEPS)
  33. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build $(TARGET_PRFX)$(RUST_TARGET) \
  34. --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. token_lists:
  43. $(MAKE) -C contrib/token all
  44. $(BINS): token_lists contracts $(PROOFS_BIN) $(BINDEPS)
  45. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build $(TARGET_PRFX)$(RUST_TARGET) \
  46. --all-features --release --package $@
  47. cp -f target/$(RUST_TARGET)/release/$@ $@
  48. check: token_lists contracts $(PROOFS_BIN)
  49. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) hack check --release --feature-powerset --all
  50. fix: token_lists contracts $(PROOFS_BIN)
  51. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --release --all-features --fix --allow-dirty --all
  52. clippy: token_lists contracts $(PROOFS_BIN)
  53. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --release --all-features --all
  54. rustdoc: token_lists contracts $(PROOFS_BIN)
  55. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) doc --release --all-features --workspace --document-private-items
  56. test: token_lists $(PROOFS_BIN) contracts
  57. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) test --release --all-features --all
  58. cleanbin:
  59. rm -f $(BINS)
  60. clean: cleanbin
  61. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clean
  62. install:
  63. @for i in $(BINS); \
  64. do \
  65. if test ! -f $$i; \
  66. then \
  67. echo "The '$$i' binary was not built."; \
  68. echo "You should run 'make BINS=$$i' as a normal user before installing."; \
  69. exit 1; \
  70. fi; \
  71. done;
  72. mkdir -p $(DESTDIR)$(PREFIX)/bin
  73. cp -f $(BINS) $(DESTDIR)$(PREFIX)/bin
  74. uninstall:
  75. for i in $(BINS); \
  76. do \
  77. rm -f $(DESTDIR)$(PREFIX)/bin/$$i; \
  78. done;
  79. .PHONY: all contracts token_lists check fix clippy rustdoc test cleanbin clean install uninstall