Re: docs: fix MAKEFLAGS testing example

2011-01-26 Thread Eli Zaretskii
> Date: Wed, 26 Jan 2011 21:34:25 +0100
> From: Ralf Wildenhues 
> 
>  You can write a conditional that tests @code{make} command flags such as
> -@samp{-t} by using the variable @code{MAKEFLAGS} together with the
> -@code{findstring} function
> -(@pxref{Text Functions, , Functions for String Substitution and Analysis}).
> +@samp{-t} by using the variable @code{MAKEFLAGS} together with the a
> +couple of @code{make} functions^

A typo.

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


docs: fix MAKEFLAGS testing example

2011-01-26 Thread Ralf Wildenhues
I think it's been reported here before, but I can't find the reference
now.  Anyway, the ranlib example in the manual is wrong because it is
way too simplistic; try, e.g.,
  make --no-print-directory FOO=bart

Below is a patch that might make the section less fitting for what it
was intended, but at least the code has less problems, or so I hope;
also, I think it is useful to have this code snippet in the manual
so people can copy it.

And yes, even the line wrapping cause headaches to get right.

Thanks,
Ralf

2011-01-26  Ralf Wildenhues  

* doc/make.texi (Testing Flags): Fix MAKEFLAGS testing example
and adjusted text to cope with passed variable assignments and
long options.

Index: doc/make.texi
===
RCS file: /cvsroot/make/make/doc/make.texi,v
retrieving revision 1.69
diff -u -r1.69 make.texi
--- doc/make.texi   30 Nov 2010 14:48:53 -  1.69
+++ doc/make.texi   26 Jan 2011 20:08:49 -
@@ -6449,23 +6449,31 @@
 @section Conditionals that Test Flags
 
 You can write a conditional that tests @code{make} command flags such as
-@samp{-t} by using the variable @code{MAKEFLAGS} together with the
-@code{findstring} function
-(@pxref{Text Functions, , Functions for String Substitution and Analysis}).
+@samp{-t} by using the variable @code{MAKEFLAGS} together with the a
+couple of @code{make} functions
+(@pxref{Functions, , Functions for Transforming Text}).
 This is useful when @code{touch} is not enough to make a file appear up
 to date.
 
-The @code{findstring} function determines whether one string appears as a
-substring of another.  If you want to test for the @samp{-t} flag,
-use @samp{t} as the first string and the value of @code{MAKEFLAGS} as
-the other.
+The @code{foreach} function expands text repeatedly for each element of
+a list.  The @code{filter-out} function removes words from text matching
+a pattern.  The @code{findstring} function determines whether one string
+appears as a substring of another.  Finally, the @code{if} function
+expands code conditionally, based on whether the condition is nonempty
+or not.
+
+Now, if you want to test for the @samp{-t} flag, you can use @samp{t} as
+the string to find in @code{MAKEFLAGS}, after filtering out long options
+and variable assignments that might match wrongly
+(@pxref{Options/Recursion}).
 
 For example, here is how to arrange to use @samp{ranlib -t} to finish
 marking an archive file up to date:
 
 @example
 archive.a: @dots{}
-ifneq (,$(findstring t,$(MAKEFLAGS)))
+ifneq (,$(foreach flag,$(filter-out --%,$(MAKEFLAGS)),$(if \
+  $(findstring =,$(flag)),,$(findstring t,$(flag)
 +touch archive.a
 +ranlib -t archive.a
 else

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


Re: separate the notions of always-build and jobserver

2011-01-26 Thread Ralf Wildenhues
http://thread.gmane.org/gmane.comp.gnu.make.bugs/5015

* Ralf Wildenhues wrote on Tue, Sep 28, 2010 at 10:55:48PM CEST:
> Currently, 'make -n' only executes recipe commands prefixed with '+' or
> containing one of the strings ${MAKE} or $(MAKE).  Likewise, parallel
> make hands the jobserver file descriptors only to rules annotated in the
> same way.
> 
> It would be nice if these two semantics could be decoupled.

FYI, to follow up to this old message myself, according to the other
message I just sent, I intend to use the following for this:

> 1) The GCC LTO (link-time optimization) engine may exploit
> parallelization during whole-program linking by hooking into the job
> server: http://gcc.gnu.org/ml/gcc-patches/2010-08/msg02149.html

in Automake:

am__if_make_flag = \
$(if $(strip $(foreach flag,$(filter-out --%,$(MAKEFLAGS)),$(if \
  $(findstring =,$(flag)),,$(if \
$(findstring $(1),$(flag)),:,$(2),$(3))
LTOPAR = $(call am__if_make_flag,n,,+)

and prefix link recipe commands with $(LTOPAR) (if GNU make is used).

Cheers,
Ralf

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