The Function wildcard $(wildcard pattern ...) This string, used anywhere in a makefile, is replaced by a space-separated list of names of existing files that match one of the given file name patterns. If no existing file name matches a pattern, then that pattern is omitted from the output of the wildcard function.
By default, the goal is the first target in the makefile (not counting targets that start with a period). Therefore, makefiles are usually written so that the first target is for compiling the entire program or programs they describe.
Note that the targets will be built in the order they were passed to the command line, so the first target to be built here is all , followed by clean (which again is nonsense). If you want to read more about how to correctly use makefiles, I suggest you to grab the book Managing Projects with GNU Make.
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)
Just in case you actually want to generate a .PNG for every .DOT within current directory:
%.png : %.dot
dot -Tpng -o $@ $<
all: $(addsuffix .png, $(basename $(wildcard *.dot)))
I came up with this Makefile after reading the answer from @Pavel.
I think you want some pattern rules. Try this out.
TARGETS = $(GRAPHDIR)/Complex.png \
$(GRAPHDIR)/Simple.png \
$(GRAPHDIR)/IFileReader.png \
$(GRAPHDIR)/McCabe-linear.png
%.png : %.dot
dot $^ -Tpng -o $@
graphs: $(TARGETS)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With