Sources from subdirectories in Makefile

This should do it: SOURCES = $(wildcard *.cpp) $(wildcard */*.cpp) If you change you mind and want a recursive solution (i.e. to any depth), it can be done but it involves some of the more powerful Make functions. You know, the ones that allow you to do things you really shouldn’t. EDIT: Jack Kelly points … Read more

Difference in details between “make install” and “make altinstall”

Let’s take a look at the generated Makefile! First, the install target: install: altinstall bininstall maninstall It does everything altinstall does, along with bininstall and maninstall Here’s bininstall; it just creates the python and other symbolic links. # Install the interpreter by creating a symlink chain: # $(PYTHON) -> python2 -> python$(VERSION)) # Also create … Read more

Why .SECONDARY does not work with patterns (%) while .PRECIOUS does?

Thanks to Alex (see answer) i went further in my search. What i found is that it is recorded in TODO.private of make project for 15 years …. Using git://git.savannah.gnu.org/make.git you can see history of TODO.private content : 6) Right now the .PRECIOUS, .INTERMEDIATE, and .SECONDARY pseudo-targets have different capabilities. For example, .PRECIOUS can take … Read more

Best practice for building a make file

Here is an example makefile for you, tested on your github project. Features: Automatic dependency generation. Automatic rebuild when Makefile is changed. Debug/release builds in different directories. Debug build is the default, use make BUILD=release for release builds. Supports gcc and clang. gcc is the default, use make COMPILER=clang for clang. clean target works by … Read more