[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: wildcard all the .cc file in the subdirectories?
From: |
Ken Smith |
Subject: |
Re: wildcard all the .cc file in the subdirectories? |
Date: |
Thu, 27 Sep 2007 10:51:40 -0700 |
> On 27 September 2007 15:01, Eli Zaretskii wrote:
>
> >> From: "Dave Korn" <address@hidden>
> >> 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