THE definitive makefile for simple c++
projects, without scassamento di maroni!
This simple makefile compiles all your c++
projects automatically.
It looks recursively into the folder tree for headers and sources.
It constructs the dependency rules, compiles them and links the main code in the base directory.
Basic usage:
- Place the Makefile in the same folder as the
main.cpp
file. - Edit the location of the dependency files (default is
SRC_DIRS = .
) - Edit executable name, compiler flags and the like (optional)
- Run
make all
Other commands:
make
shows a default help message;make ar
links all sources into a static library (default islib.a
) and collects all headers into theinclude
folder;make clean
removes all object files, dependency files, archive and executable.
This project runs on unix
systems.
It requires a version of the g++
compiler supporting the -MMD
flags and uses gcc-ar
for generating the archive.