Reputation: 4313
I have a naming convention that indicates that some executables depend on additional objects, e.g., targets of the form foo_test
depend on foo_test.o
and unit_tests.o
. Is it possible to specify a general rule in GNU make to capture this convention?
I tried the obvious, but it seems to have no effect:
%_test: unit_tests.o
Upvotes: 0
Views: 110
Reputation: 2792
You need to use the pattern specifier (%
) in both the target and one of its dependencies, and of course also specify the commands for the rule to make the target:
%_test: %_test.o unit_test.o
cc -o $@ $?
Upvotes: 1