Assume I have such hierarchy:

src/module1/mod1.c
src/module2/mod2.c
src/my.c

With $(wildcard src/*) I can get

  src/module1 src/module2 src/my.c

I need split this list into 2 list, one with directory only:

  src/module1 src/module2

and one with file only:

  src/my.c

I know solution with $(shell ...), but this require creating external process.

I know solution based on source files naming: they contain dot.
This can  not work on dirs with dot in names.

PS.

When I wrote this mail I found solution!

Between built in GNU Make functions only few
can communicate with reality (file system).
These are

  shell, wildcard, realpath

shell I dislike for performance.

wildcard get existing files by pattern.
realpath get existing files.

If $(dir) exist then $(dir)/. also exist.
If $(file) exist then $(file)/. does not exist. So

filter-dir = $(foreach item,$1,$(if $(realpath $(wildcard $(item)/.)),$(item))) filter-file = $(foreach item,$1,$(if $(realpath $(wildcard $(item)/.)),,$(item)))

var = $(wildcard src/*)

$(error $(call filter-dir,$(var)))  # this line for test
$(error $(call filter-file,$(var))) # this line for test

realpath you can replace with widlcard.

--
С уважением, Александр Гавенко.

_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to