# grm version
VERSION = "$(shell grep 'VERSION :' src/grm.js | cut -d '"' -f 2)"

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

release:
	@echo "Note: it does the same thing as \"make debug\" but put things in the \"release\" directory."
	@echo ""
	rm -rf build/release
	mkdir -p build/release
	cp src/grm.js build/release/grm.js
	cp src/grm.js build/release/grm_to_json.js
	echo "" >> build/release/grm_to_json.js
	cat src/bin/grm_to_json.js >> build/release/grm_to_json.js
	cp helpers/grm-to-json build/release
	cp src/grm.js build/release/grm_definition_to_json.js
	echo "" >> build/release/grm_definition_to_json.js
	cat src/bin/grm_definition_to_json.js >> build/release/grm_definition_to_json.js
	cp helpers/grm-definition-to-json build/release
	@echo "Scripts generated in build/release"

debug:
	@echo "Note: it does the same thing as \"make release\" but put things in the \"debug\" directory."
	@echo ""
	rm -rf build/debug
	mkdir -p build/debug
	cp src/grm.js build/debug/grm.js
	cp src/grm.js build/debug/grm_to_json.js
	echo "" >> build/debug/grm_to_json.js
	cat src/bin/grm_to_json.js >> build/debug/grm_to_json.js
	cp helpers/grm-to-json build/debug
	cp src/grm.js build/debug/grm_definition_to_json.js
	echo "" >> build/debug/grm_definition_to_json.js
	cat src/bin/grm_definition_to_json.js >> build/debug/grm_definition_to_json.js
	cp helpers/grm-definition-to-json build/debug
	@echo "Scripts generated in build/debug"

clean:
	rm -rf build
	rm -rf doc
	rm -f tags

doc:
	@echo "No documentation generated because jsdoc 2.4 is completely buggy."
	@echo "It cannot generate the documentation for the @typedef."
	@echo "It cannot generate the documentation from member functions of a prototyped instance."
	@echo "I wasted too many time for this crap."
	@echo ""
	@echo "And no way I install npm to get the last version of jsdoc!"
	@echo "JavaScript developers' culture on library dependency is out of control!"
	@echo ""
	@echo "Because I cannot test if the documentation is correct, I did not write one."
	@echo "You can refer to the documentation of other parsers or read the code which is straightforward."

fmt:
	@echo "No formatter because uglifyjs removes line breaks."

lint:
	eslint src/bin/grm_definition_to_json.js src/bin/grm_to_json.js src/grm.js

.PHONY: nothing release debug clean lib dist doc lint
