Question

I have a set of files of type *.x, processing which yields a corresponding set of files *.x.y (where each *.x file produces a corresponding *.x.y file). Simple enough so far.

The two issues I have are:

  1. The set of *.x files keeps changing, so I don't want to use their names as a static list in the dependency portion of a rule.
  2. I only want to process those *.x files that have a size greater than 0.

Currently I use:

for a in $(find . -iname '*.x' -size +0); do make $a.y; done

and it works, but I'd prefer a cleaner, more make-y solution.

Using GNU make 3.81 on OS X 10.7.5.

Was it helpful?

Solution

You can compute the list of source files with a shell function:

SRCFILES := $(shell find . -iname '*.x' -size +0)

OUTFILES := $(SRCFILES:%=%.y)

all: $(OUTFILES)

%.x.y : %.x
        $(CONVERT) -to $@ $<
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top