MyMakefile is a build system based on GNU Make for C++ projects. It serves as an alternative to CMake for medium-sized projects, eliminating the need to write complex Makefile rules from scratch.
While CMake is a popular choice, MyMakefile offers several advantages for smaller projects:
- Simplicity: No complex syntax or obscure function names
- Transparency: Direct control over the build process
- Efficiency: Smaller, more readable Makefiles
- Modern Features: All the tools you need without the complexity
- Encapsulate all complex Makefile rules in two files that you can include in your project, handling:
- File compilation
- Application bundling (including macOS bundles)
- Shared/static library management
- System installation
- Documentation generation
- Compilation flag management
- pkg-config integration
- RPM creation
- Define your project structure in just a few lines of Makefile syntax
- Let MyMakefile handle all the complex build rules for you
- 🐧 Linux
- 🍎 macOS
🪟 Windows(not yet supported)- 🌐 Emscripten
- 🧸 ExaequOS
- Include MyMakefile in your project:
# Option 1: Copy-paste
cp -r MyMakefile your-project/.makefile
# Option 2: Git submodule (recommended)
git submodule add https://github.com/Lecrapouille/MyMakefile.git .makefile
The dot prefix allows you to hide MyMakefile in your project, but it's not mandatory.
- Create your Makefile:
# Relative location of your project root folder P and MyMakefiles folder M
P := .
M := $(P)/.makefile
# Your minimal project definition
PROJECT_NAME := my-project
PROJECT_VERSION := 1.0.0
TARGET_NAME := my-app
TARGET_DESCRIPTION := brief explanation of the target
# Optional definitions
COMPILATION_MODE := release
CXX_STANDARD := --std=c++14
# Include MyMakefiles project file after your project definition
include $(M)/project/Makefile
# Define what and how to compile your target
INCLUDES := $(P)/include $(P)/src
VPATH := $(P)/src
DEFINES :=
SRC_FILES += src/main.cpp
# Include MyMakefiles rules file after your project configuration
include $(M)/rules/Makefile
# Optionally: add your custom Makefile rules here
- Build your project:
make help # Show all available options
make # Start compilation
make install # Install your project on your system
Here are some of my projects that use MyMakefile instead of CMake:
- 🎨 TimedPetriNetEditor
- 🎮 OpenGlassBox
- 📦 Zipper
- 🛣️ Highway
- 🎮 OpenGLCppWrapper
- 🔬 SimTaDyn
- 🧮 SimForth
- ♟️ ChessNeuNeu
- 🔗 LinkAgainstMyLibs
- 🐚 Bash interpreter (MyMakefile requires some bash assistance)
- 🛠️ Optional tools, called by MyMakefile:
g++
orclang++
(for compilation)gcovr
(for code coverage)doxygen
(for documentation)
ExaequOS is a fork of Emscripten. MyMakefile supports compilation for both platforms.
- Install the ExaequOS Docker image:
# Follow instructions at https://github.com/Lecrapouille/docker-exa
-
Run the ExaequOS Docker image against your project folder.
-
Simply run
make
- your project will compile like a native Linux application. -
After compilation, run
make install
-
Open https://www.exaequos.com/ in your browser.
-
In Havoc (ExaequOS console), run:
/media/localhost/<your-application>
## 📦 Compiling to RPM
make rpm
- For detailed API documentation, see API.md.
MIT License - See LICENSE file for details.