Microsoft KB Archive/25951

Inference Rule Fails when Used with Macros ID Number: Q25951

4.06 MS-DOS

Problem:

MAKE does not correctly handle inference rules when they are used with macros. MAKE recognizes that the destination file does not exist and that the file needs to be built, but it does not invoke the commands in the inference rule needed to create the destination file.

The same macros work properly when used without inference rules, as the following MAKE file demonstrates:


 * 1) this make file works fine

source1=source1.src source2=source2.src destination=dest.dst

$(destination): $(source1) $(source2) type $(source1) > $(destination) type $(source2) >> $(destination) The following is the same MAKE file modified to use inference rules in addition to the macros:


 * 1) this make file does not work correctly

source1=source1.src source2=source2.src destination=dest.dst

.src.dst: type $(source1) > $(destination) type $(source2) >> $(destination)

$(destination): $(source1) $(source2) The inference rule correctly identifies that “dest.dst” does not exist and needs to be built, but it does not invoke the “type” commands to build it.

Response:

This is not a problem in MAKE. It is an example of the incorrect use of inference rules. The inference rule (.src.dst) only applies to files that have the same base name, as in the following:

program.src program.dst

Because the example uses different base names (source1.src, source2.src, and dest.dst), it would be incorrect for the inference rule to act upon these files.

If the filenames contained in the macros are changed to the following, then the inference rule works properly (even with macros) because source1.src and source1.dst have the same base name:

source1.src source2.src source1.dst