{"id":16941193,"url":"https://github.com/iberianpig/makef","last_synced_at":"2025-04-11T19:30:18.012Z","repository":{"id":147294213,"uuid":"192044070","full_name":"iberianpig/makef","owner":"iberianpig","description":"Override Makefile","archived":false,"fork":false,"pushed_at":"2025-03-15T23:54:34.000Z","size":12,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T15:21:13.280Z","etag":null,"topics":["bash","cli","make","makefile","override","shell","task-runner"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iberianpig.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},"funding":{"github":["iberianpig"]}},"created_at":"2019-06-15T06:15:27.000Z","updated_at":"2025-03-15T23:54:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"7304a04e-71f6-4c3e-b444-3cfa1bf97eee","html_url":"https://github.com/iberianpig/makef","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iberianpig%2Fmakef","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iberianpig%2Fmakef/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iberianpig%2Fmakef/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iberianpig%2Fmakef/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iberianpig","download_url":"https://codeload.github.com/iberianpig/makef/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248466679,"owners_count":21108514,"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":["bash","cli","make","makefile","override","shell","task-runner"],"created_at":"2024-10-13T21:08:56.155Z","updated_at":"2025-04-11T19:30:17.976Z","avatar_url":"https://github.com/iberianpig.png","language":"Shell","funding_links":["https://github.com/sponsors/iberianpig"],"categories":[],"sub_categories":[],"readme":"# makef\n\nOverride `Makefile` for developer local environment\n\n* Extend Makefile with overriding tasks\n* Behave like make -f `make -f /path/to/git/ignored/Makefile`\n* Override the project's Makefile tasks in local envirioment\n* Unify commands for developer's local between different projects\n* No more wrong selections from Ctrl-R's command line history\n* Support `bash-completion`\n\n## Installation\n\n### 1. Install makef\n\nregister `makef` to `~/.bashrc`\n\n```sh\ngit clone https://github.com/iberianpig/makef\necho -e \"# makef\\nsource $(find `pwd` -name makef.sh)\" \u003e\u003e ~/.bashrc\nsource ~/.bashrc\n```\n\n### 2. Install direnv\n\n`makef` use `direnv` to set `$MAKEF_PATH` to envirionment variables\n\nsee: https://github.com/direnv/direnv\n\n## Usage\n\nFor example, You have a Makefile like following in your project.\n\n`./Makefile`\n```Makefile\ntask1: ## Sample task\n\techo \"this is Makefile\"\n\ntask2: task1 ## task overridden in next step\n\techo \"from ./Makefile\"\n```\n\n### Export MAKEF_PATH in `.envrc`\n\nAdd `export MAKEF_PATH=/path/to/hidden/Makefile` to `.envrc` on your project\n\nEdit `.envrc`, use `.git/Makefile` as MAKEF_PATH in this example.\n\n```sh\nexport MAKEF_PATH=.git/Makefile\n```\n\nBy setting the $MAKEF_PATH environment variable, you can specify a custom path for your override Makefile for each project. If you use direnv, simply add the following to your project's .envrc:\n\n```sh\nexport MAKEF_PATH=.git/Makefile\n```\n\nThen allow the changes with:\n\n```sh\ndirenv allow\n```\n\n(You can also set $MAKEF_PATH manually if you prefer not to use direnv.)\n\n### 1. Initializing the Override Makefile\n\nGenerate a new override Makefile at the path specified by $MAKEF_PATH by running:\n\n```sh\nmakefinit\n```\n\nAn example override Makefile (e.g., .git/Makefile) generated by this command might look like:\n\n```Makefile\n.PHONY: all\n\nall: help\n\nhelp: ## show this messages\n\t@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = \":.*?## \"}; {printf \"\\033[36m%-30s\\033[0m %s\\n\", $$1, $$2}'\n\nNO_PHONY = /^:/\nPHONY := $(shell cat $(MAKEFILE_LIST) | awk -F':' '/^[a-z0-9_.-]+:/ \u0026\u0026 !$(NO_PHONY) {print $$1}')\n.PHONY: $(PHONY)\n\nshow_phony:\n\t@echo $(PHONY)\n```\n\n### 2. Editing and Overriding Tasks\n\nAfter initialization, you can modify your override Makefile with:\n\n```sh\nmakefedit\n```\n\nFor example, you can redefine tasks as follows:\n\n```Makefile\n.PHONY: all\n\nall: help\n\ntask2: task1 ## Overriding task\n\techo \"from .git/Makefile\"\n\nhelp: ## show this messages\n\t@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = \":.*?## \"}; {printf \"\\033[36m%-30s\\033[0m %s\\n\", $$1, $$2}'\n\nNO_PHONY = /^:/\nPHONY := $(shell cat $(MAKEFILE_LIST) | awk -F':' '/^[a-z0-9_.-]+:/ \u0026\u0026 !$(NO_PHONY) {print $$1}')\n.PHONY: $(PHONY)\n\nshow_phony:\n\t@echo $(PHONY)\n```\n\n### 3. Running Tasks with makef\n\nInstead of running make directly, use makef. This command combines your original Makefile and the override Makefile, so tasks defined in both are executed together.\n\nFor example:\n\n```\nmakef\n```\n\nOutput might look like:\n\n```sh\n/tmp/tmp.u0vZq8mzkG:8: warning: overriding recipe for target 'task2'\n/tmp/tmp.u0vZq8mzkG:5: warning: ignoring old recipe for target 'task2'\ntask1                          sample task\ntask2                          overriding task\nhelp                           show help\n\n$ makef task1\n/tmp/tmp.cQARE0rtXT:8: warning: overriding recipe for target 'task2'\n/tmp/tmp.cQARE0rtXT:5: warning: ignoring old recipe for target 'task2'\necho \"this is Makefile\"\nthis is Makefile\n\n$ makef task2\n/tmp/tmp.CI2hKcYZIH:8: warning: overriding recipe for target 'task2'\n/tmp/tmp.CI2hKcYZIH:5: warning: ignoring old recipe for target 'task2'\necho \"this is Makefile\"\nthis is Makefile\necho \"from .git/Makefile\"\nfrom .git/Makefile\n```\n\nTo execute a specific task, run:\n\n```sh\nmakef task1\n```\n\nor\n\n```sh\nmakef task2\n```\n\n### 4. Bash Completion\n\nWhen using makef, simply press the Tab key to auto-complete available task names from your override Makefile.\n\n```sh\nmakef  # then press Tab to see: help   task1  task2\n```\n\n### 5. Changing the Source Makefile\n\nBy default, makef uses the Makefile in the current directory. If you want to use a different Makefile as your source, you can specify it by setting the $MAKEFILE environment variable in .envrc:\n\n```sh\nexport MAKEF_PATH=.git/Makefile\nexport MAKEFILE=path/to/Makefile  # Specify the desired Makefile\n```\n\nThen reload your environment (for example, with direnv allow).\n\n\n---\n\nmakef leverages the optional use of direnv to automatically manage the $MAKEF_PATH variable, simplifying the process of specifying a custom override Makefile for each project. Enjoy a smoother local development experience with makef!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiberianpig%2Fmakef","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiberianpig%2Fmakef","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiberianpig%2Fmakef/lists"}