I am new to C/C++ and to gnu makefiles especially. Momentarily I have a makefile that automatically generates a list of all sources and headers in one directory in order to make
the output binary.
as my project grows I surely do not want to lump all source and header files into one directory. but instead create (nested) subdirectories.......
Is there a way - I guess taking as starting point subdirs := $(wildcard */)
- and further involving for... in... ($subdirs)
to first only generate a list of the source and header files in the subdirectories and nested subdirectories ? Maybe later with addition of a make
call for the sources and headers of every subdirectory ?
Thank you very much.
Yours sincerly von Spotz
You can use $(shell)
and script it:
ALL_SOURCES := $(shell find * -name '*.cpp' -print)
(assuming you use .cpp
as a C++ source file extension). You should have full and complete documentation of make
already installed:
info -f make
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.