Is there a way to override the prerequisites of a target in later part of Makefile?
A common Makefile is used by multiple users. To accommodate individual unique usage, an include directive is added at the end.
E.g. in common.make
SomeVar1 =
all: step5
step1:
recipe1
step2: step1
recipe2
step3: step2
recipe3
step4: step3
recipe4
step5: step4
recipe5
-include local.make
Whenever necessary, individual user can override variables or even recipes from common.make in his/her own local.make.
However, it seems prerequisite from common.make can't be overridden in local.make.
E.g. if a user needs to skip step3 & step4, adding the following in local.make doesn't remove step4 as prerequisite for step5 target.
step5: step2
Does GNU make have some syntax to force override prerequisites of targets defined in earlier part of Makefile?
Perhaps, something like:
.OVERRIDE: step5: step2
The only way I can think of is to define prerequisites of each rule in common.make as variables. But it will be unwieldy for large numbers of steps -- lots of variables to define and association/mapping of variable names to their steps requires separate documentations.
I would like to avoid the prerequisite-variable approach if possible. Hopefully, GNU make has some syntax that can do so better.
Thank you for your help.
HCN
.OVERRIDE:
approach; you still need one statement specific to each rule you want to override, containing a description of the dependency relationship you want. – Beta