MechMK1
MechMK1

Reputation: 3378

Makefile pattern in reverse order

As far as I understood makefile pattern rules, it's always to: from, e.g. %.o: %:c. However, when I tried making a simple pattern to turn .asm files to .o files, Make seems to interpret these patterns in reverse.

When writing %.o: %.asm, and calling it with make test.asm, I get make: Nothing to be done for 'test.asm'.
However, when I change the rule to %.asm: %.o (which would be against anything I have read in any tutorial), my pattern suddenly works.

What am I doing wrong and why does make behave that way? (My current test-Makefile looks like this. It should work, but does not)

%.o: %.asm
    echo Doing something

Upvotes: 0

Views: 464

Answers (1)

Colonel Thirty Two
Colonel Thirty Two

Reputation: 26579

In your invocation of make, you need to specify what you want to build, not the file you are building from.

Run make as make test.o

Upvotes: 2

Related Questions