[Top][All Lists]

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

$(wildcard pattern-without-glob-chars) broken (Re: make ChangeLog read.

From: Kirill Smelkov
Subject: $(wildcard pattern-without-glob-chars) broken (Re: make ChangeLog read.c)
Date: Sat, 7 May 2011 17:06:27 +0400
User-agent: Mutt/1.5.18 (2008-05-17)

On Mon, May 02, 2011 at 12:18:06AM +0000, Paul D. Smith wrote:
> CVSROOT:      /sources/make
> Module name:  make
> Changes by:   Paul D. Smith <psmith>  11/05/02 00:18:06
> Modified files:
>       .              : ChangeLog read.c 
> Log message:
>       Avoid invoking glob() unless the filename has potential globbing
>       characters in it, for performance improvements.
> CVSWeb URLs:
> http://cvs.savannah.gnu.org/viewcvs/make/ChangeLog?cvsroot=make&r1=2.428&r2=2.429
> http://cvs.savannah.gnu.org/viewcvs/make/read.c?cvsroot=make&r1=1.198&r2=1.199

This change seems to be breaking how $(wildcard) works for patterns
without glob characters.

For example, I used to check wheter a file exists with

    ifneq ($(wildcard path/to/file),)
        $(info path/to/file exists)

but now this is triggering all the time, because wildcards does not see
glob characters in the pattern, decides to avoid globbing it,
and just leaves path/to/file in place.

And this seems to be going in contrary with what make's manual says:

---- 8< ----
    $(wildcard @address@hidden)
    @end example
    This string, used anywhere in a makefile, is replaced by a
    space-separated list of names of existing files that match one of the
    given file name patterns.  If no existing file name matches a pattern,
    then that pattern is *omitted* from the output of the @code{wildcard}
    function.  Note that this is different from how unmatched wildcards
    behave in rules, where they are used verbatim rather than ignored
    (@pxref{Wildcard Pitfall}).
---- 8< ----

(emphasis added)

This example from the manual

---- 8< ----
    This one is slightly more interesting: it defines a macro to search for
    the first instance of a program in @code{PATH}:
    pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, 
    LS := $(call pathsearch,ls)
    @end smallexample
---- 8< ----

is now broken too, because LS will return first directory from path + ls
regardless of whether ls is there. Try it:

---- 8< ----
    PATH    := /aaa/bbb:$(PATH)
    pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, 
    LS := $(call pathsearch,ls)
    $(info XXX $(LS))
---- 8< ----

Maybe we should turn globbing on for $(wildcard) unconditionally?


reply via email to

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