# grm version
VERSION = "$(shell grep 'version' Cargo.toml | cut -d '"' -f 2)"

nothing:
	@echo "Use \"make release\" or \"make debug\" to compile the binaries."
	@echo "See the other commands in Makefile."

debug:
	cargo build
	mkdir -p build/debug
	cp target/debug/grm-to-json build/debug
	cp target/debug/grm-definition-to-json build/debug

release:
	cargo build --release
	mkdir -p build/release
	cp target/release/grm-to-json build/release
	cp target/release/grm-definition-to-json build/release

test:
	cargo test

doc:
	cargo doc

fmt:
	cargo fmt

dist:
	mkdir grm-lib-$(VERSION)
	cp -r src grm-lib-$(VERSION)
	cp Makefile grm-lib-$(VERSION)
	cp Cargo.toml grm-lib-$(VERSION)
	zip -r grm-lib-$(VERSION).zip grm-lib-$(VERSION)
	rm -rf grm-lib-$(VERSION)

clean:
	rm -rf build
	rm -rf target
	rm -f Cargo.lock
	rm -rf grm-lib-$(VERSION).zip
	rm -rf grm-lib-$(VERSION)
	rm -f tags

check:
	cargo check

.PHONY: check clean debug dist doc fmt nothing release test
