A Makefile is a build automation tool that automates the management of your project. Although using this Makefile doesn't require familiarity with writing Makefiles, I recommend reading the GNU Make Manual if you're interested.
The purpose of this project is to provide a portable, easy-to-configure and beginner friendly Makefile for C/C++ projects.
- Interactive option selection with commenting
- Options for choosing your
- Shell (bash by default)
- Language (C vs C++)
- Compiler (gcc, g++, clang, clang++, etc.)
- Compiler version (c99, c++11, etc.)
- Compiler/Linker options
- Directory names (src, include, obj, bin)
- Target binary name (target by default)
- Easy-to-use commands for building, running, etc.
- Clone the repository to a central location
- Start a project in any directory
- In your project directory put your c/c++ source files (.c/.cpp) into a src/ directory
- Put your header files (.h/.hpp) into an include/ directory
- Copy the Makefile from the central location to any newly created project directory
- Configure the Makefile
- Run the commands to build/run/manage your project
make
- Builds your project. Your objects files will be put in the obj/ directory, your target binary will be put in the bin/ directorymake run
- Builds (see above) and runs your projectmake clean
- Removes your object and binary directories (obj/ and bin/)make debug
- Runs your program with gdbmake memtest
- Runs your program with valgrind (configured for memcheck)make echo | grep "<inner Makefile variable> ="
- Gives you the value of a variable in your Makefile (eg. SRC = main.c list.c)
src
- Directory for the C/C++ source files (.c/.cpp)include
- Directory for the C/C++ header files (.h/.hpp)obj
- Directory for the object files (.o)bin
- Directory for the target binary (executable)