{"id":20963785,"url":"https://github.com/mitjafelicijan/makext","last_synced_at":"2025-06-27T19:32:14.501Z","repository":{"id":239382234,"uuid":"799359722","full_name":"mitjafelicijan/makext","owner":"mitjafelicijan","description":"QOL Extensions for GNU Make","archived":false,"fork":false,"pushed_at":"2024-05-15T18:07:40.000Z","size":50,"stargazers_count":155,"open_issues_count":0,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-13T07:34:21.318Z","etag":null,"topics":["extension","make","makefile"],"latest_commit_sha":null,"homepage":"","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitjafelicijan.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}},"created_at":"2024-05-11T22:36:06.000Z","updated_at":"2024-12-03T14:35:39.000Z","dependencies_parsed_at":"2024-11-19T07:01:46.492Z","dependency_job_id":null,"html_url":"https://github.com/mitjafelicijan/makext","commit_stats":null,"previous_names":["mitjafelicijan/makext"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mitjafelicijan/makext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitjafelicijan%2Fmakext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitjafelicijan%2Fmakext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitjafelicijan%2Fmakext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitjafelicijan%2Fmakext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitjafelicijan","download_url":"https://codeload.github.com/mitjafelicijan/makext/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitjafelicijan%2Fmakext/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262319036,"owners_count":23292998,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["extension","make","makefile"],"created_at":"2024-11-19T02:48:25.605Z","updated_at":"2025-06-27T19:32:14.461Z","avatar_url":"https://github.com/mitjafelicijan.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GNU Make Extensions\n\nMakext is a collection of useful extensions for Makefiles, aimed\nat simplifying and enhancing the functionality of Make-based\nprojects. These extensions provide additional features and\nconvenience functions to improve the overall usage of [GNU\nMake](https://www.gnu.org/software/make/) as a task runner.\n\nAll the extensions are written in GNU Make so no other languages are used\nmaking this very embedable and has zero dependencies other than GNU Make.\n\nOther than `makext.mk` all the other files in the repository are either\nlicense or readme files or just testing data that is/are not needed to\nuse it.\n\n\u003e [!NOTE]\n\u003e These extensions are abusing GNU Make in some sense since it was not\n\u003e meant to really be a task runner. Keep that in mind. However, despite\n\u003e that, I constantly find myself using it as such.\n\n## Extensions\n\n| Extension   | Description                                         |\n|-------------|-----------------------------------------------------|\n| **help**        | Displays all targets with a comment in help format. |\n| **assure**      | Check for the existence of programs on a machine.   |\n| **environment** | Loads environmental variables from other files.     |\n\nAdditional features:\n\n- Automatic description inclusion in help message.\n- Automatic license inclusion in help message.\n\nTested on:\n\n- GNU Linux Debian 12 with GNU Make 4.3\n- macOS Sonoma 14.4.1 with GNU Make 3.81\n- Windows 10/11 with GNU Make 4.4.1 for Windows32\n\nIf you have an idea for a new feature [open a new\nissue](https://github.com/mitjafelicijan/makext/issues/new).\n\n## How to use\n\n\u003e [!IMPORTANT]\n\u003e If you intend to use this script on Windows machine\n\u003e make sure you have all the [prerequisites](#windows-specific-instructions) installed.\n\nFirst you will need to download `makext.mk` file from the repository to\nthe same directory where you have `Makefile`.\n\n```sh\nwget -O makext.mk https://github.com/mitjafelicijan/makext/raw/master/makext.mk\n```\n\nNow you can include it in your `Makefile`.\n\n```make\ninclude makext.mk\n\nhelp: .help\n```\n\n\u003e [!IMPORTANT]\n\u003e Make sure you create first target `help: .help` before any other\n\u003e targets in your `Makefile`. GNU Make will execute first target if\n\u003e no target provided as an argument when calling `make`.\n\n### Windows specific instructions\n\nOn Windows OS'es you need the following:\n\n- Git Bash for Windows\n- make\n\nAll of the above can be conveniently installed via [Scoop](https://scoop.sh/):\n\n```sh\nscoop install main/git main/make\n```\n\n## Help extension\n\nOne of the extensions is `.help` which displays all the targets in the\n`Makefile` and their descriptions which are provided as comments next\nto the target definition.\n\nLets check how and example `Makefile` would look like. It\nis recommended to use `.PHONY` for targets that are not\nactual files. In the example below I am not doing that\nthough, but it is wise to follow that rule. Check [4.6 Phony\nTargets](https://www.gnu.org/software/make/manual/make.html#Phony-Targets)\nsection in the GNU Make manual.\n\n```make\ninclude makext.mk\n\nhelp: .help\n\nbuild-app: clean-cache # Build the application\n\t@echo \"Building the application...\"\n\nclean-cache: # Clean the cache\n\t@echo \"Cleaning the cache...\"\n\ndeploy-prod: # Deploy to production\n\t@echo \"Deploying to production...\"\n\nrun-tests:\n\t@echo \"Running tests...\"\n```\n\nThis will give us the following result when we execute command `make`\nwithout any arguments.\n\n```text\n$ make\nTargets:\n  build-app                 Build the application\n  clean-cache               Clean the cache\n  deploy-prod               Deploy to production\n```\n\n- Targets without defined comment next to the target will be ignored\n  from help list. In this case `run-tests` is missing from the list.\n- Targets that start with `.` will also be ignored.\n- Prerequisites in targets will be omitted from the result. See how\n  `clean-cache` is missing from `build-app` target.\n\n## Description \u0026 License information\n\nYou can provide description for the project that will be displayed\ntogether with `help`. To do this provide this information in the\n`MEX_DESCRIPTION` variable.\n\nSame goes for license information. Provide this information by creating\n`MEX_LICENSE` variable.\n\nIf these variables are not present this information will not be displayed\nin the help.\n\nDescription and license information is also formatted to max 75 characters\nper row.\n\n\u003e [!IMPORTANT]\n\u003e Variables `MEX_DESCRIPTION` and `MEX_LICENSE` must be defined before you\n\u003e include `makext.mk` to your `Makefile`. This is needed because the way\n\u003e GNU Make is parsing Makefiles.\n\n```make\nMEX_DESCRIPTION=\"This provides some additional tools for this project.\"\nMEX_LICENSE=\"Released under the BSD two-clause license, see the LICENSE file for more information.\"\n\ninclude makext.mk\n\nhelp: .help\n\nbuild-app: clean-cache # Build the application\n\t@echo \"Building the application...\"\n\nclean-cache: # Clean the cache\n\t@echo \"Cleaning the cache...\"\n```\n\nThe following example will produce the following result.\n\n```text\n$ make\nThis provides some additional tools for this project.\n\nTargets:\n  build-app                 Build the application\n  clean-cache               Clean the cache\n\nReleased under the BSD two-clause license, see the LICENSE file for\nmore information.\n```\n\n## Assure extension\n\nOften times project uses multiple programs and to ensure that these\nprograms are already installed before recipes are executed `.assure` can\nbe used. If programs are missing recipes can only partially be executed\nleaving project in a potentially broken state.\n\n```make\nMEX_ASSURE=\"python3 ls tree clang\"\n\ninclude makext.mk\n\nbuild-app: .assure\n\t@echo \"Building the application...\"\n```\n\n`.assure` prerequisite will loop over the list of programs defined in\n`MEX_ASSURE` variable and in case one is missing will exit `make` with\nerror status code 1. This will stop executing the recipe and therefore\nnot execute anything in target `build-app`.\n\n## Environment extension\n\nThis extension helps loading of additional environmental files in your\nproject. The files should have environmental variables defined in the\nusual way. Separate each file by a space and that is about it.\n\nIf a file is missing this will break the execution of make and exit with\nstatus code 1.\n\n```env\nAPI_KEY=abc123\nSECRET_KEY=def456\n```\n\nBy defining `MEX_ENVIRONMENT` variable you can provide additional files\nand they will be loaded automatically.\n\n```make\nMEX_ENVIRONMENT=\"local.env second.env\"\n\ninclude makext.mk\n\ndemo-envars:\n\t@echo \"Environment variables\"\n\t@echo \"  HOME: $(HOME)\"\n\t@echo \"  TERM: $(TERM)\"\n\t@echo \"  ENV: $(MEX_ENVIRONMENT)\"\n\t@echo \"  AUDIO_BUCKET: $(AUDIO_BUCKET)\"\n\t@echo \"  DB_HOST: $(DB_HOST)\"\n```\n\nAfter that they can be used in your recipes like all the other variables\nyou have. They will however override variables the shell already has\ndefined.\n\n## Alternative tools\n\n- https://github.com/rocky/remake\n- https://github.com/casey/just\n- https://github.com/xonixx/makesure\n- https://github.com/ruby/rake\n- https://github.com/taskctl/taskctl\n- https://github.com/go-task/task\n- https://github.com/pydoit/doit\n\n## Acknowledgment\n\n- https://stackoverflow.com/a/59087509\n\n## License\n\n[makext](https://github.com/mitjafelicijan/makext) was written by [Mitja\nFelicijan](https://mitjafelicijan.com) and is released under the BSD\ntwo-clause license, see the LICENSE file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitjafelicijan%2Fmakext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitjafelicijan%2Fmakext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitjafelicijan%2Fmakext/lists"}