groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] MAKE_K_FLAG


From: Pascal Stumpf
Subject: Re: [Groff] MAKE_K_FLAG
Date: Tue, 10 Jan 2012 13:06:11 +0100

Hi,

On Tue, 10 Jan 2012 03:15:46 +0100, Bruno Haible wrote:
> Hi,
> 
> Werner asked me to answer this.
> 
> Ingo Schwarze wrote:
> > Pascal Stumpf drew my attention to the fact that the following line
> > in the top-level Makefile.in is causing trouble:
> > 
> >   MAKE_K_FLAG=`case "$(MAKEFLAGS)" in *k*) echo ' -k ';; esac`
> > 
> > The problem is that *any* k character anywhere in MAKEFLAGS,
> > for example coming from something like
> > 
> >   make ... FOO=k ...
> > 
> > is mistaken for a -k flag, forcing some parts of the build to
> > ignore errors even when that is not desired, making errors harder
> > to spot.
> 
> Indeed. The test Makefile found in
> http://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.68/html_
> node/The-Make-Macro-MAKEFLAGS.html
> confirms what you say.
> 
> Makefiles generated by Automake use this idiom:
> 
>         for f in x $$MAKEFLAGS; do \
>           case $$f in \
>             *=* | --[!k]*);; \
>             *k*) keepgoing=yes;; \
>           esac; \
>         done; \
> 
> > Pascal found
> > 
> >   http://lists.gnu.org/archive/html/groff/2006-01/msg00075.html
> > 
> > but we don't quite understand the reasoning given there, as
> > both BSD make and GNU make pass down -k to recursive make
> > child processes anyway, without doing anything special.
> > 
> > So it seems one could just remove MAKE_K_FLAG completely
> > without any adverse effect
> 
> I cannot confirm what you say. With GNU make, I get:
> 
> $ cat Makefile
> MAKE_K_FLAG=`case "$(MAKEFLAGS)" in *k*) echo ' -k ';; esac`
> 
> all :
>         echo MAKE='$(MAKE)', MAKEFLAGS='$(MAKEFLAGS)'
>         $(MAKE) $(MAKEFLAGS) foo

You don't use $(MAKE) $(MAKEFLAGS).  $(MAKEFLAGS) will always affect
recursive $(MAKE) invocations, even if you don't see the flags on
the command line.  Trying to use it this way is even wrong for GNU make,
since its format is quite different to the flags as they have been
passed on the command line.  For instance, 'gmake -k FOO=k' will result
in MAKEFLAGS == 'k -- FOO=k'.

Consider this example:

$ cat Makefile
all:
        echo $(MAKEFLAGS)
        cd sub && $(MAKE)
$ cat sub/Makefile
all:
        echo $(MAKEFLAGS)
$ gmake -k
echo k
k
cd sub && gmake
gmake[1]: Entering directory `/home/pascal/src/mystuff/gmake/sub'
echo wk
wk
gmake[1]: Leaving directory `/home/pascal/src/mystuff/gmake/sub'
$ 

So make will automatically pass down anything in $(MAKEFLAGS).
MAKE_K_FLAG is unnecessary.

>         $(MAKE) $(MAKE_K_FLAG) foo
> 
> foo :
> 
> $ make
> echo MAKE='make', MAKEFLAGS=''
> MAKE=make, MAKEFLAGS=
> make  foo
> ...
> 
> $ make -k
> echo MAKE='make', MAKEFLAGS='k'
> MAKE=make, MAKEFLAGS=k
> make k foo
> ...
> 
> $ make FOO=kit
> echo MAKE='make', MAKEFLAGS='FOO=kit'
> MAKE=make, MAKEFLAGS=FOO=kit
> make FOO=kit foo
> ...
> 
> $ make -k FOO=kit
> echo MAKE='make', MAKEFLAGS='k -- FOO=kit'
> MAKE=make, MAKEFLAGS=k -- FOO=kit
> make k -- FOO=kit foo
> ...
> 
> Looking back at
> http://lists.gnu.org/archive/html/groff/2006-01/msg00075.html
> the right thing to do IMO is to fix the definition of MAKE_K_FLAG:
> Please replace the line
> 
>   MAKE_K_FLAG=`case "$(MAKEFLAGS)" in *k*) echo ' -k ';; esac`
> 
> with
> 
>   MAKE_K_FLAG=`for f in x $(MAKEFLAGS); do \
>                  case $$f in \
>                    *=* | --[!k]*);; \
>                    *k*) echo ' -k ';; \
>                  esac; \
>                done`
> 
> Bruno
> 
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]