Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iberianpig/makef
Override Makefile
https://github.com/iberianpig/makef
bash cli make makefile override shell task-runner
Last synced: about 1 month ago
JSON representation
Override Makefile
- Host: GitHub
- URL: https://github.com/iberianpig/makef
- Owner: iberianpig
- License: mit
- Created: 2019-06-15T06:15:27.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-21T11:01:44.000Z (11 months ago)
- Last Synced: 2024-05-01T22:07:35.879Z (7 months ago)
- Topics: bash, cli, make, makefile, override, shell, task-runner
- Language: Shell
- Homepage:
- Size: 7.81 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# makef
Override `Makefile` for developer local environment
* Extend Makefile with overriding tasks
* Behave like make -f `make -f /path/to/git/ignored/Makefile`
* Override the project's Makefile tasks in local envirioment
* Unify commands for developer's local between different projects
* No more wrong selections from Ctrl-r's command line history
* Support `bash-completion`## Installation
### 1. Install makef
register `makef` to `~/.bashrc`
```sh
$ git clone https://github.com/iberianpig/makef
$ echo -e "# makef\nsource $(find `pwd` -name makef.sh)" >> ~/.bashrc
$ source ~/.bashrc
```### 2. Install direnv
`makef` use `direnv` to set `$MAKEF_PATH` to envirionment variables
see: https://github.com/direnv/direnv
## Usage
For example, You have a default Makefile.
`./Makefile`
```Makefile
task1: ## Sample task
echo "this is Makefile"task2: task1 ## task overridden in next step
echo "from ./Makefile"
```### Export MAKEF_PATH in `.envrc`
Add `export MAKEF_PATH=/path/to/hidden/Makefile` to `.envrc` on your project
Edit `.envrc`, use `.git/Makefile` as MAKEF_PATH in this example.
```sh
export MAKEF_PATH=.git/Makefile
```Then run `direnv allow`
```sh
$ direnv allow
direnv: loading .envrc
direnv: export +MAKEF_PATH
```### Init a new Makefile
Generate a new Makefile to $MAKEF_PATH with `makefinit`.
```sh
$ makefinit
```following `.git/Makefile` is a automaticaly generated by `makefinit`
```Makefile
.PHONY: allall: help
help: ## show this messages
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'NO_PHONY = /^:/
PHONY := $(shell cat $(MAKEFILE_LIST) | awk -F':' '/^[a-z0-9_.-]+:/ && !$(NO_PHONY) {print $$1}')
.PHONY: $(PHONY)show_phony:
@echo $(PHONY)
```### Override default tasks
Then, edit Makefile($MAKEF_PATH) with `makefedit`.
```sh
$ makefedit
```Overwride your tasks.
```Makefile
.PHONY: allall: help
task2: task1 ## orverriding task
echo "from .git/Makefile"help: ## show this messages
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'NO_PHONY = /^:/
PHONY := $(shell cat $(MAKEFILE_LIST) | awk -F':' '/^[a-z0-9_.-]+:/ && !$(NO_PHONY) {print $$1}')
.PHONY: $(PHONY)show_phony:
@echo $(PHONY)
```### Use `makef` instead of `make`
```sh
$ makef
/tmp/tmp.u0vZq8mzkG:8: warning: overriding recipe for target 'task2'
/tmp/tmp.u0vZq8mzkG:5: warning: ignoring old recipe for target 'task2'
task1 sample task
task2 orverriding task
help show help$ makef task1
/tmp/tmp.cQARE0rtXT:8: warning: overriding recipe for target 'task2'
/tmp/tmp.cQARE0rtXT:5: warning: ignoring old recipe for target 'task2'
echo "this is Makefile"
this is Makefile$ makef task2
/tmp/tmp.CI2hKcYZIH:8: warning: overriding recipe for target 'task2'
/tmp/tmp.CI2hKcYZIH:5: warning: ignoring old recipe for target 'task2'
echo "this is Makefile"
this is Makefile
echo "from .git/Makefile"
from .git/Makefile
```### bash-completion with `Tab` key
```sh
$ makef # press Tab key
help task1 task2
```