Posts Makefile技巧记录/收录
Post
Cancel

Makefile技巧记录/收录

wildcard递归列出目标

1
2
3
4
5
6
7
8
9
10
11
# Make does not offer a recursive wildcard function, so here's one:
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))

# How to recursively find all files with the same name in a given folder
ALL_MAIN_C := $(call rwildcard,,main.c)

# How to recursively find all files that match a pattern
ALL_SOURCE_C := $(call rwildcard,,*.c)
all:
	echo $(ALL_MAIN_C)
	echo $(ALL_SOURCE_C)
This post is licensed under CC BY 4.0 by the author.