mkgen is a lightweight Makefile generator designed for my everyday C and C++ workflow.
I often start with a small C or C++ file. Then it grows. Suddenly there are multiple .c / .cpp files, header files, and sometimes a graphical library involved. At that point, compiling manually or rewriting a Makefile becomes repetitive and annoying.
So I built mkgen.
It’s written in Python and focuses on C and C++ projects, with optional support for graphical libraries when needed.
- I like coding in C and C++
- Small projects tend to grow faster than expected
- Writing Makefiles over and over is tiring
- Linking multiple source files and libraries manually is error‑prone
mkgen automates the boring part so I can focus on writing code.
- Automatically generates a Makefile for C and C++ projects
- Detects multiple source files and header files
- Supports both C and C++ compilation
- Designed to scale from tiny projects to larger ones
- Optional / conditional support for graphical libraries
- Simple and minimal by design
- Start a small C or C++ project
- Add more
.c/.cppfiles over time - Add headers, maybe a graphical library
- Run
mkgen generate - Get a ready‑to‑use Makefile after the interactive menu
No manual compilation. No rewriting Makefiles.
mkgen is not meant to replace advanced build systems like CMake or Meson.
It is meant to be:
- Simple
- Fast
- Opinionated toward C/C++
- Easy to understand and modify
It exists because I needed it.
- Python 3.10+
- A C compiler (
gcc,clang, etc.) - or a C++ compiler (
g++,clang++)
- Clone the repository:
git clone https://github.com/gtRZync/mkgen.gitcd mkgen- Install globally for convenience:
pip install .- You're finally ready to generate your Makefiles on the go :
mkgen generateor
mkgen generate <system>or even
mkgen generate --cross-platform- Follow the interactive menu and boom a Makefile will appear at the specified output path or current working directory
Generate a Makefile based on the current project structure and selected options.
This command analyzes the project directory, applies heuristics to detect source/header/output/object folders, and generates the appropriate Makefile.
Usage
mkgen generate [options]Caution
Folder scanning is not functional yet
Note
Folder scanning is non-recursive by default.
GUI-related flags affect only compilation and linking flags in the generated Makefile.
Display the current version of the tool.
Usage
mkgen versionNote
This command does not accept any additional arguments.
The version command is equivalent to running mkgen --version.
Useful for debugging, bug reports, and verifying installed versions.
| Flag | Description |
|---|---|
-v, --version |
Print version information and exit |
-h, --help |
Show help and exit |
| Argument | Description | Default |
|---|---|---|
target_system |
Specify the system/OS for which the Makefile should be generated (e.g., linux, windows, macos). --cross-platform. |
Current system/OS |
| Argument | Description | Default |
|---|---|---|
--cross-platform |
Generate a Makefile that works across multiple systems. target_system. |
Disabled |
-l, --lang |
Specify the programming language to use. Supported: C or C++. |
None |
-c, --compiler |
Specify the compiler to use. This value will be written into the generated Makefile. | None |
-std, --standard |
Specify the language standard to use (e.g., c11, c17, c++11, c++17, c++20). Added to compiler flags in the Makefile. | None |
--gui |
Include GUI library flags in the Makefile. Supported backend: SDL2, SFML, RAYLIB. •If --gui is not specified and --no-gui is not used, the user is prompted to select a backend. • Mutually exclusive with --no-gui. |
None |
--no-gui |
Disable any GUI backend prompts. Mutually exclusive with --gui. |
Disabled |
-o, --output |
Specify the output directory for the Makefile. Defaults to current working directory if path is invalid. | ./ |
--binary-name |
Specify the name of the output binary/executable. The Makefile will use this name for the compiled program. | None |
mkgen generatemkgen generate linuxmkgen generate linux --lang C++ -c clang++ -std c++17 --gui=SDL2 -o ./build --binary-name my_appmkgen generate -l C++ --gui raylib mkgen generate macos -l C -std c23 -c clang --no-gui mkgen generate --cross-platform --lang CThis is a personal tool built for real projects. Features may evolve as my workflow evolves.
