Created
April 21, 2017 10:03
-
-
Save rottenbytes/ec7ddf95f1331d0e468da212d132a5af to your computer and use it in GitHub Desktop.
Makefile with loops
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OS = $(shell uname -s) | |
CONFIGS = $(wildcard *.js) | |
empty = | |
tab = $(empty)$(shell printf '\t')$(empty) | |
define execute-command | |
$(tab)$(1) | |
endef | |
what = $(foreach a,$(CONFIGS),./bin/dnscontrol-$(OS) -js $(a) preview${\n}) | |
fetch-binary: ## fetch dns control binary for your OS | |
@echo "Please wait while fetching your binary. It will be placed in bin/" | |
@mkdir -p bin | |
@curl -s -o bin/dnscontrol-$(OS) -L https://github.com/StackExchange/dnscontrol/releases/download/latest/dnscontrol-$(OS) | |
preview: ## preview changes for all files | |
@$(foreach a,$(CONFIGS),$(call execute-command,./bin/dnscontrol-$(OS) -js $(a) preview)) | |
push: ## push changes for all files | |
@$(foreach a,$(CONFIGS),$(call execute-command,./bin/dnscontrol-$(OS) -js $(a) push)) | |
.PHONY: help preview | |
.DEFAULT_GOAL := help | |
help: | |
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment