Frage

Consider the following makefile:

default: foo.o

clean:
    rm -f fmake test_second
%.o: %.c
    echo This is customized implicit rule

%.o: %.c
    echo This is overriden implicit rule

The output of the make command is

echo This is overriden implicit rule
This is overriden implicit rule

This is ok. However, if the makefile is instead:

default: foo.o

clean:
    rm -f fmake test_second
%.o: %.c
    echo This is customized implicit rule

%.o: %.z
    echo This is overriden implicit rule

then the output of the make command is

echo This is customized implicit rule
This is customized implicit rule

I expected that it would be the same as in the first example. Why is it different? I have a both foo.c and foo.z files in a makefile's directory.

War es hilfreich?

Lösung

You can build an object file from all different kinds of source files: from C files, C++ files, FORTRAN files, etc. In make, a rule only overrides if BOTH the target and the prerequisite patterns match. Otherwise, it just defines a new way to build the target using a different prerequisite.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top