Skip to content

unique-targets

Makefilesuspiciousno fixdefault: offmakefile/checkmake

Reports a target defined by more than one rule, which merges prerequisites and overrides recipes. Double-colon rules, .PHONY and the targets of the ignore option are not reported.

Several rules for one target add their prerequisites and only one of them may have a recipe; make uses the last and warns about the override. The recipe that runs depends on the order of the rules.

To fix, merge the rules, or rename a target.

Reported
a:
echo
a:
echo
b::
b::
.PHONY: a
.PHONY: b
...
d:
makefile:
lint:
rules:
unique-targets:
level: warn # off (default), warn, error
options:
ignore: []
Option Type Default Description
ignore list [] Targets that may be defined more than once.

Enabled by the presets: makefile/checkmake.

Suppress one line with sudsy-disable-next-line unique-targets in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
checkmake uniquetargets full