Jeremy Edwards
Jeremy Edwards

Reputation: 14740

Makefile pattern rule targets for pattern part

Is there a way to have a parameterized Makefile target. I'm trying to use wildcards but I cannot seem to make it work.

The problem is that I just want the % part. Since I need to generate some paths.

bin/bootstrap.ino.bin: bin/
    $(ARDUINO_BUILDER) $(BUILD_FLAGS) bootstrap/bootstrap.ino

bin/sensorscan.ino.bin: bin/
    $(ARDUINO_BUILDER) $(BUILD_FLAGS) sensorscan/sensorscan.ino

bin/httpprober.ino.bin: bin/
    $(ARDUINO_BUILDER) $(BUILD_FLAGS) httpprober/httpprober.ino

To something like:

bin/%.ino.bin: bin/
    $(ARDUINO_BUILDER) $(BUILD_FLAGS) %/%.ino

Upvotes: 0

Views: 29

Answers (1)

MadScientist
MadScientist

Reputation: 100816

The automatic variable $* expands to the stem of the target ("the pattern part"). See Automatic Variables in the GNU make manual.

Upvotes: 2

Related Questions