Skip to content

[Build System][v2-rc][Functional] Generic but complete Makefile for all my C++ GitHub projects (and also for your projects)

License

Notifications You must be signed in to change notification settings

Lecrapouille/MyMakefile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyMakefile

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.

🤔 Why MyMakefile?

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

🌟 MyMakefile Goals

  • 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

🌐 Cross-Platform Support

🚀 Quick Start

  1. 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.

  1. 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
  1. Build your project:
make help         # Show all available options
make              # Start compilation
make install      # Install your project on your system

📚 Projects Using MyMakefile

Here are some of my projects that use MyMakefile instead of CMake:

📋 Prerequisites

  • 🐚 Bash interpreter (MyMakefile requires some bash assistance)
  • 🛠️ Optional tools, called by MyMakefile:
    • g++ or clang++ (for compilation)
    • gcovr (for code coverage)
    • doxygen (for documentation)

🔧 Compiling for ExaequOS

ExaequOS is a fork of Emscripten. MyMakefile supports compilation for both platforms.

  1. Install the ExaequOS Docker image:
# Follow instructions at https://github.com/Lecrapouille/docker-exa
  1. Run the ExaequOS Docker image against your project folder.

  2. Simply run make - your project will compile like a native Linux application.

  3. After compilation, run make install

  4. Open https://www.exaequos.com/ in your browser.

  5. In Havoc (ExaequOS console), run:

/media/localhost/<your-application>

## 📦 Compiling to RPM

make rpm

📖 Documentation

  • For detailed API documentation, see API.md.

📝 License

MIT License - See LICENSE file for details.

About

[Build System][v2-rc][Functional] Generic but complete Makefile for all my C++ GitHub projects (and also for your projects)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published