The concept is called pattern rules. You can read about it in GNU make manual.
$(GRAPHDIR)/%.png: $(GRAPHDIR)/%.dot
dot $< -Tpng -o $@
graphs: $(patsubst %,$(GRAPHDIR)/%.png, Complex Simple IFileReader McCabe)
or just
%.png: %.dot
dot $< -Tpng -o $@
graphs: $(patsubst %,$(GRAPHDIR)/%.png, Complex Simple IFileReader McCabe)
You can also remove all repetition by extracting one of the patterns into a separate variable PNG_PATTERN
like so:
PNG_pattern=$(GRAPHDIR)/%.png
$(PNG_pattern): $(GRAPHDIR)/%.dot
dot $< -Tpng -o $@
graphs: $(patsubst %,$(PNG_pattern), Complex Simple IFileReader McCabe)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…