gnu make pattern rule matches the wrong rule

Viewed 128

In the following example, when building all, the target main-gs-universalk9-m.o seems to match with rule 1 instead of rule 2. In make version 3.81 I thought order mattered. Even if I moved rule 2 to be defined before rule 1. It still ends up matching rule 1

What is the right way to code this and make it work as expected?

$(info .FEATURES := $(.FEATURES))


%.o:
    @echo "Rule 1 $?"
    rm -f $@
    cp $*.c $@

main-gs-%-m.o: file1.o file2.o file3.o
    @echo "Rule 2"
    cat $? > $@

binos_%_version.o:
    @echo "Rule 3"
    echo "Hello World" > $@

x86-%-m: main-gs-%-m.o binos_%_version.o
    @echo "Rule 4"
    cat $? > $@

all: x86-universalk9-m

clean:
    @echo "Rule Cleaning"
    rm -f *.o
    rm -f x86-universalk9-m
1 Answers
Related