This Makefile has been elaborated to compile executable C or C++ projects in an incremental fashion with minimal setup and sensible defaults.
Edit the variables near the top of the file:
PROJECT_NAME := your-project-name-here
PROJECT_ROOT := src
This folder will be added to the -I
flag, making the headers discoverable through
#include <...>
instead of #include "..."
. Using this is of course optional.
HEADERS_ROOT := include
For instance: cpp
/hpp
, c
/h
, etc.
FILE_EXTENSION := c
HEADER_EXTENSION := h
This can be any compiler that accepts gcc-like flags (clang, etc)
COMPILER := gcc
OPT_DEBUG
only applies to debug builds, OPT_RELEASE
to release builds, and COMMON
applies to both.
OPT_DEBUG := -O0
OPT_RELEASE := -O3
COMMON := <your flags here>
build
: builds a debug version of the project, asmain
ormain.exe
depending on the platform.release
: builds a release version of the project, asproject-name(.exe)
. Optimisation flags are configurable.run
: builds and runs a debug version of the project.bench
: builds and runs a release version of the project.clean
: cleans the current object files and executables.rebuild
: cleans and rebuilds the project in debug mode.
It is recommended to add the executables and the ./obj
folder
to your .gitignore