On Thu, 2024-07-25 at 12:01 +0900, Masahiro Yamada wrote: > .%.dtb.checked must be executed after %.dtb, not before. > It is not so simple as adding $(a_prereq).
Thanks this version of your question is much more useful than the initial version. The above paragraph is the key information which was missing from your initial question. In make, everything is a matter of order and dependencies so we always need that to be made clear. In this case, you need to create an extra prerequisite layer on top of the two you already have. In other words, something like this: ifdef CHECK_DTB dtb_prereq = checked else dtb_prereq = built endif %.dtb: .%.dtb.$(dtb_prereq) ; .%.dtb.built: %.dts [ compile the device tree--creates %.dtb ] @touch $@ .%.dtb.checked: .%.dtb.built [ check the schema ] @touch $@ Be sure you add the semicolon to the %.dtb rule to create an empty recipe, else it won't work it all.