in kernel Makefile
# Modules
/ %/: prepare scripts FORCE
$(cmd_crmodverdir)
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
$(build)=$(build-dir)
%.ko: prepare scripts FORCE
$(cmd_crmodverdir)
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
$(build)=$(build-dir) $(@:.ko=.o)
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
causing error Makefile mixed implicit and normal rules. (to first string on provided code)
I think something wrong with / %/ syntax, how can I repair it?
so far I’m thinking about separating rules this way:
# Modules
/: prepare scripts FORCE
$(cmd_crmodverdir)
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
$(build)=$(build-dir)
%/: prepare scripts FORCE
$(cmd_crmodverdir)
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
$(build)=$(build-dir)
%.ko: prepare scripts FORCE
$(cmd_crmodverdir)
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
$(build)=$(build-dir) $(@:.ko=.o)
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
But it’s confusing for me.
What do you think the
/ %/rule is doing (apart from confuse you andmake— and me)? What are you trying to achieve with the%/bit?You can have two (or more) targets on the left of the colon, but they both need to be percent-less.
The
%metacharacter cannot be used with a rule without any%in it, butmakeis interpreting:as similar to the
prog1 prog2example, but one of the targets has a%and the other does not, and you’re not allowed to mix these up. The/rule is the explicit rule; it appears to be instructions on how to update the root directory of your system. The%/is the implicit rule; it might be doing something related to making directories up to date.Copying some material up from the comments:
This notation should work (which is why I used it in the comment), but what I’d write in a
makefileis:If this still causes trouble, review what the first (the
/:) rule does. Are you sure it is needed?