this is a makefile that aims towards letting you build a linux c++ project with the least amount of configuration
make init
creates the basic directory structure shown below
make shared BUILD=release
builds source files in ./src
with -O3
into a stripped shared object file in ./lib
directory with separate debug symbols in a .dbg file
make static
builds source files in ./src
into a static archive in ./lib
directory with debug symbols included
make exec BUILD=debug
builds source files in ./src
into an executable in ./bin
directory with debug symbols included
make test
builds source files in ./test
into an executable that is linked against the first shared/static lib file it finds in lib directory
make run
runs the output test executable
make run BUILD=coverage
builds test sources with --coverage
flag, run tests, generates web report in ./doc
and opens it using system default web browser
- automatic header dependency generation
- source directories nesting support for
./src
and./test
- Linux library versioning, usage: edit
MAJOR_VERSION
&MINOR_VERSION
- 32/64bit builds support, usage:
make ARCH=32
,make ARCH=64
-default is system arch- - 3 types of builds:
debug
: default buildrelease
: has-O3
optimization level and separate debug symbols with debug link in elf filecoverage
: output binaries generate coverage reports inhtml
directory (lcov
package required for that)
rpath
set to $ORIGIN by default- library/executable file names are determined from project directory name
libtest
|
├── makefile
|
├── src
│ └── TestModule.cpp
|
├── include
│ └── TestModule.h
|
|── test
| └── major_tests.cpp
|
├── dep --generated--
│ ├── src
│ │ └── TestModule.cpp.dep
│ └── test
│ └── major_tests.cpp.dep
|
├── obj --generated--
│ └── 64
│ └── debug
│ ├── src
│ │ └── TestModule.o
│ └── test
│ └── major_tests.o
|
├── lib --generated--
│ └── 64
│ └── debug
│ ├── libtest.so.0 -> ./libtest.so.0.1.9
│ └── libtest.so.0.1.9
|
├── bin --generated--
│ └── test
│ └── 64
│ └── main_test
|
├── cov --generated by coverage target--
|
└── docs
└── mydoc.md
- make use of pkg-config
- support nested local deps
- add install target
- support more architectures
- support packaging via fpm