# Generated by yjcli (managed — regenerated when platforms or plugins change).
# Windows: use make.ps1 with the same targets.
# Each target only calls tools/<tool>/<platform>/<tool>.sh; see tools/<tool>/GUIDE.md.

PLATFORMS := {{platforms}}
{{#if builder}}
BUILD_TARGETS := $(foreach p,$(PLATFORMS),$(p)-build-development $(p)-build-production)
{{/if}}
{{#if deployer}}
DEPLOY_TARGETS := $(foreach p,$(PLATFORMS),$(p)-deploy-development $(p)-deploy-production)
{{/if}}

.PHONY: help{{#if runner}} $(PLATFORMS){{/if}}{{#if builder}} $(BUILD_TARGETS){{#if platform_proto}} proto-build{{/if}}{{/if}}{{#if deployer}} $(DEPLOY_TARGETS){{/if}}

help:
	@echo "Usage:"
{{#if runner}}
	@echo "  make <platform> [NAME=<service>]               # run locally (tools/runner)"
{{/if}}
{{#if builder}}
	@echo "  make <platform>-build-<env> [NAME=<service>]   # build into dist/ (tools/builder)"
{{#if platform_proto}}
	@echo "  make proto-build [PROTO_LANG=<language>]       # generate proto/dist/<language>/ (tools/builder/proto)"
{{/if}}
{{/if}}
{{#if deployer}}
	@echo "  make <platform>-deploy-<env> [NAME=<service>]  # deploy dist/ (tools/deployer)"
{{/if}}
	@echo "  <env>: development | production"
	@echo ""
	@echo "Platforms: $(PLATFORMS)"
{{#if runner}}

$(PLATFORMS):
	@test -x "tools/runner/$@/runner.sh" || (echo "missing: tools/runner/$@/runner.sh"; exit 1)
	@"tools/runner/$@/runner.sh" $(NAME)
{{/if}}
{{#if builder}}

$(BUILD_TARGETS):
	@p="$(word 1,$(subst -build-, ,$@))"; e="$(word 2,$(subst -build-, ,$@))"; \
	test -x "tools/builder/$$p/builder.sh" || { echo "missing: tools/builder/$$p/builder.sh"; exit 1; }; \
	"tools/builder/$$p/builder.sh" "$$e" $(NAME)
{{#if platform_proto}}

proto-build:
	@test -x "tools/builder/proto/builder.sh" || (echo "missing: tools/builder/proto/builder.sh"; exit 1)
	@"tools/builder/proto/builder.sh" $(PROTO_LANG)
{{/if}}
{{/if}}
{{#if deployer}}

$(DEPLOY_TARGETS):
	@p="$(word 1,$(subst -deploy-, ,$@))"; e="$(word 2,$(subst -deploy-, ,$@))"; \
	test -x "tools/deployer/$$p/deployer.sh" || { echo "missing: tools/deployer/$$p/deployer.sh"; exit 1; }; \
	"tools/deployer/$$p/deployer.sh" "$$e" $(NAME)
{{/if}}
