Skip to content

Instantly share code, notes, and snippets.

@defanator
Last active February 28, 2018 06:23
Show Gist options
  • Save defanator/d82ac3a39917bb3aca685ab50172a230 to your computer and use it in GitHub Desktop.
Save defanator/d82ac3a39917bb3aca685ab50172a230 to your computer and use it in GitHub Desktop.
Makefile with implicit pattern rules - dependencies ordering example
OPTS = a b c
default:
@echo "try: make {all|base|opts}"
all: pattern-dep-all base opts
base: pattern-dep-base
@echo "base"
@touch $@
opts: $(addprefix opt-, $(OPTS))
opt-%: pattern-dep-%
@echo "opt-$*"
@touch $@
pattern-dep-%:
@echo "pattern-dep-$*"
@touch $@
clean:
@rm -f base opt-* pattern-dep-*
.PHONY: default all opts clean
.SECONDARY: $(addprefix pattern-dep-, $(OPTS))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment