[Techtalk] Re: Loop/wildcard-like syntax for GNU make?

Wim De Smet kromagg at gmail.com
Thu Apr 19 17:34:43 UTC 2007


On 4/19/07, Michelle Konzack <linux4michelle at freenet.de> wrote:
> Am 2007-04-18 09:28:51, schrieb Conor Daly:
> > This works for a straight cp and should work with convert also:
> >
> > all:
> >       for FILE in *.png; do \
> >               cp -f $$FILE $$(basename "$$FILE" png)jpg; \
> >       done;
>
> Please read the manual to gnu make why you should avoid shell loops.
>
> Why not:
> -----------------------------------------------
> GIFS := $(wildcard *.gif)
>
> all: $(GIFS)
>
> $(GIFS):
>         convert $@ $(patsubst %.gif,%,$@).jpg
>
> .PHONY: all $(GIFS)

I think that last line should read:
.PHONY: all
since $(GIFS) actually points to real files, otherwise your makefile
is probably going to always/never update the files.

greets,
Wim


More information about the Techtalk mailing list