Personally, I never had problems listing all the files manually. Listing a file in a make file takes little time compared to adding content to it with useful content.
To get all the files from different directories, you can suggest using the wildcard function . Thus, my_sources:=$(wildcard *.cpp dir1/*.cpp) will force the variable to contain the source files matching the substitution expression.
However, I find this less convenient than using the usual Linux find through the shell:
# Find all sources my_sources:=$(shell find -iname '*.cpp')
Find more powerful than Make builtin wildcard . You can also use other shell features, such as pipelines, for example, to filter the find output (if the Make filter-out function is not enough). Or something like this to avoid excessive variables:
OBJS:=$(shell find -iname '*.cpp' | sed 's/\.cpp$/.o/')
You name it!
Pavel shved
source share