Makefile 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. # zkas compiler binary
  11. ZKAS = ../../zkas
  12. # zkas circuits
  13. PROOFS_SRC = $(shell find proof -type f -name '*.zk')
  14. PROOFS_BIN = $(PROOFS_SRC:=.bin)
  15. SRC = \
  16. Cargo.toml \
  17. ../../Cargo.toml \
  18. $(shell find src -type f -name '*.rs') \
  19. $(shell find ../../src -type f -name '*.rs') \
  20. BIN = $(shell grep '^name = ' Cargo.toml | sed 1q | cut -d' ' -f3 | tr -d '"')
  21. all: $(BIN)
  22. $(PROOFS_BIN): $(ZKAS) $(PROOFS_SRC)
  23. $(ZKAS) $(basename $@) -o $@
  24. $(BIN): $(PROOFS_BIN) $(SRC)
  25. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build --target=$(RUST_TARGET) --release --package $@ --bin $@
  26. cp -f ../../target/$(RUST_TARGET)/release/$@ $@
  27. cp -f ../../target/$(RUST_TARGET)/release/$@ ../../$@
  28. # To build for android, install the Android NDK (Android Studio)
  29. # and then install cargo-ndk: `cargo install cargo-ndk`.
  30. # After that, add new android rust toolchains:
  31. # - rustup target add aarch64-linux-android
  32. # - rustup target add armv7-linux-androideabi
  33. # - rustup target add x86_64-linux-android
  34. # - rustup target add i686-linux-android
  35. $(BIN).android64:
  36. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) ndk -t arm64-v8a -o ./jniLibs build --release --package $(BIN)
  37. cp -f ../../target/aarch64-linux-android/release/$(BIN) $@
  38. # UNTESTED:
  39. #$(BIN).android32:
  40. # RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) ndk -t armeabi-v7a -o ./jniLibs build --release --package $(BIN)
  41. # cp -f ../../target/armv7-linux-androideabi/release/$(BIN) $(BIN).$@
  42. clean:
  43. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clean --target=$(RUST_TARGET) --release --package $(BIN)
  44. rm -f $(BIN) ../../$(BIN) $(BIN).android64 $(BIN).android32
  45. install: all
  46. mkdir -p $(DESTDIR)$(PREFIX)/bin
  47. cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin
  48. chmod 755 $(DESTDIR)$(PREFIX)/bin/$(BIN)
  49. uninstall:
  50. rm -f $(DESTDIR)$(PREFIX)/bin/$(BIN)
  51. .PHONY: all clean install uninstall