如何使用GNUMake的通配符函数排除特定文件? [英] How to exclude a particular file with GNUMake's wildcard function?
问题描述
我的项目的目录结构如下:
dir1_contents:= $(通配符dir1 / *)
dir3_contents:= $(通配符dir3 / *)
全部:clean_dir1 clean_dir3
clean_dir1:
echo'dir1_contents = $(dir1_contents)'
clean_dir3:
echo'dir3_contents = $(dir3_contents)'
当我运行make时,是我得到的:
$ pwd
make-test
$ make -s
dir1_contents = dir1 / dir2 dir1 / file2.junk dir1 / file3.junk
dir3_contents = dir3 / file4.junk
我想在 dir1_contents
中获取 dir1
的内容。但是我想从该列表中排除 file3.junk
。我该怎么做?
也许我应该使用 grep -v
?但我不确定这是最好的方法。
$(filter- out
pattern , text )
text function $(过滤掉file3.junk,$ {dir1_contents})
(有人建议使用%/ file3.junk
而不是 file3.junk
,但我相信你不会需要的;我让你去实验)
My project's directory structure is as follows:
My Makefile looks like this:
dir1_contents := $(wildcard dir1/*)
dir3_contents := $(wildcard dir3/*)
all: clean_dir1 clean_dir3
clean_dir1:
echo 'dir1_contents = $(dir1_contents)'
clean_dir3:
echo 'dir3_contents = $(dir3_contents)'
When I run make, this is what I get:
$ pwd
make-test
$ make -s
dir1_contents = dir1/dir2 dir1/file2.junk dir1/file3.junk
dir3_contents = dir3/file4.junk
I want to get the contents of dir1
in dir1_contents
. But I want to exclude file3.junk
from that list. How can I do it?
Perhaps I should use grep -v
? But I'm not sure that's the best way. Is there a built-in GNUMake function I can use here?
Use the $(filter-out
pattern, text )
text function
$(filter-out file3.junk,${dir1_contents})
(someone suggested to use %/file3.junk
instead of file3.junk
, but I believe you don't need that; I leave you to experiment)
这篇关于如何使用GNUMake的通配符函数排除特定文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!