{"id":16214801,"url":"https://github.com/lecrapouille/mymakefile","last_synced_at":"2026-02-10T20:32:50.374Z","repository":{"id":115857132,"uuid":"163410519","full_name":"Lecrapouille/MyMakefile","owner":"Lecrapouille","description":"[Build System][v2.0.0][Functional] Generic but complete Makefile for all my C++ GitHub projects (and also for your projects)","archived":false,"fork":false,"pushed_at":"2025-10-28T11:18:37.000Z","size":916,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-28T13:16:48.836Z","etag":null,"topics":["cpp","generic-makefile","gnu-make","make","makefile","makefile-template"],"latest_commit_sha":null,"homepage":"","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Lecrapouille.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-12-28T12:54:58.000Z","updated_at":"2025-10-28T11:18:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"5a258c44-62ff-4ba4-a6a9-e7bb8938cf14","html_url":"https://github.com/Lecrapouille/MyMakefile","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Lecrapouille/MyMakefile","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lecrapouille%2FMyMakefile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lecrapouille%2FMyMakefile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lecrapouille%2FMyMakefile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lecrapouille%2FMyMakefile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lecrapouille","download_url":"https://codeload.github.com/Lecrapouille/MyMakefile/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lecrapouille%2FMyMakefile/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29314705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-10T17:48:59.043Z","status":"ssl_error","status_checked_at":"2026-02-10T17:45:37.240Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","generic-makefile","gnu-make","make","makefile","makefile-template"],"created_at":"2024-10-10T11:12:59.302Z","updated_at":"2026-02-10T20:32:50.356Z","avatar_url":"https://github.com/Lecrapouille.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MyMakefile\n\n[MyMakefile](https://github.com/Lecrapouille/MyMakefile) is a build system based on GNU Make for C++ projects. It eliminates the need to write complex Makefile rules from scratch by offering plenty of rules and macros.\n\n**Note:** I no longer develop in C but MyMakefile should also work.\n\n## 🤔 Why MyMakefile?\n\nWhile CMake is a popular choice, MyMakefile serves as an alternative to CMake for medium-sized projects. Indeed, it offers several advantages for smaller C++ projects:\n\n- **Simplicity**: No complex CMake syntax or its obscure function names.\n- **Efficiency**: Smaller code you have to write, more readable Makefiles.\n- **Modern Features**: Call engineer tools you usually need without the complexity.\n\n**Limitations:** MyMakefile does not support multiple targets in a single Makefile file, but you can build a project that generates multiple libraries, standalone applications, and demos.\n\n## 🌟 MyMakefile Goals\n\n- Encapsulate all complex Makefile rules in two files that you can include in your project, handling:\n  - C++ file compilation.\n  - A small manifest file for downloading third-party libraries.\n  - Compilation flag management.\n  - Application bundling (including macOS bundles).\n  - Shared/static library creation (contrary to CMake, both are created).\n  - Installation on your system (header files, doc, libraries).\n  - Creation/installation of pkg-config files.\n  - Documentation generation (Doxygen).\n  - Unit tests and code coverage.\n  - RPM creation.\n  - Code formatting (clang-format integration).\n  - Static analysis (cppcheck integration).\n  - call dev tools (cppcheck, clang-format, asan, benchmark, gprof, coverity-scan, OpenSuse Build System, )\n- Define your project structure in just a few lines of Makefile syntax.\n- Let MyMakefile handle all the complex build rules for you.\n\n## 🌐 Cross-Platform Support\n\n- 🐧 Linux\n- 🍎 Mac OS\n- ~~🪟 Windows~~ (not yet supported)\n- 🌐 [Emscripten](https://emscripten.org)\n- 🧸 [ExaequOS](https://www.exaequos.com)\n\n## 🚀 Quick Start\n\n1. **Include MyMakefile in your project**:\n\nEither you copy directly this repo in your project or better to include it as submodule.\n\n```bash\n# Option 1: Copy-paste\ncp -r MyMakefile your-project/.makefile\n\n# Option 2: Git submodule (recommended)\ngit submodule add https://github.com/Lecrapouille/MyMakefile.git .makefile\n```\n\nThe dot prefix allows you to hide MyMakefile in your project, but it's not mandatory. The folder name is up to you.\n\n2. **Create your first Makefile**:\n\n```makefile\n# Relative location of your project root folder P and MyMakefile folder M\nP := .\nM := $(P)/.makefile\n\n# Your minimal project definition\nPROJECT_NAME := my-project\nPROJECT_VERSION := 1.0.0\nTARGET_NAME := my-app\nTARGET_DESCRIPTION := brief explanation of the target\n\n# Optional definitions\nCOMPILATION_MODE := release\nCXX_STANDARD := --std=c++14\n\n# Include MyMakefile project file after your project definition\ninclude $(M)/project/Makefile\n\n# Define what and how to compile your target\nINCLUDES := $(P)/include $(P)/src\nVPATH := $(P)/src\nDEFINES :=\nSRC_FILES += src/main.cpp\n# For compiling a library, replace SRC_FILES with LIB_FILES\n\n# Include MyMakefile rules file after your project configuration\ninclude $(M)/rules/Makefile\n\n# Optionally: add your custom Makefile rules here\n```\n\nFirst, you must define macros P and M. P indicates the relative path to the root project. M indicates where to find the MyMakefile folder.\n\nThe project definition is mandatory and allows you to define your project name and the target name (which is either a stand-alone application or library). You have to define a description to your target and a version to your project.\n\nCompilation definitions are up to you: release, debug, unit test, and the C++ standard.\n\nYou must include the two MyMakefile files at the correct location in your Makefile. One sets variables for your project and the other defines Makefile rules. As a consequence, order and position matter.\n\nFinally, you can give options to your compiler for finding C++ sources and header files, define project macros and the list of C++ files to compile.\n\n3. **Build your project**:\n\n```bash\nmake help                     # Show all available options\nmake [OPTIONS1]               # Start compilation\nsudo make install [OPTIONS2]  # Install your project on your system\n```\n\nLike traditional makefile you can pass OPTIONS1 to makefile, for example which compiler you prefer (CXX). OPTIONS define where to install your project on your system.\n\n## 📚 Projects Using MyMakefile\n\nHere are some of my projects that use MyMakefile instead of CMake:\n\n- 🎨 [TimedPetriNetEditor](https://github.com/Lecrapouille/TimedPetriNetEditor)\n- 🎮 [OpenGlassBox](https://github.com/Lecrapouille/OpenGlassBox)\n- 📦 [Zipper](https://github.com/Lecrapouille/zipper)\n- 🛣️ [Highway](https://github.com/Lecrapouille/Highway)\n- 🎮 [OpenGLCppWrapper](https://github.com/Lecrapouille/OpenGLCppWrapper)\n- 🔬 [SimTaDyn](https://github.com/Lecrapouille/SimTaDyn)\n- 🧮 [SimForth](https://github.com/Lecrapouille/SimForth)\n- ♟️ [ChessNeuNeu](https://github.com/Lecrapouille/ChessNeuNeu)\n- 🔗 [LinkAgainstMyLibs](https://github.com/Lecrapouille/LinkAgainstMyLibs)\n\n**Note:** They may not refer to the HEAD of MyMakefile and may use old syntax.\n\n## 📋 Prerequisites\n\n- 🐚 Bash interpreter (MyMakefile requires some bash assistance)\n- 🛠️ Optional tools, called by MyMakefile:\n  - `g++` or `clang++` (for compilation).\n  - `gcovr` (for code coverage).\n  - `doxygen` (for documentation).\n  - `git` (for downloading third-parties).\n\n## 🔧 Compiling for MacOS\n\nBy default, the behavior will compile like done with Linux. To create Bundle applications, you have to add the following code:\n\n```makefile\nifeq ($(OS),Darwin)\nBUILD_MACOS_APP_BUNDLE := 1\nAPPLE_IDENTIFIER := lecrapouille\nMACOS_BUNDLE_ICON := \u003cyour path\u003e/\u003cyour icon name\u003e.icns\nendif\n```\n\n## 🔧 Compiling for Emscripten\n\nNothing to do, follow the Emscripten documentation for compiling a project. MyMakefile shall detect it and compile for Emscripten.\n\n## 🔧 Compiling for ExaequOS\n\n[ExaequOS](https://www.exaequos.com) is a fork of [Emscripten](https://emscripten.org) and better alternative (POSIX compliant). MyMakefile also supports the compilation for this platform.\n\n- Install the ExaequOS Docker image:\n\n```bash\n# Follow instructions at https://github.com/Lecrapouille/docker-exa\n```\n\n- Run the ExaequOS Docker image against your project folder.\n- Simply run `make` - your project will compile like a native Linux application.\n- After compilation, run `make install`\n- Open [https://www.exaequos.com/](https://www.exaequos.com) in your browser.\n- In Havoc (ExaequOS console), run:\n\n```bash\n/media/localhost/\u003cyour-application\u003e\n```\n\n## 📦 Compiling to RPM\n\n```bash\nmake rpm\n```\n\n## Compiling standalone applications\n\nUse, `SRC_FILES` to set the local paths to C++ files you want to compile. For example `SRC_FILES := $(call rwildcard,$(CURRENT_DIR),*.cpp)`.\n\n## Compiling an internal library\n\nYou can mix with `LIB_FILES` instead of `SRC_FILES`. One library managed by Makefile.\n\n## Compiling standalone applications using several internal libraries\n\nYou have to set:\n\n- Use the macro `$(call internal-lib,xxx)` to set a library.\n- Set `INTERNAL_LIBS` with the list of libraries previously defined.\n- Set `DIRS_WITH_MAKEFILE` the list of folder in which there is a Makefile to compile the lib.\n- Set the order of library compilation with rules using paths (not library names).\n\nExample\n\n```makefile\nLIB_FOO := $(call internal-lib,foo)\nLIB_BAR := $(call internal-lib,robotik-bar)\nINTERNAL_LIBS := $(LIB_FOO) $(LIB_BAR)\nDIRS_WITH_MAKEFILE := $(P)/src/path/to/foo $(P)/src/path/to/bar\n$(P)/src/path/to/foo $(P)/src/path/to/bar\n```\n\nWe suppose that a Makefile exists in `$(P)/src/path/to/foo` and in `$(P)/src/path/to/bar`.\n\n## Pre and Post compilation\n\nYou can use `pre-build::` and `post-build::` goals. Place them after `include $(M)/rules/Makefile`. You can compile it to demos and examples.\n\n## Using third-parties libraries\n\nCreate a folder named `external` create a file named `manifest` with list of GitHub repos to clone. For example:\n\n```txt\nzeux/pugixml\nocornut/imgui@docking\n```\n\nTo download them, call in the console:\n\n```bash\nmake download-external-libs\n```\n\nThe `external` folder will be populated.\n\nIn Makefile: use the variable `$(THIRD_PARTIES_DIR)` to refer to the `external` folder. For example:\n\n```makefile\nINCLUDES += $(THIRD_PARTIES_DIR)/imgui\nVPATH += $(THIRD_PARTIES_DIR)/imgui\n```\n\n## Orchestrator Makefile\n\nThis Makefile does not compile `SRC_FILES` or `LIB_FILES` files but only call other Makefiles that will be used to compile internal lib, demos, ...\n\n## 📖 Documentation\n\n- The `help` rule will display you all variables you can override and prebuilt rules you can call. Note that rules with `::` allow you to append your own commands.\n- For detailed API documentation, see [API.md](doc/API.md).\n\n```bash\nmake help\nUsage:\n  [VERBOSE=1] make [flags...] \u003ctarget\u003e\n\nYou can override the following flags:\n\n  AUTHOR                                                                Auto-detect author from git config or system user\n    Default value: $(shell git config --global user.name 2\u003e/dev/null                                                                                                       echo $(USER))\n  ECHO                                                                  Echo command for colors\n    Default value: echo\n  ECHO_COLOR                                                            Echo command for colors\n    Default value: $(ECHO) -e\n  DESTDIR                                                               Define where the project will be installed: $(DESTDIR)$(PREFIX)/lib and $(DESTDIR)$(PREFIX)/bin.\n    Default value:\n  PREFIX                                                                Define where the project will be installed: $(DESTDIR)$(PREFIX)/lib and $(DESTDIR)$(PREFIX)/bin\n    Default value: /usr/local\n  INCLUDEDIR                                                            Define where to install includes.\n    Default value: $(PREFIX)/include\n  LIBDIR                                                                Define where to install libraries.\n    Default value: $(PREFIX)/lib\n  PKGLIBDIR                                                             Define where to install pkgconfig files.\n    Default value: $(LIBDIR)/pkgconfig\n  DATADIR                                                               Define where to install data and documentation.\n    Default value: $(PREFIX)/share\n  BINDIR                                                                Define where to install standalone applications.\n    Default value: $(PREFIX)/bin\n  TMPDIR                                                                Define where to you can store temporary files.\n    Default value: /tmp\n  BUILD                                                                 Name of the directory holding the compilation artifacts.\n    Default value: build\n  THIRD_PARTIES_FOLDER_NAME                                             Name of the directory holding third parties libraries (external libraries).\n    Default value: external\n  DOC_FOLDER_NAME                                                       Name of the directory holding documentation.\n    Default value: doc\n  PROJECT_GENERATED_FOLDER_NAME                                         Name of the directory holding generated reports.\n    Default value: doc\n  GENERATED_DOXYGEN_DIR                                                 Directory where Doxygen is generated\n    Default value: $(PROJECT_GENERATED_DOC_DIR)/doxygen\n  GPROF_ANALYSIS                                                        Path of the generated profiling analysis\n    Default value: $(PROJECT_GENERATED_DOC_DIR)/profiling/analysis.txt\n  COVERAGE_DIR                                                          Path of the generated code coverage report\n    Default value: $(PROJECT_GENERATED_DOC_DIR)/code-coverage\n  COVERAGE_HTML_RAPPORT                                                 Path of the generated code coverage report\n    Default value: $(COVERAGE_DIR)/coverage.html\n  COVERAGE_LCOV_RAPPORT                                                 Path of the generated code coverage report\n    Default value: $(COVERAGE_DIR)/lcov.info\n  DATA_FOLDER_NAME                                                      Define the directory holding project data.\n    Default value: data\n  PROJECT_TESTS                                                         Define the directory holding unit tests.\n    Default value: tests\n  MACOS_BUNDLE_ICON                                                     Path to the default icon for MacOS bundle applications.\n    Default value: $(M)/assets/$(DATA_FOLDER_NAME)/macos.icns\n  PATH_PROJECT_LOGO                                                     Path to the default icon for MacOS bundle applications.\n    Default value: $(abspath $(M)/assets/icons/logo.png)\n  DOXYGEN_INPUTS                                                        Path to the default icon for MacOS bundle applications.\n    Default value: $(abspath $(P)/README.md $(P)/src $(P)/include)\n  PROJECT_TEMP_DIR                                                      Path where to store temporary project files.\n    Default value: $(TMPDIR)/$(PROJECT_NAME)/$(PROJECT_VERSION)\n  PROJECT_OTHER_FILES                                                    Path where to store temporary project files.\n    Default value: AUTHORS LICENSE README.md ChangeLog VERSION\n  REGEXP_CXX_HEADER_FILES                                               Path where to store temporary project files.\n    Default value: *.hpp *.ipp *.tpp *.hh *.h *.hxx *.incl\n  PREVENT_SHARED_LIB_UNLOAD                                             Use nodelete flag for shared libraries\n    Default value:\n  CUSTOM_RPATH                                                          Custom runtime library search paths (rpath) - colon separated\n    Default value:\n  DO_NOT_COMPILE_STATIC_LIB                                             Do not compile static library\n    Default value:\n  DO_NOT_COMPILE_SHARED_LIB                                             Do not compile shared library\n    Default value:\n  LICENSE                                                               Do not compile shared library\n    Default value: $(if $(DETECTED_LICENSE),$(DETECTED_LICENSE),MIT)\n  CXX_STANDARD                                                          Select the C++ standard.\n    Default value: --std=c++14\n  EMCC                                                                  Select the C++ standard.\n    Default value: emcc\n  EMCXX                                                                 Select the C++ standard.\n    Default value: em++\n  EMAR                                                                  Select the C++ standard.\n    Default value: emar\n  CC                                                                    Select the C++ standard.\n    Default value:\n  CXX                                                                   Select the C++ standard.\n    Default value:\n  AR                                                                    Select the C++ standard.\n    Default value: ar\n  ARFLAGS                                                               Select the C++ standard.\n    Default value: crs\n  RUN                                                                   Select the C++ standard.\n    Default value:\n  STRIP                                                                 Select the C++ standard.\n    Default value: strip -R .comment -R .note -R .note.ABI-tag\n  PKG_CONFIG_SEARCH_PATH                                                Select the C++ standard.\n    Default value:\n\nTargets:\n\n  all:                        Compile the standalone application or static/shared libraries.\n  asan:                       Launch the executable with address sanitizer (if enabled).\n  benchmark:                  Run benchmark.\n  build-stats:                Show build statistics.\n  check:                      Call unit-tests with code coverage.\n  check-compiled-with-gprof:  Launch the executable with gprof.\n  check-deps:                 Check dependencies.\n  check-harden:               Check if your project is harden\n  clean::                     Clean the build folder.\n  compilation-mode:           Display the compilation mode of the project.\n  compile-external-libs:      Compile external projects needed.\n  compiler-info:              Display the compiler version and information.\n  coverage:                   Generate the code coverage html rapport.\n  coverity-scan:              Create a tarball for Coverity Scan a static analysis of code.\n  creating-build-folder:      Ensure .clang-format file exists at the project root.\n  cxx-standard:               Display the C++ standard used.\n  doc:                        Generate the code source documentation with doxygen.\n  download-external-libs::    Download external github code source needed by this project.\n  ensure-clang-format:        Ensure .clang-format file exists at the project root or install it.\n  format-source-code:         Format source code with .clang-format file (else a default one is installed).\n  gprof:                      Launch the executable with gprof.\n  help:                       Show this help.\n  install::                   Install the project artifacts on the operating system\n  internal-libs-deps:         Compile the standalone application or static/shared libraries.\n  lint:                       Run static analysis.\n  list-targets:               List all available targets.\n  list-variables:             List all key project variables.\n  obs:                        Create an uploadable tarball for the OpenSuse Build Service.\n  post-build::                Compile the standalone application or static/shared libraries.\n  post-build::                Post-build actions: rules to extend after the build process.\n  pre-build::                 Pre-build actions: rules to extend before the build process.\n  project-name:               Display the name of the project.\n  project-version:            Display the version of the project.\n  rebuild:                    Rebuild the project.\n  rpm:                        Build RPM package using auto-generated spec file.\n  run:                        Run the binary with optional arguments. For example make run -- foo --help\n  show-flags:                 Show compilation flags.\n  show-paths:                 Show project paths.\n  size-analysis:              Show size analysis.\n  tarball:                    Compress project sources without in the goal to backup the code or share it.\n  target-description:         Display the description of the target.\n  target-name:                Display the name of the target.\n  tests:                      Call unit-tests with code coverage.\n  veryclean::                 Clean everything: build, third-parties, documentation, and generated files.\n```\n\n## 📝 License\n\nMIT License - See [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flecrapouille%2Fmymakefile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flecrapouille%2Fmymakefile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flecrapouille%2Fmymakefile/lists"}