List Info

Thread: wildcard all the .cc file in the subdirectories?




wildcard all the .cc file in the subdirectories?
user name
2007-09-26 16:59:27
Hi,

Suppose I have a root directory, whose subdirectories could
also
subdirectories, etc. I want to wildcard all the .cc in the
root
directory, which shall give me all the path of all the .cc
files.
Would you please let me know how to do it?

Thanks,
Peng


_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make

RE: wildcard all the .cc file in the subdirectories?
country flaguser name
United Kingdom
2007-09-27 07:25:57
On 26 September 2007 22:59, Peng Yu wrote:

> Hi,
> 
> Suppose I have a root directory, whose subdirectories
could also
> subdirectories, etc. I want to wildcard all the .cc in
the root
> directory, which shall give me all the path of all the
.cc files.
> Would you please let me know how to do it?

  Is this what you're looking for?

DIR:=/path/to/whereever
CC_FILES_IN_ROOT:=$(wildcard $(DIR)/*.cc)


  It doesn't specifically look for files, but as long as
none of your
directories have '.cc' extensions that will be OK.


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....



_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make

Re: wildcard all the .cc file in the subdirectories?
country flaguser name
Israel
2007-09-27 09:00:50
RE: wildcard all the .cc file in the subdirectories?
country flaguser name
United Kingdom
2007-09-27 09:10:22
On 27 September 2007 15:01, Eli Zaretskii wrote:

>> From: "Dave Korn" <dave.kornartimi.com>
>> Date: Thu, 27 Sep 2007 13:25:57 +0100
>> Cc:
>> 
>>> Suppose I have a root directory, whose
subdirectories could also
>>> subdirectories, etc. I want to wildcard all the
.cc in the root
>>> directory, which shall give me all the path of
all the .cc files.
>>> Would you please let me know how to do it?
>> 
>>   Is this what you're looking for?
>> 
>> DIR:=/path/to/whereever
>> CC_FILES_IN_ROOT:=$(wildcard $(DIR)/*.cc)
> 
> No, I think he wants the files in subdirectories as
well, and then in
> subdirectories of those subdirectories, etc.,
recursively.

  Ah, I misunderstood the use of "root directory"
in "all the .cc in the root
directory", but in that case AFAIK the only way to do
it would be

DIR:=/path/to/whereever
CC_FILES_IN_ROOT:=$(shell find $(DIR) -type f -name '*.cc')

(Well, you could actually get horribly tricky with recursive
functions adding
successive instances of '*/' to the front of a string that
start of as '.cc'
and using $(wildcard) on that, but it's probably not worth
the trouble).

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....



_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make

Re: wildcard all the .cc file in the subdirectories?
user name
2007-09-27 12:51:40
> On 27 September 2007 15:01, Eli Zaretskii wrote:
>
> >> From: "Dave Korn" <dave.kornartimi.com>
> >> Date: Thu, 27 Sep 2007 13:25:57 +0100
> >> Cc:
> >>
> >>> Suppose I have a root directory, whose
subdirectories could also
> >>> subdirectories, etc. I want to wildcard
all the .cc in the root
> >>> directory, which shall give me all the
path of all the .cc files.
> >>> Would you please let me know how to do
it?
[snip]
> (Well, you could actually get horribly tricky with
recursive functions adding
> successive instances of '*/' to the front of a string
that start of as '.cc'
> and using $(wildcard) on that, but it's probably not
worth the trouble).

I use this function.  Even without the $(info) it probably
requires 3.81.

# logical not
not = $(if $(strip $(1)),,t)

# find-files-matching-extension:
# $(1)=subdir of $(CURDIR) to begin search
# $(2)=extension patterns
# $(3)=private recursive state variable (don't set)
find-files-matching-extension = 
$(strip 
  $(if $(call not,$(3)), 
    $(eval .thisdir := $(CURDIR)/$(1)) 
    , 
    $(eval .thisdir := $(1)) 
   ) 
  $(eval .thesefiles := $(wildcard $(.thisdir)/*)) 
  $(foreach .thisfile,$(.thesefiles), 
    $(eval .subdir := $(wildcard $(.thisfile)/*)) 
    $(if $(.subdir), 
      $(call
find-files-matching-extension,$(.thisfile),$(2),t) 
      , 
      $(filter $(2),$(.thisfile)) 
     ) 
   ) 
 )

$(info $(call find-files-matching-extension,.,%.cc))

   Enjoy
   Ken


_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make

[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )