RedGrittyBrick
RedGrittyBrick

Reputation: 4002

Makefile without explicit targets

If I have a set of files *.foo that are "compiled" to a set of *.bar using a foo2bar some.foo "compiler" I can write a Makefile like this:

  %.bar: %.foo
    <tab>foo2bar $<

However if there are no *.bar yet, I can't just type something like make all and have all the *.bar produced.

How do I tell make to create all missing targets that match *.bar?

Upvotes: 1

Views: 73

Answers (1)

j&#248;rgensen
j&#248;rgensen

Reputation: 10549

Provided you are using GNU make (which you seem to be since you used the %-notation already):

all: $(patsubst %.foo,%.bar,$(wildcard *.foo))

Upvotes: 2

Related Questions