Dead-simple C/C++ build tool!
| cmd/mako | ||
| examples | ||
| internal | ||
| tests | ||
| .gitignore | ||
| ai.md | ||
| CLAUDE.md | ||
| go.mod | ||
| LICENSE.md | ||
| README.md | ||
Mako
A fast, parallel build system for C/C++ projects. Think npm or cargo, but for C/C++.
Why Mako?
- Fast: Parallel compilation with smart caching
- Simple: One
build.tomlfile, sensible defaults - Modern: Clean TOML config instead of Makefiles
- Batteries included: Built-in test framework, file watching, and scripts
Quick Start
# Create a new project
mako new myproject
cd myproject
# Build and run
mako build
mako run
# Watch for changes and rebuild
mako watch
Build Configuration
Create a build.toml in your project root:
name = "myapp"
language = "c++17"
# Build settings
optimization = "2"
warnings = "all"
# Suppress specific warnings
warnings = [
"no-unused-parameter",
"no-deprecated-declarations"
]
# Define constants (converts to -D flags)
[constants]
VERSION = "1.0.0"
DEBUG_MODE = ""
MAX_CONNECTIONS = "100"
# Link libraries
link_libs = ["pthread", "m"]
# Add include directories
include_dirs = ["include", "vendor"]
Build Modes
Executable Mode (Default)
Build executables from your source code:
name = "myapp"
language = "c++17"
mode = "executable" # Default, can be omitted
# Main executable is built from src/ automatically
Library Mode
Build static or shared libraries:
name = "mylib"
language = "c11"
mode = "library"
library_type = "static" # Options: "static", "shared", or "both"
# Will create libmylib.a (and/or libmylib.so / libmylib.dll / libmylib.dylib)
mako build # Creates libmylib.a
Multiple Executables
Mako makes it easy to build multiple executables from the same codebase:
name = "myproject"
language = "c++17"
# Main executable is built from src/ automatically
# Additional executables
[[executables]]
name = "server"
source = "cmd/server"
entry_point = "main.cpp"
ldflags = ["-lpthread"]
[[executables]]
name = "client"
source = "cmd/client"
entry_point = "main.cpp"
Build Modes
# Build only the main executable (default)
mako build
# Build all executables (main + additional)
mako build --all
# Build a specific executable
mako build server
Commands
Project Setup
mako init # Initialize in current directory
mako new <name> # Create new project directory
Building
mako build # Build main executable
mako build --all # Build all executables
mako build server # Build specific executable
mako build main.cpp # Compile single file
mako build --clean # Force rebuild all
mako build --verbose # Show detailed output
Running
mako run # Build and run main executable
mako run server # Build and run specific executable
mako run -- arg1 arg2 # Pass arguments to executable
Testing
Mako includes the Echo test framework for both C and C++:
C Tests:
// test_math.c
#include <echo.h>
ECHO_TEST(addition) {
ECHO_ASSERT_EQ(2 + 2, 4);
}
ECHO_TEST(multiplication) {
ECHO_ASSERT_EQ(3 * 4, 12);
}
ECHO_MAIN()
C++ Tests:
// test_math.cpp
#include <echo/echo.hpp>
suite("Math Operations") {
test("addition") {
expect(2 + 2) == 4;
};
test("multiplication") {
expect(3 * 4) == 12;
};
}
ECHO_MAIN
mako test # Run all tests
mako test math # Run specific test
mako test --verbose # Show detailed output
Other Commands
mako clean # Remove build artifacts
mako watch # Watch and rebuild on changes
mako list sources # List source files
mako list headers # List header files
Scripts
Define custom commands (like npm scripts):
[scripts]
benchmark = ["./build/myapp --benchmark"]
deploy = [
"./build/myapp --test",
"scp build/myapp server:/opt/myapp"
]
mako script benchmark
mako script deploy
Auto-Discovery
Mako automatically discovers and handles:
- Source files: Finds all
.c,.cpp,.cc, etc. in your source directory - Include paths: Adds common directories like
include/,src/include/ - Executables: Discovers executables in
cmd/*/,examples/*/,tools/*/ - Dependencies: Tracks header changes and rebuilds only what's needed
Directory Layouts
Mako works with various project structures:
Simple Layout
myproject/
├── build.toml
├── src/
│ ├── main.cpp
│ └── utils.cpp
└── include/
└── utils.h
Multi-Executable Layout
myproject/
├── build.toml
├── src/ # Shared library code
│ └── core.cpp
├── cmd/
│ ├── server/
│ │ └── main.cpp
│ └── client/
│ └── main.cpp
└── include/
└── core.h
Auto-Discovery Layout
myproject/
├── build.toml # Just enable auto_discover_executables = true
├── cmd/
│ ├── server/main.cpp # Automatically becomes "server" executable
│ └── client/main.cpp # Automatically becomes "client" executable
└── examples/
└── demo/main.cpp # Automatically becomes "demo" executable
Configuration Reference
Project Settings
name = "myproject" # Project name
language = "c++17" # c++11, c++14, c++17, c++20, c++23, c11, c17, c89, c99
compiler = "gcc" # gcc, clang, msvc (auto-detected by default)
mode = "executable" # "executable" (default) or "library"
library_type = "static" # "static", "shared", or "both" (only for library mode)
source = "src" # Source directory (also accepts source_dir)
build_dir = "build" # Build output directory
optimization = "2" # 0, 1, 2, 3, fast, debug, release, size
warnings = "all" # all, basic, none, error
Dependencies
# Simple library linking
link_libs = ["pthread", "m", "ssl"]
# Include directories
include_dirs = ["include", "vendor/json/include"]
# Library search paths
lib_dirs = ["lib", "vendor/lib"]
# Use pkg-config
[dependencies]
pkg_config = ["gtk+-3.0", "openssl"]
Executables
[[executables]]
name = "myapp" # Executable name
source = "cmd/myapp" # Source directory
entry_point = "main.cpp" # Main file (optional)
sources = ["main.cpp", "cli.cpp"] # Specific sources (optional)
cflags = ["-DSPECIAL_BUILD"] # Executable-specific compiler flags
ldflags = ["-lpthread"] # Executable-specific linker flags
link_libs = ["custom"] # Executable-specific libraries
include_dirs = ["internal"] # Executable-specific includes
Advanced Settings
# Parallel compilation
threads = 8 # Number of worker threads (default: CPU count)
# Auto-discovery
auto_discover_executables = true # Find executables in cmd/, examples/, etc.
auto_discover_includes = true # Auto-add include paths
auto_discover_libraries = true # Auto-detect system libraries
# Compiler flags
cflags = ["-fPIC", "-march=native"]
ldflags = ["-Wl,--strip-all"]
Performance
Mako is designed for speed:
- Parallel compilation: Utilizes all CPU cores
- Smart caching: Only recompiles changed files
- Dependency tracking: Tracks header dependencies automatically
- Incremental linking: Relinks only when necessary
# Use more workers for faster compilation
mako build --workers=16
# See what's being compiled
mako build --verbose
Examples
Check out the examples/ directory for real-world usage:
- lua: Building Lua 1.1 interpreter (C89 project)
- ldflags: Multiple executables with different linker flags
- mathlib: Static and shared library example
- Various test projects demonstrating different features
Contributing
Mako is open source. Contributions welcome!
License
See LICENSE.md