-1

I have a bunch of .dot files (for example, a.dot, b.dot, c.dot) and I want to compile them to .png files with neato. Currently, the make command I have to do that looks something like this:

neato -Tpng -o a.png a.dot
neato -Tpng -o b.png b.dot
neato -Tpng -o c.png c.dot

Obviously, this is completely non-scalable, and I'd like to write something that will take every file with a .dot extension, and compile it to an equivalently-named .png file. I'm not sure how to write such a loop in make - any help would be appreciated.

Koz Ross
  • 3,040
  • 2
  • 24
  • 44

1 Answers1

1

This is pretty much basic make 101:

SRCS = a.dot b.dot c.dot

OBJS = $(SRCS:%.dot=%.png)

all: $(OBJS)

%.png : %.dot
        neato -Tpng -o $@ $<

You don't do "loops" in make; you define targets and prerequisites.

MadScientist
  • 92,819
  • 9
  • 109
  • 136