diff --git a/Makefile b/Makefile index a62a126ea..d60ec5ea7 100644 --- a/Makefile +++ b/Makefile @@ -1,35 +1,56 @@ # mruby is using Rake (https://ruby.github.io/rake/) as a build tool. RAKE = rake +DOCKER_COMPOSE = docker-compose +PRE_COMMIT = pre-commit -all : +define check_command + @command -v $(1) >/dev/null 2>&1 || { \ + echo "Error: $(1) is not installed or not in PATH."; \ + exit 1; \ + } +endef + +all : check_rake $(RAKE) .PHONY : all -test : all +test : check_rake all $(RAKE) test .PHONY : test -clean : +clean : check_rake $(RAKE) clean .PHONY : clean -check : - pre-commit run --all-files +check : check_pre_commit + $(PRE_COMMIT) run --all-files .PHONY : check -checkinstall : - pre-commit install +checkinstall : check_pre_commit + $(PRE_COMMIT) install .PHONY : checkinstall -checkupdate : - pre-commit autoupdate +checkupdate : check_pre_commit + $(PRE_COMMIT) autoupdate .PHONY : checkupdate -composecheck : - docker-compose -p mruby run test pre-commit run --all-files +composecheck : check_docker_compose check_pre_commit + $(DOCKER_COMPOSE) -p mruby run test $(PRE_COMMIT) run --all-files .PHONY : composecheck -composetest : - docker-compose -p mruby run test +composetest : check_docker_compose + $(DOCKER_COMPOSE) -p mruby run test .PHONY : composetest + +check_rake: + $(call check_command, $(RAKE)) +.PHONY : check_rake + +check_docker_compose: + $(call check_command, $(DOCKER_COMPOSE)) +.PHONY : check_docker_compose + +check_pre_commit: + $(call check_command, $(PRE_COMMIT)) +.PHONY : check_pre_commit