Re: Bug in pattern rule parsing: how to handle?

2008-10-29 Thread Sam Ravnborg
On Sun, Oct 26, 2008 at 07:12:53PM -0400, Paul Smith wrote:
 On Sun, 2008-10-26 at 23:15 +0100, Sam Ravnborg wrote:
  Can you give me a more precise pointer where we have this issue
  so I can get it fixed.  I guess it is Makefile.build...
 
 If you mean in the Linux kernel there are two places:
 
 Makefile:1601: *** mixed implicit and normal rules.  Stop.
 
 # Modules
 / %/: prepare scripts FORCE

Here we try to catch that the following targets can be specified:
make /
make foobar/
make foo/bar/

I have this wake memory that I had some troubles initially
when I did this. Most likely I did it the other way around:

%/ /: bla bla

and it did not work.
But later I chenged the order and suddenly it worked.

But you imply that it is not acceptable to mix it
like I do.

And this one looks easy to fix. I can rewrite it like this:

%/: prepare scripts FORCE

And we are happy.

 and:
 
 Makefile:442: *** mixed implicit and normal rules.  Stop.
 
 config %config: scripts_basic outputmakefile FORCE
 $(Q)mkdir -p include/linux include/config
 $(Q)$(MAKE) $(build)=scripts/kconfig $@

Here I try to catch the following:

make config
make menuconfig
make xconfig
make foobarconfig

I must admit I cannot see the problem with mixing implicit and normal
rules in the above. But I gues this is my simple use of it.
Do you have any god suggestion how to rewrite this?

Note: %onfig:  works but I would hate to use it.

Sam


___
Bug-make mailing list
Bug-make@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-make


Re: Bug in pattern rule parsing: how to handle?

2008-10-29 Thread Philip Guenther
On Wed, Oct 29, 2008 at 2:12 PM, Sam Ravnborg [EMAIL PROTECTED] wrote:
 On Sun, Oct 26, 2008 at 07:12:53PM -0400, Paul Smith wrote:
...
 Makefile:442: *** mixed implicit and normal rules.  Stop.

 config %config: scripts_basic outputmakefile FORCE
 $(Q)mkdir -p include/linux include/config
 $(Q)$(MAKE) $(build)=scripts/kconfig $@

 Here I try to catch the following:

 make config
 make menuconfig
 make xconfig
 make foobarconfig

 I must admit I cannot see the problem with mixing implicit and normal
 rules in the above. But I gues this is my simple use of it.

I see at least two ways in which it's confusing:
1) what prerequisites does foo have with this rule:
foo %.c: %.c.real
@: cp $ $@

2) rules with multiple pattern targets have special meaning to make:
   Pattern rules may have more than one target.  Unlike normal rules,
   this does not act as many different rules with the same prerequisites
   and commands.  If a pattern rule has multiple targets, `make' knows that
   the rule's commands are responsible for making all of the targets.  ...
I.e., this rule:
%.a %.b:
${commands}
says that building bar.a will also build bar.b, and
building quux.a will also build quux.b.  With this rule:
foo %.a %.b:
${commands}
should make assume that building bar.a will also build bar.b
*and* foo?
How about this rule:
foo blip %.a %.b:
${commands}
Will building bar.a also build bar.b, foo, and blip?
How about this one:
foo blip %.a:
${commands}
...whoops...


 Do you have any god suggestion how to rewrite this?

Option 1: if make config is really the same as make fooconfig,
then actually set that equivalence in the makefile with something
like:

config: fooconfig
%config: scripts_basic outputmakefile FORCE
$(Q)mkdir -p include/linux include/config
$(Q)$(MAKE) $(build)=scripts/kconfig $@



Option 2: if the list of config types is basically static, then just
list them explicitly:

CONFIG_TARGETS = config menuconfig xconfig foobarconfig
${CONFIG_TARGETS}: scripts_basic outputmakefile FORCE
$(Q)mkdir -p include/linux include/config
$(Q)$(MAKE) $(build)=scripts/kconfig $@


Option 3: if the list of config targets really does change regularly
or needs to be open-ended, then I would go with

CONFIG_DEP = scripts_basic outputmakefile FORCE
define CONFIG_COMMANDS
$(Q)mkdir -p include/linux include/config
$(Q)$(MAKE) $(build)=scripts/kconfig $@
endef

# normal and pattern targets are immiscible in a single rule
config: ${CONFIG_DEP}; ${CONFIG_COMMANDS}
%config: ${CONFIG_DEP}; ${CONFIG_COMMANDS}


(The version using $(eval) and $(foreach) is just icky looking in my mind)


Philip Guenther


___
Bug-make mailing list
Bug-make@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-make